Skip to content

Commit 1d29562

Browse files
committed
minor #13695 [Validator] deprecate the allowEmptyString option (xabbuh)
This PR was merged into the master branch. Discussion ---------- [Validator] deprecate the allowEmptyString option fixes #13692 Commits ------- 808abdd deprecate the allowEmptyString option
2 parents c6d820f + 808abdd commit 1d29562

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

reference/constraints/Length.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ and "50", you might add the following:
4242
* min = 2,
4343
* max = 50,
4444
* minMessage = "Your first name must be at least {{ limit }} characters long",
45-
* maxMessage = "Your first name cannot be longer than {{ limit }} characters",
46-
* allowEmptyString = false
45+
* maxMessage = "Your first name cannot be longer than {{ limit }} characters"
4746
* )
4847
*/
4948
protected $firstName;
@@ -60,7 +59,6 @@ and "50", you might add the following:
6059
max: 50
6160
minMessage: 'Your first name must be at least {{ limit }} characters long'
6261
maxMessage: 'Your first name cannot be longer than {{ limit }} characters'
63-
allowEmptyString: false
6462
6563
.. code-block:: xml
6664
@@ -81,7 +79,6 @@ and "50", you might add the following:
8179
<option name="maxMessage">
8280
Your first name cannot be longer than {{ limit }} characters
8381
</option>
84-
<option name="allowEmptyString">false</option>
8582
</constraint>
8683
</property>
8784
</class>
@@ -104,7 +101,6 @@ and "50", you might add the following:
104101
'max' => 50,
105102
'minMessage' => 'Your first name must be at least {{ limit }} characters long',
106103
'maxMessage' => 'Your first name cannot be longer than {{ limit }} characters',
107-
'allowEmptyString' => false,
108104
]));
109105
}
110106
}
@@ -119,6 +115,13 @@ allowEmptyString
119115

120116
**type**: ``boolean`` **default**: ``false``
121117

118+
.. deprecated:: 5.2
119+
120+
The ``allowEmptyString`` option is deprecated since Symfony 5.2. If you
121+
want to allow empty strings too, combine the ``Length`` constraint with
122+
the :doc:`Blank constraint </reference/constraints/Blank>` inside the
123+
:doc:`AtLeastOneOf constraint </reference/constraints/AtLeastOneOf>`.
124+
122125
If set to ``true``, empty strings are considered valid (which is the same
123126
behavior as previous Symfony versions). The default ``false`` value considers
124127
empty strings not valid.

0 commit comments

Comments
 (0)