Skip to content

Document the new property path options of the Range constraint #11793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Document the new property path options of the Range constraint
  • Loading branch information
Lctrs authored and javiereguiluz committed Jul 10, 2019
commit 08e724cd7edde50329ff652a2764b3498f5a9585
46 changes: 46 additions & 0 deletions reference/constraints/Range.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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
~~~

Expand All @@ -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
Expand Down