Skip to content

Commit 165c331

Browse files
committed
Merge branch '7.2' into 7.3
* 7.2: Add more details about the context variable feat(when constraint): add context variable
2 parents f05b4d8 + d46522a commit 165c331

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

reference/constraints/When.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,22 @@ validation of constraints won't be triggered.
163163
To learn more about the expression language syntax, see
164164
:doc:`/reference/formats/expression_language`.
165165

166-
Depending on how you use the constraint, you have access to 1 or 2 variables
166+
Depending on how you use the constraint, you have access to different variables
167167
in your expression:
168168

169169
``this``
170170
The object being validated (e.g. an instance of Discount).
171171
``value``
172172
The value of the property being validated (only available when
173173
the constraint is applied to a property).
174+
``context``
175+
The :class:`Symfony\\Component\\Validator\\Context\\ExecutionContextInterface`
176+
object that provides information such as the currently validated class, the
177+
name of the currently validated property, the list of violations, etc.
178+
179+
.. versionadded:: 7.2
180+
181+
The ``context`` variable in expressions was introduced in Symfony 7.2.
174182

175183
The ``value`` variable can be used when you want to execute more complex
176184
validation based on its value:

0 commit comments

Comments
 (0)