Skip to content

Commit 376e70d

Browse files
committed
minor #11793 Document the new property path options of the Range constraint (Lctrs)
This PR was squashed before being merged into the 4.4 branch (closes #11793). Discussion ---------- Document the new property path options of the Range constraint Related PR : symfony/symfony#31511 Commits ------- 08e724c Document the new property path options of the Range constraint
2 parents 430dea8 + 08e724c commit 376e70d

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

reference/constraints/Range.rst

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ Options - `groups`_
99
- `invalidMessage`_
1010
- `max`_
1111
- `maxMessage`_
12+
- `maxPropertyPath`_
1213
- `min`_
1314
- `minMessage`_
15+
- `minPropertyPath`_
1416
- `payload`_
1517
Class :class:`Symfony\\Component\\Validator\\Constraints\\Range`
1618
Validator :class:`Symfony\\Component\\Validator\\Constraints\\RangeValidator`
@@ -358,6 +360,28 @@ Parameter Description
358360
``{{ value }}`` The current (invalid) value
359361
=============== ==============================================================
360362

363+
maxPropertyPath
364+
~~~~~~~~~~~~~~~
365+
366+
**type**: ``string``
367+
368+
.. versionadded:: 4.4
369+
370+
The ``maxPropertyPath`` option was introduced in Symfony 4.4.
371+
372+
It defines the object property whose value is used as ``max`` option.
373+
374+
For example, if you want to compare the ``$submittedDate`` property of some object
375+
with regard to the ``$deadline`` property of the same object, use
376+
``maxPropertyPath="deadline"`` in the range constraint of ``$submittedDate``.
377+
378+
.. tip::
379+
380+
When using this option, its value is available in error messages as the
381+
``{{ max_limit_path }}`` placeholder. Although it's not intended to
382+
include it in the error messages displayed to end users, it's useful when
383+
using APIs for doing any mapping logic on client-side.
384+
361385
min
362386
~~~
363387

@@ -383,6 +407,28 @@ Parameter Description
383407
``{{ value }}`` The current (invalid) value
384408
=============== ==============================================================
385409

410+
minPropertyPath
411+
~~~~~~~~~~~~~~~
412+
413+
**type**: ``string``
414+
415+
.. versionadded:: 4.4
416+
417+
The ``minPropertyPath`` option was introduced in Symfony 4.4.
418+
419+
It defines the object property whose value is used as ``min`` option.
420+
421+
For example, if you want to compare the ``$endDate`` property of some object
422+
with regard to the ``$startDate`` property of the same object, use
423+
``minPropertyPath="startDate"`` in the range constraint of ``$endDate``.
424+
425+
.. tip::
426+
427+
When using this option, its value is available in error messages as the
428+
``{{ min_limit_path }}`` placeholder. Although it's not intended to
429+
include it in the error messages displayed to end users, it's useful when
430+
using APIs for doing any mapping logic on client-side.
431+
386432
.. include:: /reference/constraints/_payload-option.rst.inc
387433

388434
.. _`is_numeric`: https://php.net/manual/en/function.is-numeric.php

0 commit comments

Comments
 (0)