Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc246ddc

Browse files
committed
minor#10954 Document the allowNull option for NotBlank constraint (javiereguiluz)
This PR was merged into the master branch.Discussion----------Document the allowNull option for NotBlank constraintThis documentssymfony/symfony#29641Commits-------ab2c4f1 Document the allowNull option for NotBlank constraint
2 parentsbda855d +ab2c4f1 commitc246ddc

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

‎reference/constraints/NotBlank.rst‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,15 @@ NotBlank
22
========
33

44
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
127
:doc:`/reference/constraints/NotNull` constraint.
138

149
+----------------+------------------------------------------------------------------------+
1510
| Applies to|:ref:`property or method<validation-property-target>`|
1611
+----------------+------------------------------------------------------------------------+
17-
| Options| - `message`_|
12+
| Options| - `allowNull`_|
13+
|| - `message`_|
1814
|| - `payload`_|
1915
+----------------+------------------------------------------------------------------------+
2016
| Class|:class:`Symfony\\Component\\Validator\\Constraints\\NotBlank`|
@@ -87,6 +83,18 @@ class were not blank, you could do the following:
8783
Options
8884
-------
8985

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+
9098
message
9199
~~~~~~~
92100

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp