8000 Added a note about the usage of NotBlank by javiereguiluz · Pull Request #10407 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

Added a note about the usage of NotBlank #10407

8000
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 7 commits 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
2 changes: 2 additions & 0 deletions reference/constraints/Bic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ will contain a Business Identifier Code (BIC).
}
}

.. include:: /reference/constraints/_empty-values-are-valid.rst.inc

Available Options
-----------------

Expand Down
2 changes: 2 additions & 0 deletions reference/constraints/CardScheme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ on an object that will contain a credit card number.
}
}

.. include:: /reference/constraints/_empty-values-are-valid.rst.inc

Available Options
-----------------

Expand Down
2 changes: 2 additions & 0 deletions reference/constraints/Country.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ Basic Usage
}
}

.. include:: /reference/constraints/_empty-values-are-valid.rst.inc

Options
-------

Expand Down
2 changes: 2 additions & 0 deletions reference/constraints/Currency.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ a valid currency, you could do the following:
}
}

.. include:: /reference/constraints/_empty-values-are-valid.rst.inc

Options
-------

Expand Down
2 changes: 2 additions & 0 deletions reference/constraints/Date.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ Basic Usage
}
}

.. include:: /reference/constraints/_empty-values-are-valid.rst.inc

Options
-------

Expand Down
2 changes: 2 additions & 0 deletions reference/constraints/DateTime.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ Basic Usage
}
}

.. include:: /reference/constraints/_empty-values-are-valid.rst.inc

Options
-------

Expand Down
2 changes: 2 additions & 0 deletions reference/constraints/Email.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ Basic Usage
}
}

.. include:: /reference/constraints/_empty-values-are-valid.rst.inc

Options
-------

Expand Down
2 changes: 2 additions & 0 deletions reference/constraints/File.rst
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ The ``bioFile`` property is validated to guarantee that it is a real file.
Its size and mime type are also validated because the appropriate options
have been specified.

.. include:: /reference/constraints/_empty-values-are-valid.rst.inc

Options
-------

Expand Down
2 changes: 2 additions & 0 deletions reference/constraints/Iban.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ will contain an International Bank Account Number.
}
}

.. include:: /reference/constraints/_empty-values-are-valid.rst.inc

Available Options
-----------------

Expand Down
2 changes: 2 additions & 0 deletions reference/constraints/Ip.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ Basic Usage
}
}

.. include:: /reference/constraints/_empty-values-are-valid.rst.inc

Options
-------

Expand Down
2 changes: 2 additions & 0 deletions reference/constraints/Isbn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ on an object that will contain an ISBN.
}
}

.. include:: /reference/constraints/_empty-values-are-valid.rst.inc

Available Options
-----------------

Expand Down
2 changes: 2 additions & 0 deletions reference/constraints/Issn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ Basic Usage
}
}

.. include:: /reference/constraints/_empty-values-are-valid.rst.inc

Options
-------

Expand Down
2 changes: 2 additions & 0 deletions reference/constraints/Language.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ Basic Usage
}
}

.. include:: /reference/constraints/_empty-values-are-valid.rst.inc

Options
-------

Expand Down
2 changes: 2 additions & 0 deletions reference/constraints/Length.rst
Original file line number Dif A851 f line number Diff line change
Expand Up @@ -110,6 +110,8 @@ and "50", you might add the following:
}
}

.. include:: /reference/constraints/_empty-values-are-valid.rst.inc

Options
-------

Expand Down
2 changes: 2 additions & 0 deletions reference/constraints/Locale.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ Basic Usage
}
}

.. include:: /reference/constraints/_empty-values-are-valid.rst.inc

Options
-------

Expand Down
2 changes: 2 additions & 0 deletions reference/constraints/Luhn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ will contain a credit card number.
}
}

.. include:: /reference/constraints/_empty-values-are-valid.rst.inc

Available Options
-----------------

Expand Down
2 changes: 2 additions & 0 deletions reference/constraints/Regex.rst
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ it a custom message:
}
}

.. include:: /reference/constraints/_empty-values-are-valid.rst.inc

Options
-------

Expand Down
2 changes: 2 additions & 0 deletions reference/constraints/Time.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ of the day when the event starts:
}
}

.. include:: /reference/constraints/_empty-values-are-valid.rst.inc

Options
-------

Expand Down
2 changes: 2 additions & 0 deletions reference/constraints/Url.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ Basic Usage
}
}

.. include:: /reference/constraints/_empty-values-are-valid.rst.inc

Options
-------

Expand Down
2 changes: 2 additions & 0 deletions reference/constraints/Uuid.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ Basic Usage
}
}

.. include:: /reference/constraints/_empty-values-are-valid.rst.inc

Options
-------

Expand Down
7 changes: 7 additions & 0 deletions reference/constraints/_empty-values-are-valid.rst.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.. note::

As with most of the other constraints, ``null`` values and empty strings
are considered valid values. Otherwise, in addition to validating this value,
you would also be requiring it, making it impossible to be optional. That's
why it's common to combine this constraint with
:doc:`NotBlank </reference/constraints/NotBlank>`.
Copy link
Member

Choose a reason for hiding this comment

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

I thought if we should maybe reword this a bit:

As with most of the other constraints, null values and empty strings are considered valid values. This is to allow them to be optional values. If the values is mandatory, a common solution is to combine this constraint with NotBlank.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that your wording is better. Could you please create a pull request for it? Thanks a lot!

Copy link
Member

Choose a reason for hiding this comment

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

here we go: #10418

0