@@ -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+
122125If set to ``true ``, empty strings are considered valid (which is the same
123126behavior as previous Symfony versions). The default ``false `` value considers
124127empty strings not valid.
0 commit comments