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 1
1
Negative
2
2
========
3
3
4
+ .. versionadded :: 4.3
5
+
6
+ The ``Negative `` constraint was introduced in Symfony 4.3.
7
+
4
8
Validates that a value is a negative number. To force that a value is a negative
5
9
number or equal to zero, see :doc: `/reference/constraints/NegativeOrZero `.
6
10
To force a value is positive, see :doc: `/reference/constraints/Positive `.
@@ -17,22 +21,21 @@ Validator :class:`Symfony\\Component\\Validator\\Constraints\\LesserThanValida
17
21
Basic Usage
18
22
-----------
19
23
20
- The following constraints ensure that:
24
+ The following constraint ensure that:
21
25
22
26
* the ``withdraw `` of a bankaccount ``TransferItem `` is a negative number (lesser than zero)
23
27
24
28
.. configuration-block ::
25
29
26
30
.. code-block :: php-annotations
27
31
28
- // src/Entity/Freezer .php
32
+ // src/Entity/TransferItem .php
29
33
namespace App\Entity;
30
34
31
35
use Symfony\Component\Validator\Constraints as Assert;
32
36
33
37
class TransferItem
34
38
{
35
-
36
39
/**
37
40
* @Assert\Negative
38
41
*/
@@ -74,6 +77,6 @@ The following constraints ensure that:
74
77
{
75
78
public static function loadValidatorMetadata(ClassMetadata $metadata)
76
79
{
77
- $metadata->addPropertyConstraint('withdraw', new Assert\Negative;
80
+ $metadata->addPropertyConstraint('withdraw', new Assert\Negative() ;
78
81
}
79
82
}
Original file line number Diff line number Diff line change 1
1
Positive
2
2
========
3
3
4
+ .. versionadded :: 4.3
5
+
6
+ The ``Positive `` constraint was introduced in Symfony 4.3.
7
+
4
8
Validates that a value is a positive number. To force that a value is positive
5
9
number or equal to zero, see :doc: `/reference/constraints/PositiveOrZero `.
6
10
To force a value is negative, see :doc: `/reference/constraints/Negative `.
@@ -17,7 +21,7 @@ Validator :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThanValid
17
21
Basic Usage
18
22
-----------
19
23
20
- The following constraints ensure that:
24
+ The following constraint ensure that:
21
25
22
26
* the ``income `` of an ``Employee `` is a positive number (greater than zero)
23
27
@@ -32,7 +36,6 @@ The following constraints ensure that:
32
36
33
37
class Employee
34
38
{
35
-
36
39
/**
37
40
* @Assert\Positive
38
41
*/
@@ -74,6 +77,6 @@ The following constraints ensure that:
74
77
{
75
78
public static function loadValidatorMetadata(ClassMetadata $metadata)
76
79
{
77
- $metadata->addPropertyConstraint('income', new Assert\Positive;
80
+ $metadata->addPropertyConstraint('income', new Assert\Positive() ;
78
81
}
79
82
}
Original file line number Diff line number Diff line change 1
1
PositiveOrZero
2
2
==============
3
3
4
+ .. versionadded :: 4.3
5
+
6
+ The ``PositiveOrZero `` constraint was introduced in Symfony 4.3.
7
+
4
8
Validates that a value is a positive number or equal to zero. To force that
5
9
a value is only a positiven umber, see :doc: `/reference/constraints/Positive `.
6
10
To force a value is negative or equal to zero,
@@ -18,7 +22,7 @@ Validator :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThanOrEqu
18
22
Basic Usage
19
23
-----------
20
24
21
- The following constraints ensure that:
25
+ The following constraint ensure that:
22
26
23
27
* the number of ``siblings `` of a ``Person `` is positive or zero
24
28
@@ -74,6 +78,6 @@ The following constraints ensure that:
74
78
{
75
79
public static function loadValidatorMetadata(ClassMetadata $metadata)
76
80
{
77
- $metadata->addPropertyConstraint('siblings', new Assert\PositiveOrZero);
81
+ $metadata->addPropertyConstraint('siblings', new Assert\PositiveOrZero( );
78
82
}
79
83
}
You can’t perform that action at this time.
0 commit comments