8000 [Validator] add documentation for the new `Timezone` constraint. by hhamon · Pull Request #11317 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

[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 10 commits into from
Apr 7, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Minor fixes
  • Loading branch information
javiereguiluz authored Apr 6, 2019
commit 135c5ffed3ccccaaf391a937ba30f451a4af1403
21 changes: 9 additions & 12 deletions reference/constraints/Timezone.rst
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>`
Expand All @@ -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``):

.. configuration-block::

Expand All @@ -31,7 +31,6 @@ meant to contain a timezone identifier (ie. `America/New_York`):
{
/**
* @Assert\Timezone
* @var string A timezone identifier
*/
protected $timezone;
}
Expand Down Expand Up @@ -69,9 +68,6 @@ meant to contain a timezone identifier (ie. `America/New_York`):

class Event
{
/**
* @var string A timezone identifier
*/
protected $timezone;
Copy link
Contributor

Choose a reason for hiding this comment

The 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)
Expand All @@ -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:

Expand All @@ -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.

Expand All @@ -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.

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
0