8000 minor #11886 [Validator] Documented the allowEmptyString option in Le… · symfony/symfony-docs@5c4bccc · GitHub
[go: up one dir, main page]

Skip to content

Commit 5c4bccc

Browse files
committed
minor #11886 [Validator] Documented the allowEmptyString option in Length (javiereguiluz)
This PR was merged into the 4.4 branch. Discussion ---------- [Validator] Documented the allowEmptyString option in Length This fixes #11875. When upmerging to `master`, contents will be replaced by the following: ```rst allowEmptyString ~~~~~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``false`` If set to ``true``, empty strings are considered valid (which is the same behavior as previous Symfony versions). The default ``false`` value considers empty strings not valid. ``` Commits ------- c510abb [Validator] Documented the allowEmptyString option in Length
2 parents fbd660a + c510abb commit 5c4bccc

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

reference/constraints/Length.rst

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,10 @@ Length
33

44
Validates that a given string length is *between* some minimum and maximum value.
55

6-
.. caution::
7-
8-
``null`` and empty strings are not handled by this constraint. You need to
9-
also add the :doc:`/reference/constraints/NotBlank` or :doc:`/reference/constraints/NotNull`
10-
constraints to validate against these.
11-
126
========== ===================================================================
137
Applies to :ref:`property or method <validation-property-target>`
14-
Options - `charset`_
8+
Options - `allowEmptyString`_
9+
- `charset`_
1510
- `charsetMessage`_
1611
- `exactMessage`_
1712
- `groups`_
@@ -115,6 +110,20 @@ and "50", you might add the following:
115110
Options
116111
-------
117112

113+
allowEmptyString
114+
~~~~~~~~~~~~~~~~
115+
116+
**type**: ``boolean`` **default**: ``true``
117+
118+
.. versionadded:: 4.4
119+
120+
The ``allowEmptyString`` option was introduced in Symfony 4.4.
121+
122+
When using the ``min`` option, it's mandatory to also define this option. If
123+
set to ``true``, empty strings are considered valid (which is the same behavior
124+
as previous Symfony versions). Set it to ``false`` to consider empty strings not
125+
valid.
126+
118127
charset
119128
~~~~~~~
120129

0 commit comments

Comments
 (0)
0