@@ -9,11 +9,12 @@ Validates that a value is a valid timezone identifier (e.g. ``Europe/Paris``).
99
1010========== ======================================================================
1111Applies to :ref: `property or method <validation-property-target >`
12- Options - `groups `_
12+ Options - `countryCode `_
13+ - `groups `_
14+ - `intlCompatible `_
1315 - `message `_
1416 - `payload `_
1517 - `zone `_
16- - `countryCode `_
1718Class :class: `Symfony\\ Component\\ Validator\\ Constraints\\ Timezone `
1819Validator :class: `Symfony\\ Component\\ Validator\\ Constraints\\ TimezoneValidator `
1920========== ======================================================================
@@ -22,7 +23,7 @@ Basic Usage
2223-----------
2324
2425Suppose 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 which contains any of the ` PHP timezone identifiers `_ (e.g. ``America/New_York ``):
2627
2728.. configuration-block ::
2829
@@ -85,8 +86,34 @@ string meant to contain a timezone identifier (e.g. ``America/New_York``):
8586Options
8687-------
8788
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+
88101.. include :: /reference/constraints/_groups-option.rst.inc
89102
103+ intlCompatible
104+ ~~~~~~~~~~~~~~
105+
106+ **type **: ``boolean `` **default **: ``false ``
107+
108+ This constraint considers valid both the `PHP timezone identifiers `_ and the
109+ :ref: `ICU timezones <component-intl-timezones >` provided by Symfony's
110+ :doc: `Intl component </components/intl >`
111+
112+ However, the timezones provided by the Intl component can be different from the
113+ timezones provided by PHP's Intl extension (because they use different ICU
114+ versions). If this option is set to ``true ``, this constraint only considers
115+ valid the values created with the PHP ``\IntlTimeZone::createTimeZone() `` method.
116+
90117message
91118~~~~~~~
92119
@@ -131,17 +158,6 @@ In addition, there are some special zone values:
131158* ``\DateTimeZone::PER_COUNTRY `` restricts the valid timezones to a certain
132159 country (which is defined using the ``countryCode `` option).
133160
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-
161+ .. _`PHP timezone identifiers` : https://www.php.net/manual/en/timezones.php
146162.. _`DateTimeZone` : https://www.php.net/datetimezone
147163.. _`ISO 3166-1 alpha-2` : https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
0 commit comments