File tree Expand file tree Collapse file tree 3 files changed +19
-9
lines changed Expand file tree Collapse file tree 3 files changed +19
-9
lines changed Original file line number Diff line number Diff line change 11Negative
22========
33
4+ .. versionadded :: 4.3
5+
6+ The ``Negative `` constraint was introduced in Symfony 4.3.
7+
48Validates that a value is a negative number. To force that a value is a negative
59number or equal to zero, see :doc: `/reference/constraints/NegativeOrZero `.
610To force a value is positive, see :doc: `/reference/constraints/Positive `.
@@ -17,22 +21,21 @@ Validator :class:`Symfony\\Component\\Validator\\Constraints\\LesserThanValida
1721Basic Usage
1822-----------
1923
20- The following constraints ensure that:
24+ The following constraint ensure that:
2125
2226* the ``withdraw `` of a bankaccount ``TransferItem `` is a negative number (lesser than zero)
2327
2428.. configuration-block ::
2529
2630 .. code-block :: php-annotations
2731
28- // src/Entity/Freezer .php
32+ // src/Entity/TransferItem .php
2933 namespace App\Entity;
3034
3135 use Symfony\Component\Validator\Constraints as Assert;
3236
3337 class TransferItem
3438 {
35-
3639 /**
3740 * @Assert\Negative
3841 */
@@ -74,6 +77,6 @@ The following constraints ensure that:
7477 {
7578 public static function loadValidatorMetadata(ClassMetadata $metadata)
7679 {
77- $metadata->addPropertyConstraint('withdraw', new Assert\Negative;
80+ $metadata->addPropertyConstraint('withdraw', new Assert\Negative() ;
7881 }
7982 }
Original file line number Diff line number Diff line change 11Positive
22========
33
4+ .. versionadded :: 4.3
5+
6+ The ``Positive `` constraint was introduced in Symfony 4.3.
7+
48Validates that a value is a positive number. To force that a value is positive
59number or equal to zero, see :doc: `/reference/constraints/PositiveOrZero `.
610To force a value is negative, see :doc: `/reference/constraints/Negative `.
@@ -17,7 +21,7 @@ Validator :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThanValid
1721Basic Usage
1822-----------
1923
20- The following constraints ensure that:
24+ The following constraint ensure that:
2125
2226* the ``income `` of an ``Employee `` is a positive number (greater than zero)
2327
@@ -32,7 +36,6 @@ The following constraints ensure that:
3236
3337 class Employee
3438 {
35-
3639 /**
3740 * @Assert\Positive
3841 */
@@ -74,6 +77,6 @@ The following constraints ensure that:
7477 {
7578 public static function loadValidatorMetadata(ClassMetadata $metadata)
7679 {
77- $metadata->addPropertyConstraint('income', new Assert\Positive;
80+ $metadata->addPropertyConstraint('income', new Assert\Positive() ;
7881 }
7982 }
Original file line number Diff line number Diff line change 11PositiveOrZero
22==============
33
4+ .. versionadded :: 4.3
5+
6+ The ``PositiveOrZero `` constraint was introduced in Symfony 4.3.
7+
48Validates that a value is a positive number or equal to zero. To force that
59a value is only a positiven umber, see :doc: `/reference/constraints/Positive `.
610To force a value is negative or equal to zero,
@@ -18,7 +22,7 @@ Validator :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThanOrEqu
1822Basic Usage
1923-----------
2024
21- The following constraints ensure that:
25+ The following constraint ensure that:
2226
2327* the number of ``siblings `` of a ``Person `` is positive or zero
2428
@@ -74,6 +78,6 @@ The following constraints ensure that:
7478 {
7579 public static function loadValidatorMetadata(ClassMetadata $metadata)
7680 {
77- $metadata->addPropertyConstraint('siblings', new Assert\PositiveOrZero);
81+ $metadata->addPropertyConstraint('siblings', new Assert\PositiveOrZero( );
7882 }
7983 }
You can’t perform that action at this time.
0 commit comments