Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[MapRequestPayload] Allow usage of expressions for defining validation groups#58273
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:7.4
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
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.
LGTM, here are some minor comments
src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/RequestPayloadValueResolver.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/RequestPayloadValueResolver.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
->set('controller.expression_language', ExpressionLanguage::class) | ||
->args([service('cache.request_payload_value_resolver_expression_language')->nullOnInvalid()]) | ||
->set('cache.request_payload_value_resolver_expression_language') |
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.
either the EL service is named like proposed and this needs to ba aligned, or we change the name of the EL service, but the current mix looks inconsistent to me
->set('cache.request_payload_value_resolver_expression_language') | |
->set('cache.controller_expression_language') |
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.
@nicolas-grekas true. i prefer suggested change.
fixed550c8a4
34d63e6
to4af5a37
Compare4af5a37
to14189d2
Compare5ebb49b
to1f9de26
Compare1f9de26
to29d53f3
Compare29d53f3
to85204a5
CompareIt looks like your committer email is not associated with your GitHub account, you may want to change that for credibility 🖖 |
@OskarStark thanks for advice, i fixed that 😄 |
…equestPayloadValueResolver.phpCo-authored-by: Nicolas Grekas <nicolas.grekas@gmail.com>
…equestPayloadValueResolver.phpCo-authored-by: Nicolas Grekas <nicolas.grekas@gmail.com>
85204a5
to67eb8ec
Compare
Uh oh!
There was an error while loading.Please reload this page.
This PR adds option to use Expression for defining validation groups when using
#[MapRequestPayload]
and#[MapQueryString]
Inspired by expression options when using
#[IsGranted]
, request and args are available.Example:
We have route which is used to update user info. Entity
User
has propertytype
which can beadmin
orregular
.If user is admin, his password must be very strong and they must have image while regular user can have weaker password and image is not required.
Payload used in request:
We need to dynamically determine which validation group to use based on context (User that is being updated).
Current way of doing this is to manually call
validate
method:This PR allows usage of Expression with access to arguments so above code can be replaced with
#[MapRequestPayload]