@@ -2,19 +2,15 @@ NotBlank
22========
33
44Validates that a value is not blank - meaning not equal to a blank string,
5- a blank array, ``null `` or ``false ``::
6-
7- if (false === $value || (empty($value) && '0' != $value)) {
8- // validation will fail
9- }
10-
11- To force that a value is simply not equal to ``null ``, see the
5+ a blank array, ``false `` or ``null `` (null behavior is configurable). To check
6+ that a value is not equal to ``null ``, see the
127:doc: `/reference/constraints/NotNull ` constraint.
138
149+----------------+------------------------------------------------------------------------+
1510| Applies to | :ref: `property or method <validation-property-target >` |
1611+----------------+------------------------------------------------------------------------+
17- | Options | - `message `_ |
12+ | Options | - `allowNull `_ |
13+ | | - `message `_ |
1814| | - `payload `_ |
1915+----------------+------------------------------------------------------------------------+
2016| Class | :class: `Symfony\\ Component\\ Validator\\ Constraints\\ NotBlank ` |
@@ -87,6 +83,18 @@ class were not blank, you could do the following:
8783 Options
8884-------
8985
86+ allowNull
87+ ~~~~~~~~~
88+
89+ **type **: ``bool `` **default **: ``false ``
90+
91+ If set to ``true ``, ``null `` values are considered valid and won't trigger a
92+ constraint violation.
93+
94+ .. versionadded :: 4.3
95+
96+ The ``allowNull `` option was introduced in Symfony 4.3.
97+
9098message
9199~~~~~~~
92100
0 commit comments