Skip to content

[Validator] Clarify behaviour of Blank and NotBlank validator #6030

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
12 changes: 10 additions & 2 deletions reference/constraints/Blank.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@ Blank

Validates that a value is blank, defined as equal to a blank string or equal
to ``null``. To force that a value strictly be equal to ``null``, see the
:doc:`/reference/constraints/IsNull` constraint. To force that a value is
*not* blank, see :doc:`/reference/constraints/NotBlank`.
:doc:`/reference/constraints/IsNull` constraint.


.. tip::

To force that a value is *not* blank, see
:doc:`/reference/constraints/NotBlank`. But be careful as ``NotBlank`` is
*not* strictly the opposite of ``Blank``. Emtpy array and strictly
``false`` are considered blank by the ``NotBlank`` validator but not by the
``Blank`` validator.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is related to the fact how most validators treat empty strings and null values (see #4244). Maybe we can clarify this a bit?


+----------------+---------------------------------------------------------------------+
| Applies to | :ref:`property or method <validation-property-target>` |
Expand Down
4 changes: 2 additions & 2 deletions reference/constraints/NotBlank.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ NotBlank
========

Validates that a value is not blank, defined as not strictly ``false``,
not equal to a blank string and also not equal to ``null``. To force that
a value is simply not equal to ``null``, see the
not equal to a blank string, not an empty array and also not equal to ``null``.
To force that a value is simply not equal to ``null``, see the
:doc:`/reference/constraints/NotNull` constraint.

+----------------+------------------------------------------------------------------------+
Expand Down