Skip to content

Commit

Permalink
feat: add warning for number constraints with PHP 7.x
Browse files Browse the repository at this point in the history
  • Loading branch information
alexislefebvre committed Apr 8, 2024
1 parent a5977ce commit 7341079
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions reference/constraints/GreaterThan.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Class :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThan`
Validator :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThanValidator`
========== ===================================================================

.. include:: /reference/constraints/_php7-string-and-number.rst.inc

Basic Usage
-----------

Expand Down
2 changes: 2 additions & 0 deletions reference/constraints/GreaterThanOrEqual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Class :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThanOrEqu
Validator :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThanOrEqualValidator`
========== ===================================================================

.. include:: /reference/constraints/_php7-string-and-number.rst.inc

Basic Usage
-----------

Expand Down
2 changes: 2 additions & 0 deletions reference/constraints/LessThan.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Class :class:`Symfony\\Component\\Validator\\Constraints\\LessThan`
Validator :class:`Symfony\\Component\\Validator\\Constraints\\LessThanValidator`
========== ===================================================================

.. include:: /reference/constraints/_php7-string-and-number.rst.inc

Basic Usage
-----------

Expand Down
2 changes: 2 additions & 0 deletions reference/constraints/LessThanOrEqual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Class :class:`Symfony\\Component\\Validator\\Constraints\\LessThanOrEqual`
Validator :class:`Symfony\\Component\\Validator\\Constraints\\LessThanOrEqualValidator`
========== ===================================================================

.. include:: /reference/constraints/_php7-string-and-number.rst.inc

Basic Usage
-----------

Expand Down
2 changes: 2 additions & 0 deletions reference/constraints/Negative.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Class :class:`Symfony\\Component\\Validator\\Constraints\\Negative`
Validator :class:`Symfony\\Component\\Validator\\Constraints\\LessThanValidator`
========== ===================================================================

.. include:: /reference/constraints/_php7-string-and-number.rst.inc

Basic Usage
-----------

Expand Down
2 changes: 2 additions & 0 deletions reference/constraints/NegativeOrZero.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Class :class:`Symfony\\Component\\Validator\\Constraints\\NegativeOrZero`
Validator :class:`Symfony\\Component\\Validator\\Constraints\\LessThanOrEqualValidator`
========== ===================================================================

.. include:: /reference/constraints/_php7-string-and-number.rst.inc

Basic Usage
-----------

Expand Down
2 changes: 2 additions & 0 deletions reference/constraints/Positive.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Class :class:`Symfony\\Component\\Validator\\Constraints\\Positive`
Validator :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThanValidator`
========== ===================================================================

.. include:: /reference/constraints/_php7-string-and-number.rst.inc

Basic Usage
-----------

Expand Down
2 changes: 2 additions & 0 deletions reference/constraints/PositiveOrZero.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Class :class:`Symfony\\Component\\Validator\\Constraints\\PositiveOrZero`
Validator :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThanOrEqualValidator`
========== ===================================================================

.. include:: /reference/constraints/_php7-string-and-number.rst.inc

Basic Usage
-----------

Expand Down
6 changes: 6 additions & 0 deletions reference/constraints/_php7-string-and-number.rst.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.. caution::

When using PHP 7.x, if the value is a string (e.g. ``1234asd``), the validator
will not trigger an error. In this case, you must also use the
:doc:`Type constraint </reference/constraints/Type>` with
``numeric``, ``integer`, etc. to reject strings.

0 comments on commit 7341079

Please sign in to comment.