File tree 1 file changed +16
-8
lines changed
Filter options
1 file changed +16
-8
lines changed
Original file line number Diff line number Diff line change @@ -2,19 +2,15 @@ NotBlank
2
2
========
3
3
4
4
Validates that a value is not blank - meaning not equal to a blank string,
5
- a blank array, ``null `` or ``false ``::
6
-
7
- if (false === $value || (empty($value) && '0' != $value)) {
8
- // validation will fail
9
- }
10
-
11
- To force that a value is simply not equal to ``null ``, see the
5
+ a blank array, ``false `` or ``null `` (null behavior is configurable). To check
6
+ that a value is not equal to ``null ``, see the
12
7
:doc: `/reference/constraints/NotNull ` constraint.
13
8
14
9
+----------------+------------------------------------------------------------------------+
15
10
| Applies to | :ref: `property or method <validation-property-target >` |
16
11
+----------------+------------------------------------------------------------------------+
17
- | Options | - `message `_ |
12
+ | Options | - `allowNull `_ |
13
+ | | - `message `_ |
18
14
| | - `payload `_ |
19
15
+----------------+------------------------------------------------------------------------+
20
16
| Class | :class: `Symfony\\ Component\\ Validator\\ Constraints\\ NotBlank ` |
@@ -87,6 +83,18 @@ class were not blank, you could do the following:
87
83
Options
88
84
-------
89
85
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
+
90
98
message
91
99
~~~~~~~
92
100
You can’t perform that action at this time.
0 commit comments