Skip to content

Commit 26228a1

Browse files
committed
minor #13358 Consider option "allowEmptyString" in examples (W0rma)
This PR was merged into the 4.4 branch. Discussion ---------- Consider option "allowEmptyString" in examples According to https://symfony.com/doc/4.4/reference/constraints/Length.html#allowemptystring the option "allowEmptyString" is mandatory if "min" is set (only for symfony 4.4). Therefore I'd like to consider this in the examples. Commits ------- a0ffdb4 consider "allowEmptyString" option in example
2 parents 531a2db + a0ffdb4 commit 26228a1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

reference/constraints/Length.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ 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"
45+
* maxMessage = "Your first name cannot be longer than {{ limit }} characters",
46+
* allowEmptyString = false
4647
* )
4748
*/
4849
protected $firstName;
@@ -59,6 +60,7 @@ and "50", you might add the following:
5960
max: 50
6061
minMessage: 'Your first name must be at least {{ limit }} characters long'
6162
maxMessage: 'Your first name cannot be longer than {{ limit }} characters'
63+
allowEmptyString: false
6264
6365
.. code-block:: xml
6466
@@ -79,6 +81,7 @@ and "50", you might add the following:
7981
<option name="maxMessage">
8082
Your first name cannot be longer than {{ limit }} characters
8183
</option>
84+
<option name="allowEmptyString">false</option>
8285
</constraint>
8386
</property>
8487
</class>
@@ -101,6 +104,7 @@ and "50", you might add the following:
101104
'max' => 50,
102105
'minMessage' => 'Your first name must be at least {{ limit }} characters long',
103106
'maxMessage' => 'Your first name cannot be longer than {{ limit }} characters',
107+
'allowEmptyString' => false,
104108
]));
105109
}
106110
}

0 commit comments

Comments
 (0)