Skip to content

Commit c5007ae

Browse files
committed
[Validator] add code review fixes
1 parent 0fd69b6 commit c5007ae

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

reference/constraints/Negative.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Negative
22
========
33

4+
.. versionadded:: 4.3
5+
6+
The ``Negative`` constraint was introduced in Symfony 4.3.
7+
48
Validates that a value is a negative number. To force that a value is a negative
59
number or equal to zero, see :doc:`/reference/constraints/NegativeOrZero`.
610
To force a value is positive, see :doc:`/reference/constraints/Positive`.
@@ -17,22 +21,21 @@ Validator :class:`Symfony\\Component\\Validator\\Constraints\\LesserThanValida
1721
Basic 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
}

reference/constraints/Positive.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Positive
22
========
33

4+
.. versionadded:: 4.3
5+
6+
The ``Positive`` constraint was introduced in Symfony 4.3.
7+
48
Validates that a value is a positive number. To force that a value is positive
59
number or equal to zero, see :doc:`/reference/constraints/PositiveOrZero`.
610
To force a value is negative, see :doc:`/reference/constraints/Negative`.
@@ -17,7 +21,7 @@ Validator :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThanValid
1721
Basic 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
}

reference/constraints/PositiveOrZero.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
PositiveOrZero
22
==============
33

4+
.. versionadded:: 4.3
5+
6+
The ``PositiveOrZero`` constraint was introduced in Symfony 4.3.
7+
48
Validates that a value is a positive number or equal to zero. To force that
59
a value is only a positiven umber, see :doc:`/reference/constraints/Positive`.
610
To force a value is negative or equal to zero,
@@ -18,7 +22,7 @@ Validator :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThanOrEqu
1822
Basic 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
}

0 commit comments

Comments
 (0)