Skip to content

Commit 3ff1ecf

Browse files
committed
minor #15028 [Validator] Mention IsNull in Basic Constraints (wkania)
This PR was merged into the 4.4 branch. Discussion ---------- [Validator] Mention IsNull in Basic Constraints [Email](https://symfony.com/doc/4.4/reference/constraints/Email.html), [Date](https://symfony.com/doc/4.4/reference/constraints/Date.html), [File](https://symfony.com/doc/4.4/reference/constraints/File.html) and other string constraints have note: > As with most of the other constraints, null and empty strings are considered valid values. This is to allow them to be optional values. If the value is mandatory, a common solution is to combine this constraint with NotBlank. This pull request adds a note about `null` to Basic Constraints. Empty/Blank string is an invalid value for them. That's why I added a new note. Commits ------- 69f9db3 [Validator] Mention IsNull in Basic Constraints
2 parents c8c63ab + 69f9db3 commit 3ff1ecf

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

reference/constraints/IsFalse.rst

+2
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ method returns **false**:
107107
// ...
108108
}
109109
110+
.. include:: /reference/constraints/_null-values-are-valid.rst.inc
111+
110112
Options
111113
-------
112114

reference/constraints/IsTrue.rst

+2
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ Then you can validate this method with ``IsTrue`` as follows:
111111
112112
If the ``isTokenValid()`` returns false, the validation will fail.
113113

114+
.. include:: /reference/constraints/_null-values-are-valid.rst.inc
115+
114116
Options
115117
-------
116118

reference/constraints/Type.rst

+2
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ This will check if ``emailAddress`` is an instance of ``Symfony\Component\Mime\A
148148
The feature to define multiple types in the ``type`` option was introduced
149149
in Symfony 4.4.
150150

151+
.. include:: /reference/constraints/_null-values-are-valid.rst.inc
152+
151153
Options
152154
-------
153155

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.. note::
2+
3+
As with most of the other constraints, ``null`` is
4+
considered a valid value. This is to allow the use of optional values.
5+
If the value is mandatory, a common solution is to combine this constraint
6+
with :doc:`NotNull </reference/constraints/NotNull>`.

0 commit comments

Comments
 (0)