-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Validator] feat(when constraint): add context variable #20314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,14 +163,16 @@ validation of constraints won't be triggered. | |
To learn more about the expression language syntax, see | ||
:doc:`/reference/formats/expression_language`. | ||
|
||
Depending on how you use the constraint, you have access to 1 or 2 variables | ||
Depending on how you use the constraint, you have access to 1 or 3 variables | ||
in your expression: | ||
|
||
``this`` | ||
The object being validated (e.g. an instance of Discount). | ||
``value`` | ||
The value of the property being validated (only available when | ||
the constraint is applied to a property). | ||
``context`` | ||
This is the context that is used in validation | ||
Comment on lines
+174
to
+175
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add a versionadded directive for this new variable ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to improve this description. Right now it's basically saying "context is the validation context" 😐 For example, in the Validation article (https://symfony.com/doc/current/validation.html) the word There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done while merging too. Thanks. |
||
|
||
The ``value`` variable can be used when you want to execute more complex | ||
validation based on its value: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To match with text in doc for Expression constraint, "to 1 or 3 variables" doesn't feel clear to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about « multiple internal variables »
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done while merging. Thanks.