Skip to content

Correct defintion of Range validation messages #13644

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
May 6, 2020
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
15 changes: 7 additions & 8 deletions reference/constraints/Range.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ you might add the following:
- Range:
min: 120
max: 180
minMessage: You must be at least {{ limit }}cm tall to enter
maxMessage: You cannot be taller than {{ limit }}cm to enter
notInRangeMessage: You must be between {{ min }}cm and {{ max }}cm tall to enter

.. code-block:: xml

Expand All @@ -72,8 +71,7 @@ you might add the following:
<constraint name="Range">
<option name="min">120</option>
<option name="max">180</option>
<option name="minMessage">You must be at least {{ limit }}cm tall to enter</option>
<option name="maxMessage">You cannot be taller than {{ limit }}cm to enter</option>
<option name="notInRangeMessage">You must be between {{ min }}cm and {{ max }}cm tall to enter</option>
</constraint>
</property>
</class>
Expand All @@ -94,8 +92,7 @@ you might add the following:
$metadata->addPropertyConstraint('height', new Assert\Range([
'min' => 120,
'max' => 180,
'minMessage' => 'You must be at least {{ limit }}cm tall to enter',
'maxMessage' => 'You cannot be taller than {{ limit }}cm to enter',
'notInRangeMessage' => 'You must be between {{ min }}cm and {{ max }}cm tall to enter',
]));
}
}
Expand Down Expand Up @@ -350,7 +347,8 @@ maxMessage
**type**: ``string`` **default**: ``This value should be {{ limit }} or less.``

The message that will be shown if the underlying value is more than the
`max`_ option.
`max`_ option, and no `min`_ option has been defined (if both are defined, use
`notInRangeMessage`_).

You can use the following parameters in this message:

Expand Down Expand Up @@ -397,7 +395,8 @@ minMessage
**type**: ``string`` **default**: ``This value should be {{ limit }} or more.``

The message that will be shown if the underlying value is less than the
`min`_ option.
`min`_ option, and no `max`_ option has been defined (if both are defined, use
`notInRangeMessage`_).

You can use the following parameters in this message:

Expand Down