@@ -42,8 +42,7 @@ and "50", you might add the following:
42
42
* min = 2,
43
43
* max = 50,
44
44
* 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"
47
46
* )
48
47
*/
49
48
protected $firstName;
@@ -60,7 +59,6 @@ and "50", you might add the following:
60
59
max : 50
61
60
minMessage : ' Your first name must be at least {{ limit }} characters long'
62
61
maxMessage : ' Your first name cannot be longer than {{ limit }} characters'
63
- allowEmptyString : false
64
62
65
63
.. code-block :: xml
66
64
@@ -81,7 +79,6 @@ and "50", you might add the following:
81
79
<option name =" maxMessage" >
82
80
Your first name cannot be longer than {{ limit }} characters
83
81
</option >
84
- <option name =" allowEmptyString" >false</option >
85
82
</constraint >
86
83
</property >
87
84
</class >
@@ -104,7 +101,6 @@ and "50", you might add the following:
104
101
'max' => 50,
105
102
'minMessage' => 'Your first name must be at least {{ limit }} characters long',
106
103
'maxMessage' => 'Your first name cannot be longer than {{ limit }} characters',
107
- 'allowEmptyString' => false,
108
104
]));
109
105
}
110
106
}
@@ -119,6 +115,13 @@ allowEmptyString
119
115
120
116
**type **: ``boolean `` **default **: ``false ``
121
117
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
+
122
125
If set to ``true ``, empty strings are considered valid (which is the same
123
126
behavior as previous Symfony versions). The default ``false `` value considers
124
127
empty strings not valid.
0 commit comments