@@ -9,11 +9,12 @@ Validates that a value is a valid timezone identifier (e.g. ``Europe/Paris``).
9
9
10
10
========== ======================================================================
11
11
Applies to :ref: `property or method <validation-property-target >`
12
- Options - `groups `_
12
+ Options - `countryCode `_
13
+ - `groups `_
14
+ - `intlCompatible `_
13
15
- `message `_
14
16
- `payload `_
15
17
- `zone `_
16
- - `countryCode `_
17
18
Class :class: `Symfony\\ Component\\ Validator\\ Constraints\\ Timezone `
18
19
Validator :class: `Symfony\\ Component\\ Validator\\ Constraints\\ TimezoneValidator `
19
20
========== ======================================================================
@@ -22,7 +23,7 @@ Basic Usage
22
23
-----------
23
24
24
25
Suppose you have a ``UserSettings `` class, with a ``timezone `` field that is a
25
- string meant to contain a timezone identifier (e.g. ``America/New_York ``):
26
+ string meant to contain a ` PHP timezone identifier`_ (e.g. ``America/New_York ``):
26
27
27
28
.. configuration-block ::
28
29
@@ -85,8 +86,28 @@ string meant to contain a timezone identifier (e.g. ``America/New_York``):
85
86
Options
86
87
-------
87
88
89
+ countryCode
90
+ ~~~~~~~~~~~
91
+
92
+ **type **: ``string `` **default **: ``null ``
93
+
94
+ If the ``zone `` option is set to ``\DateTimeZone::PER_COUNTRY ``, this option
95
+ restricts the valid timezone identifiers to the ones that belong to the given
96
+ country.
97
+
98
+ The value of this option must be a valid `ISO 3166-1 alpha-2 `_ country code
99
+ (e.g. ``CN `` for China).
100
+
88
101
.. include :: /reference/constraints/_groups-option.rst.inc
89
102
103
+ intlCompatible
104
+ ~~~~~~~~~~~~~~
105
+
106
+ **type **: ``boolean `` **default **: ``false ``
107
+
108
+ If ``true ``, this constraint also considers valid any of the
109
+ :ref: `ICU timezones <component-inlt-timezones >` provided by the Intl component.
110
+
90
111
message
91
112
~~~~~~~
92
113
@@ -131,17 +152,6 @@ In addition, there are some special zone values:
131
152
* ``\DateTimeZone::PER_COUNTRY `` restricts the valid timezones to a certain
132
153
country (which is defined using the ``countryCode `` option).
133
154
134
- countryCode
135
- ~~~~~~~~~~~
136
-
137
- **type **: ``string `` **default **: ``null ``
138
-
139
- If the ``zone `` option is set to ``\DateTimeZone::PER_COUNTRY ``, this option
140
- restricts the valid timezone identifiers to the ones that belong to the given
141
- country.
142
-
143
- The value of this option must be a valid `ISO 3166-1 alpha-2 `_ country code
144
- (e.g. ``CN `` for China).
145
-
155
+ .. _`PHP timezone identifier` : https://www.php.net/manual/en/timezones.php
146
156
.. _`DateTimeZone` : https://www.php.net/datetimezone
147
157
.. _`ISO 3166-1 alpha-2` : https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
0 commit comments