Skip to content

Commit 9c5d8a9

Browse files
committed
validate null (Expression constraint in 2.6)
Since Symfony 2.6, the Expression constraint doesn't skip validating `null` values.
1 parent 1ea6304 commit 9c5d8a9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

reference/constraints/Expression.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,18 @@ more about the expression language syntax, see
217217
// ...
218218
}
219219
220+
.. versionadded:: 2.6
221+
Since Symfony 2.6, the Expression constraint doesn't skip ``null``
222+
values.
223+
224+
Before Symfony 2.6, the expression would never be called if the property
225+
(e.g. ``isTechnicalPost``) were ``null``. Now, if you want to allow ``null``
226+
values, you'll have write your expression like this:
227+
228+
.. code-block:: text
229+
230+
this.getCategory() === null or this.getCategory() in ["php", "symfony"] or !this.isTechnicalPost()
231+
220232
For more information about the expression and what variables are available
221233
to you, see the :ref:`expression <reference-constraint-expression-option>`
222234
option details below.

0 commit comments

Comments
 (0)