|
5 | 5 |
|
6 | 6 | The ``Week`` constraint was introduced in Symfony 7.2. |
7 | 7 |
|
8 | | -Validates that a string (or an object implementing the ``Stringable`` PHP interface) |
9 | | -matches a given week number. The week number format is defined by `ISO-8601`_ |
10 | | -and should be composed of the year and the week number, separated by a hyphen |
11 | | -(e.g. ``2022-W01``). |
| 8 | +Validates that a given string (or an object implementing the ``Stringable`` PHP |
| 9 | +interface) represents a valid week number according to the `ISO-8601`_ standard |
| 10 | +(e.g. ``2025-W01``). |
12 | 11 |
|
13 | 12 | ========== ======================================================================= |
14 | 13 | Applies to :ref:`property or method <validation-property-target>` |
@@ -87,10 +86,11 @@ the following: |
87 | 86 | } |
88 | 87 | } |
89 | 88 |
|
90 | | -.. note:: |
91 | | - |
92 | | - The constraint also checks that the given week exists in the calendar. For example, |
93 | | - ``2022-W53`` is not a valid week number for 2022, because 2022 only had 52 weeks. |
| 89 | +This constraint not only checks that the value matches the week number pattern, |
| 90 | +but it also verifies that the specified week actually exists in the calendar. |
| 91 | +According to the ISO-8601 standard, years can have either 52 or 53 weeks. For example, |
| 92 | +``2022-W53`` is not a valid because 2022 only had 52 weeks; but ``2020-W53`` is |
| 93 | +valid because 2020 had 53 weeks. |
94 | 94 |
|
95 | 95 | Options |
96 | 96 | ------- |
@@ -169,4 +169,4 @@ Parameter Description |
169 | 169 |
|
170 | 170 | .. include:: /reference/constraints/_payload-option.rst.inc |
171 | 171 |
|
172 | | -.. _ISO-8601: https://en.wikipedia.org/wiki/ISO_8601 |
| 172 | +.. _`ISO-8601`: https://en.wikipedia.org/wiki/ISO_8601 |
0 commit comments