Skip to content

Commit 99ac309

Browse files
[Validator] Mention exactly option for Length constraint
1 parent c7463b2 commit 99ac309

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

reference/constraints/Length.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,25 @@ Parameter Description
163163
``{{ value }}`` The current (invalid) value
164164
================= ============================================================
165165

166+
exactly
167+
~~~~~~~
168+
169+
**type**: ``integer``
170+
171+
This option is the exact length value. Validation will fail if
172+
the given value's length is not **exactly** equal to this value.
173+
174+
.. note::
175+
176+
This option is the one being set by default when using the Length constraint
177+
without passing any named argument to it. This means that for example,
178+
``@Assert\Length(20)`` and ``@Assert\Length(exactly=20)`` are equivalent, as
179+
well as ``#[Assert\Length(20)]`` and ``#[Assert\Length(exactly: 20)]``.
180+
181+
.. versionadded::
182+
183+
The named argument ``exactly`` was introduced in Symfony 5.2.
184+
166185
exactMessage
167186
~~~~~~~~~~~~
168187

0 commit comments

Comments
 (0)