-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Validator] add documentation for the new Timezone
constraint.
#11317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b0b1498
[Validator] add documentation for the new `Timezone` constraint.
hhamon 135c5ff
Minor fixes
javiereguiluz ac6282f
Listed the geographical zones defined by PHP
javiereguiluz d564218
Minor fixes
javiereguiluz b37bc78
Minor fixes
hhamon c5681bf
Add more explanations
hhamon 9cbeb75
Fixes options list table
hhamon ec7bd40
Revert country_code to countryCode
hhamon 5ec9159
Fix option
hhamon 8e33d47
Fixes classification
hhamon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Minor fixes
- Loading branch information
commit 135c5ffed3ccccaaf391a937ba30f451a4af1403
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
Timezone | ||
======== | ||
|
||
Validates that a value is a valid timezone identifier (ie. ``Europe/Paris``). | ||
Validates that a value is a valid timezone identifier (e.g. ``Europe/Paris``). | ||
|
||
========== =================================================================== | ||
Applies to :ref:`property or method <validation-property-target>` | ||
|
@@ -15,8 +15,8 @@ Validator :class:`Symfony\\Component\\Validator\\Constraints\\TimezoneValidato | |
Basic Usage | ||
----------- | ||
|
||
Suppose you have a ``UserSettings`` class, with a ``timezone`` field that is a string | ||
meant to contain a timezone identifier (ie. `America/New_York`): | ||
Suppose you have a ``UserSettings`` class, with a ``timezone`` field that is a | ||
string meant to contain a timezone identifier (ie. ``America/New_York``): | ||
javiereguiluz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
.. configuration-block:: | ||
|
||
|
@@ -31,7 +31,6 @@ meant to contain a timezone identifier (ie. `America/New_York`): | |
{ | ||
/** | ||
* @Assert\Timezone | ||
* @var string A timezone identifier | ||
*/ | ||
protected $timezone; | ||
} | ||
|
@@ -69,9 +68,6 @@ meant to contain a timezone identifier (ie. `America/New_York`): | |
|
||
class Event | ||
hhamon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
/** | ||
* @var string A timezone identifier | ||
*/ | ||
protected $timezone; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I am correct, this should be removed as it is not added in other constraints |
||
|
||
public static function loadValidatorMetadata(ClassMetadata $metadata) | ||
|
@@ -90,9 +86,9 @@ Options | |
message | ||
~~~~~~~ | ||
|
||
**type**: ``string`` **default**: ``This value is not a valid time.`` | ||
**type**: ``string`` **default**: ``This value is not a valid timezone.`` | ||
|
||
This message is shown if the underlying data is not a valid time. | ||
This message is shown if the underlying data is not a valid timezone identifier. | ||
|
||
You can use the following parameters in this message: | ||
|
||
|
@@ -107,7 +103,7 @@ Parameter Description | |
zone | ||
~~~~ | ||
|
||
**type**: ``string`` **default**: ``\DateTimeZone::ALL.`` | ||
**type**: ``string`` **default**: ``\DateTimeZone::ALL`` | ||
|
||
The geographical zone in which to validate the timezone identifier. | ||
|
||
|
@@ -122,6 +118,7 @@ This option must be used only when the ``zone`` option value equals ``\DateTimeZ | |
|
||
The ``countryCode`` option enables to validate the timezone identifier is supported by the country code. | ||
javiereguiluz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Value must be a valid `ISO 3166-1 alpha-2` country code (ie. `BE`). | ||
Value must be a valid `ISO 3166-1 alpha-2`_ country code (e.g. ``BE``). | ||
|
||
.. _DateTimeZone: https://www.php.net/datetimezone | ||
.. _`DateTimeZone`: https://www.php.net/datetimezone | ||
.. _`ISO 3166-1 alpha-2`: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.