From 08e724cd7edde50329ff652a2764b3498f5a9585 Mon Sep 17 00:00:00 2001 From: Lctrs Date: Thu, 20 Jun 2019 00:01:25 +0200 Subject: [PATCH] Document the new property path options of the Range constraint --- reference/constraints/Range.rst | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/reference/constraints/Range.rst b/reference/constraints/Range.rst index 9b8fab33d69..4261c4b1054 100644 --- a/reference/constraints/Range.rst +++ b/reference/constraints/Range.rst @@ -9,8 +9,10 @@ Options - `groups`_ - `invalidMessage`_ - `max`_ - `maxMessage`_ + - `maxPropertyPath`_ - `min`_ - `minMessage`_ + - `minPropertyPath`_ - `payload`_ Class :class:`Symfony\\Component\\Validator\\Constraints\\Range` Validator :class:`Symfony\\Component\\Validator\\Constraints\\RangeValidator` @@ -358,6 +360,28 @@ Parameter Description ``{{ value }}`` The current (invalid) value =============== ============================================================== +maxPropertyPath +~~~~~~~~~~~~~~~ + +**type**: ``string`` + +.. versionadded:: 4.4 + + The ``maxPropertyPath`` option was introduced in Symfony 4.4. + +It defines the object property whose value is used as ``max`` option. + +For example, if you want to compare the ``$submittedDate`` property of some object +with regard to the ``$deadline`` property of the same object, use +``maxPropertyPath="deadline"`` in the range constraint of ``$submittedDate``. + +.. tip:: + + When using this option, its value is available in error messages as the + ``{{ max_limit_path }}`` placeholder. Although it's not intended to + include it in the error messages displayed to end users, it's useful when + using APIs for doing any mapping logic on client-side. + min ~~~ @@ -383,6 +407,28 @@ Parameter Description ``{{ value }}`` The current (invalid) value =============== ============================================================== +minPropertyPath +~~~~~~~~~~~~~~~ + +**type**: ``string`` + +.. versionadded:: 4.4 + + The ``minPropertyPath`` option was introduced in Symfony 4.4. + +It defines the object property whose value is used as ``min`` option. + +For example, if you want to compare the ``$endDate`` property of some object +with regard to the ``$startDate`` property of the same object, use +``minPropertyPath="startDate"`` in the range constraint of ``$endDate``. + +.. tip:: + + When using this option, its value is available in error messages as the + ``{{ min_limit_path }}`` placeholder. Although it's not intended to + include it in the error messages displayed to end users, it's useful when + using APIs for doing any mapping logic on client-side. + .. include:: /reference/constraints/_payload-option.rst.inc .. _`is_numeric`: https://php.net/manual/en/function.is-numeric.php