From 0d5f098e04cdff8e5d1993098ee115b7a355c071 Mon Sep 17 00:00:00 2001 From: Tim Stamp Date: Tue, 8 Sep 2015 14:01:30 +0100 Subject: [PATCH 1/4] Renaming constraint rst files to Is* to preserve edit history --- reference/constraints.rst | 6 +++--- reference/constraints/{False.rst => IsFalse.rst} | 5 +++++ reference/constraints/{Null.rst => IsNull.rst} | 5 +++++ reference/constraints/{True.rst => IsTrue.rst} | 5 +++++ 4 files changed, 18 insertions(+), 3 deletions(-) rename reference/constraints/{False.rst => IsFalse.rst} (96%) rename reference/constraints/{Null.rst => IsNull.rst} (95%) rename reference/constraints/{True.rst => IsTrue.rst} (96%) diff --git a/reference/constraints.rst b/reference/constraints.rst index 94077dd3052..491aa8e626c 100644 --- a/reference/constraints.rst +++ b/reference/constraints.rst @@ -8,9 +8,9 @@ Validation Constraints Reference constraints/NotBlank constraints/Blank constraints/NotNull - constraints/Null - constraints/True - constraints/False + constraints/IsNull + constraints/IsTrue + constraints/IsFalse constraints/Type constraints/Email diff --git a/reference/constraints/False.rst b/reference/constraints/IsFalse.rst similarity index 96% rename from reference/constraints/False.rst rename to reference/constraints/IsFalse.rst index 9e1cdc7a45f..67cdbf3f3b9 100644 --- a/reference/constraints/False.rst +++ b/reference/constraints/IsFalse.rst @@ -1,6 +1,11 @@ False ===== +.. caution:: + + The ``False`` constraint is deprecated since Symfony 2.7 + and will be removed in Symfony 3.0. Use the ``IsFalse`` constraint instead. + Validates that a value is ``false``. Specifically, this checks to see if the value is exactly ``false``, exactly the integer ``0``, or exactly the string "``0``". diff --git a/reference/constraints/Null.rst b/reference/constraints/IsNull.rst similarity index 95% rename from reference/constraints/Null.rst rename to reference/constraints/IsNull.rst index 81691ca79a9..09096657b53 100644 --- a/reference/constraints/Null.rst +++ b/reference/constraints/IsNull.rst @@ -1,6 +1,11 @@ Null ==== +.. caution:: + + The ``Null`` constraint is deprecated since Symfony 2.7 + and will be removed in Symfony 3.0. Use the ``IsNull`` constraint instead. + Validates that a value is exactly equal to ``null``. To force that a property is simply blank (blank string or ``null``), see the :doc:`/reference/constraints/Blank` constraint. To ensure that a property is not null, see :doc:`/reference/constraints/NotNull`. diff --git a/reference/constraints/True.rst b/reference/constraints/IsTrue.rst similarity index 96% rename from reference/constraints/True.rst rename to reference/constraints/IsTrue.rst index 18dea513a45..f3af65b6932 100644 --- a/reference/constraints/True.rst +++ b/reference/constraints/IsTrue.rst @@ -1,6 +1,11 @@ True ==== +.. caution:: + + The ``True`` constraint is deprecated since Symfony 2.7 + and will be removed in Symfony 3.0. Use the ``IsTrue`` constraint instead. + Validates that a value is ``true``. Specifically, this checks to see if the value is exactly ``true``, exactly the integer ``1``, or exactly the string "``1``". From 11db556ddb9ea6ec23345e6845429c116540586b Mon Sep 17 00:00:00 2001 From: Tim Stamp Date: Tue, 8 Sep 2015 14:05:06 +0100 Subject: [PATCH 2/4] Creating placeholder constraint rst docs for deprecated usage --- reference/constraints/False.rst | 9 +++++++++ reference/constraints/Null.rst | 9 +++++++++ reference/constraints/True.rst | 9 +++++++++ 3 files changed, 27 insertions(+) create mode 100644 reference/constraints/False.rst create mode 100644 reference/constraints/Null.rst create mode 100644 reference/constraints/True.rst diff --git a/reference/constraints/False.rst b/reference/constraints/False.rst new file mode 100644 index 00000000000..41bee6ee926 --- /dev/null +++ b/reference/constraints/False.rst @@ -0,0 +1,9 @@ +False +===== + +.. caution:: + + The ``False`` constraint is deprecated since Symfony 2.7 + and will be removed in Symfony 3.0. Use the ``IsFalse`` constraint instead. + +.. include:: /reference/constraints/IsFalse.rst diff --git a/reference/constraints/Null.rst b/reference/constraints/Null.rst new file mode 100644 index 00000000000..f6328fb14dd --- /dev/null +++ b/reference/constraints/Null.rst @@ -0,0 +1,9 @@ +Null +==== + +.. caution:: + + The ``Null`` constraint is deprecated since Symfony 2.7 + and will be removed in Symfony 3.0. Use the ``IsNull`` constraint instead. + +.. include:: /reference/constraints/IsNull.rst diff --git a/reference/constraints/True.rst b/reference/constraints/True.rst new file mode 100644 index 00000000000..285cd68bf15 --- /dev/null +++ b/reference/constraints/True.rst @@ -0,0 +1,9 @@ +True +==== + +.. caution:: + + The ``True`` constraint is deprecated since Symfony 2.7 + and will be removed in Symfony 3.0. Use the ``IsTrue`` constraint instead. + +.. include:: /reference/constraints/IsTrue.rst From f60c19abb939d129e9552f2d0346a53c359b7621 Mon Sep 17 00:00:00 2001 From: Tim Stamp Date: Tue, 8 Sep 2015 14:17:21 +0100 Subject: [PATCH 3/4] Updated constraint reference docs for Null->IsNull, False->IsFalse, True->IsTrue --- reference/constraints/Blank.rst | 2 +- reference/constraints/IsFalse.rst | 46 ++++++++++++----------------- reference/constraints/IsNull.rst | 28 +++++++----------- reference/constraints/IsTrue.rst | 48 ++++++++++++------------------- 4 files changed, 48 insertions(+), 76 deletions(-) diff --git a/reference/constraints/Blank.rst b/reference/constraints/Blank.rst index 4ce7426116c..ffbf196f435 100644 --- a/reference/constraints/Blank.rst +++ b/reference/constraints/Blank.rst @@ -3,7 +3,7 @@ Blank Validates that a value is blank, defined as equal to a blank string or equal to ``null``. To force that a value strictly be equal to ``null``, see the -:doc:`/reference/constraints/Null` constraint. To force that a value is +:doc:`/reference/constraints/IsNull` constraint. To force that a value is *not* blank, see :doc:`/reference/constraints/NotBlank`. +----------------+---------------------------------------------------------------------+ diff --git a/reference/constraints/IsFalse.rst b/reference/constraints/IsFalse.rst index 67cdbf3f3b9..a4171bcf598 100644 --- a/reference/constraints/IsFalse.rst +++ b/reference/constraints/IsFalse.rst @@ -1,32 +1,27 @@ -False -===== - -.. caution:: - - The ``False`` constraint is deprecated since Symfony 2.7 - and will be removed in Symfony 3.0. Use the ``IsFalse`` constraint instead. +IsFalse +======= Validates that a value is ``false``. Specifically, this checks to see if the value is exactly ``false``, exactly the integer ``0``, or exactly the string "``0``". -Also see :doc:`True `. +Also see :doc:`IsTrue `. -+----------------+---------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+---------------------------------------------------------------------+ -| Options | - `message`_ | -| | - `payload`_ | -+----------------+---------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\False` | -+----------------+---------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\FalseValidator` | -+----------------+---------------------------------------------------------------------+ ++----------------+-----------------------------------------------------------------------+ +| Applies to | :ref:`property or method ` | ++----------------+-----------------------------------------------------------------------+ +| Options | - `message`_ | +| | - `payload`_ | ++----------------+-----------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Validator\\Constraints\\IsFalse` | ++----------------+-----------------------------------------------------------------------+ +| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\IsFalseValidator` | ++----------------+-----------------------------------------------------------------------+ Basic Usage ----------- -The ``False`` constraint can be applied to a property or a "getter" method, +The ``IsFalse`` constraint can be applied to a property or a "getter" method, but is most commonly useful in the latter case. For example, suppose that you want to guarantee that some ``state`` property is *not* in a dynamic ``invalidStates`` array. First, you'd create a "getter" method:: @@ -55,7 +50,7 @@ method returns **false**: class Author { /** - * @Assert\False( + * @Assert\IsFalse( * message = "You've entered an invalid state." * ) */ @@ -71,7 +66,7 @@ method returns **false**: AppBundle\Entity\Author getters: stateInvalid: - - 'False': + - 'IsFalse': message: You've entered an invalid state. .. code-block:: xml @@ -84,7 +79,7 @@ method returns **false**: - + @@ -103,15 +98,10 @@ method returns **false**: { public static function loadValidatorMetadata(ClassMetadata $metadata) { - $metadata->addGetterConstraint('stateInvalid', new Assert\False()); + $metadata->addGetterConstraint('stateInvalid', new Assert\IsFalse()); } } -.. caution:: - - When using YAML, be sure to surround ``False`` with quotes (``'False'``) - or else YAML will convert this into a ``false`` boolean value. - Options ------- diff --git a/reference/constraints/IsNull.rst b/reference/constraints/IsNull.rst index 09096657b53..7c281fd1592 100644 --- a/reference/constraints/IsNull.rst +++ b/reference/constraints/IsNull.rst @@ -1,24 +1,21 @@ -Null -==== - -.. caution:: - - The ``Null`` constraint is deprecated since Symfony 2.7 - and will be removed in Symfony 3.0. Use the ``IsNull`` constraint instead. +IsNull +====== Validates that a value is exactly equal to ``null``. To force that a property is simply blank (blank string or ``null``), see the :doc:`/reference/constraints/Blank` constraint. To ensure that a property is not null, see :doc:`/reference/constraints/NotNull`. +Also see :doc:`NotNull `. + +----------------+-----------------------------------------------------------------------+ | Applies to | :ref:`property or method ` | +----------------+-----------------------------------------------------------------------+ | Options | - `message`_ | | | - `payload`_ | +----------------+-----------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Null` | +| Class | :class:`Symfony\\Component\\Validator\\Constraints\\IsNull` | +----------------+-----------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\NullValidator` | +| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\IsNullValidator` | +----------------+-----------------------------------------------------------------------+ Basic Usage @@ -39,7 +36,7 @@ of an ``Author`` class exactly equal to ``null``, you could do the following: class Author { /** - * @Assert\Null() + * @Assert\IsNull() */ protected $firstName; } @@ -50,7 +47,7 @@ of an ``Author`` class exactly equal to ``null``, you could do the following: AppBundle\Entity\Author: properties: firstName: - - 'Null': ~ + - 'IsNull': ~ .. code-block:: xml @@ -62,7 +59,7 @@ of an ``Author`` class exactly equal to ``null``, you could do the following: - + @@ -79,15 +76,10 @@ of an ``Author`` class exactly equal to ``null``, you could do the following: { public static function loadValidatorMetadata(ClassMetadata $metadata) { - $metadata->addPropertyConstraint('firstName', Assert\Null()); + $metadata->addPropertyConstraint('firstName', Assert\IsNull()); } } -.. caution:: - - When using YAML, be sure to surround ``Null`` with quotes (``'Null'``) - or else YAML will convert this into a ``null`` value. - Options ------- diff --git a/reference/constraints/IsTrue.rst b/reference/constraints/IsTrue.rst index f3af65b6932..4d971a419ae 100644 --- a/reference/constraints/IsTrue.rst +++ b/reference/constraints/IsTrue.rst @@ -1,27 +1,22 @@ -True -==== - -.. caution:: - - The ``True`` constraint is deprecated since Symfony 2.7 - and will be removed in Symfony 3.0. Use the ``IsTrue`` constraint instead. +IsTrue +====== Validates that a value is ``true``. Specifically, this checks to see if the value is exactly ``true``, exactly the integer ``1``, or exactly the string "``1``". -Also see :doc:`False `. +Also see :doc:`IsFalse `. -+----------------+---------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+---------------------------------------------------------------------+ -| Options | - `message`_ | -| | - `payload`_ | -+----------------+---------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\True` | -+----------------+---------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\TrueValidator` | -+----------------+---------------------------------------------------------------------+ ++----------------+-----------------------------------------------------------------------+ +| Applies to | :ref:`property or method ` | ++----------------+-----------------------------------------------------------------------+ +| Options | - `message`_ | +| | - `payload`_ | ++----------------+-----------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Validator\\Constraints\\IsTrue` | ++----------------+-----------------------------------------------------------------------+ +| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\IsTrueValidator` | ++----------------+-----------------------------------------------------------------------+ Basic Usage ----------- @@ -44,7 +39,7 @@ For example, suppose you have the following method:: } } -Then you can constrain this method with ``True``. +Then you can constrain this method with ``IsTrue``. .. configuration-block:: @@ -60,7 +55,7 @@ Then you can constrain this method with ``True``. protected $token; /** - * @Assert\True(message = "The token is invalid") + * @Assert\IsTrue(message = "The token is invalid") */ public function isTokenValid() { @@ -74,7 +69,7 @@ Then you can constrain this method with ``True``. AppBundle\Entity\Author: getters: tokenValid: - - 'True': + - 'IsTrue': message: The token is invalid. .. code-block:: xml @@ -87,7 +82,7 @@ Then you can constrain this method with ``True``. - + @@ -100,7 +95,7 @@ Then you can constrain this method with ``True``. namespace AppBundle\Entity; use Symfony\Component\Validator\Mapping\ClassMetadata; - use Symfony\Component\Validator\Constraints\True; + use Symfony\Component\Validator\Constraints\IsTrue; class Author { @@ -108,7 +103,7 @@ Then you can constrain this method with ``True``. public static function loadValidatorMetadata(ClassMetadata $metadata) { - $metadata->addGetterConstraint('tokenValid', new True(array( + $metadata->addGetterConstraint('tokenValid', new IsTrue(array( 'message' => 'The token is invalid.', ))); } @@ -121,11 +116,6 @@ Then you can constrain this method with ``True``. If the ``isTokenValid()`` returns false, the validation will fail. -.. caution:: - - When using YAML, be sure to surround ``True`` with quotes (``'True'``) - or else YAML will convert this into a ``true`` boolean value. - Options ------- From 68dde3a2d1de14e0404d5c8cfdbf86f49ae31ece Mon Sep 17 00:00:00 2001 From: Tim Stamp Date: Tue, 8 Sep 2015 14:19:04 +0100 Subject: [PATCH 4/4] Updating book examples to not use deprecated validation methods --- book/validation.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/book/validation.rst b/book/validation.rst index f454b78e525..35c29958a4c 100644 --- a/book/validation.rst +++ b/book/validation.rst @@ -630,7 +630,7 @@ this method must return ``true``: class Author { /** - * @Assert\True(message = "The password cannot match your first name") + * @Assert\IsTrue(message = "The password cannot match your first name") */ public function isPasswordLegal() { @@ -675,7 +675,7 @@ this method must return ``true``: { public static function loadValidatorMetadata(ClassMetadata $metadata) { - $metadata->addGetterConstraint('passwordLegal', new Assert\True(array( + $metadata->addGetterConstraint('passwordLegal', new Assert\IsTrue(array( 'message' => 'The password cannot match your first name', ))); } @@ -937,7 +937,7 @@ username and the password are different only if all other validation passes private $password; /** - * @Assert\True(message="The password cannot match your username", groups={"Strict"}) + * @Assert\IsTrue(message="The password cannot match your username", groups={"Strict"}) */ public function isPasswordLegal() { @@ -1011,7 +1011,7 @@ username and the password are different only if all other validation passes $metadata->addPropertyConstraint('username', new Assert\NotBlank()); $metadata->addPropertyConstraint('password', new Assert\NotBlank()); - $metadata->addGetterConstraint('passwordLegal', new Assert\True(array( + $metadata->addGetterConstraint('passwordLegal', new Assert\IsTrue(array( 'message' => 'The password cannot match your first name', 'groups' => array('Strict'), )));