Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions reference/constraints/NotBlank.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@ NotBlank
========

Validates that a value is not blank - meaning not equal to a blank string,
a blank array, ``null`` or ``false``::

if (false === $value || (empty($value) && '0' != $value)) {
// validation will fail
}

To force that a value is simply not equal to ``null``, see the
a blank array, ``false`` or ``null`` (null behavior is configurable). To check
that a value is not equal to ``null``, see the
:doc:`/reference/constraints/NotNull` constraint.

+----------------+------------------------------------------------------------------------+
| Applies to | :ref:`property or method <validation-property-target>` |
+----------------+------------------------------------------------------------------------+
| Options | - `message`_ |
| Options | - `allowNull`_ |
| | - `message`_ |
| | - `payload`_ |
+----------------+------------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\NotBlank` |
Expand Down Expand Up @@ -87,6 +83,18 @@ class were not blank, you could do the following:
Options
-------

allowNull
~~~~~~~~~

**type**: ``bool`` **default**: ``false``

If set to ``true``, ``null`` values are considered valid and won't trigger a
constraint violation.

.. versionadded:: 4.3

The ``allowNull`` option was introduced in Symfony 4.3.

message
~~~~~~~

Expand Down