Skip to content

Commit e70b0df

Browse files
committed
Re-added the allowNull option
1 parent 5ba1b4d commit e70b0df

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

reference/constraints/NotBlank.rst

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ NotBlank
22
========
33

44
Validates that a value is not blank - meaning not equal to a blank string,
5-
a blank array, ``false`` or ``null``. To check that a value is not equal to
6-
``null``, see the :doc:`/reference/constraints/NotNull` constraint.
5+
a blank array, ``false`` or ``null`` (null behavior is configurable). To check
6+
that a value is not equal to ``null``, see the
7+
:doc:`/reference/constraints/NotNull` constraint.
78

89
+----------------+------------------------------------------------------------------------+
910
| Applies to | :ref:`property or method <validation-property-target>` |
1011
+----------------+------------------------------------------------------------------------+
11-
| Options | - `message`_ |
12+
| Options | - `allowNull`_ |
13+
| | - `message`_ |
1214
| | - `payload`_ |
1315
+----------------+------------------------------------------------------------------------+
1416
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\NotBlank` |
@@ -81,6 +83,18 @@ class were not blank, you could do the following:
8183
Options
8284
-------
8385

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+
8498
message
8599
~~~~~~~
86100

0 commit comments

Comments
 (0)