Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Validator] Add support for theotherwise option in theWhen constraint#59634
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
nicolas-grekas commentedJan 28, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I'm not sure this is what the issue is about. From what I can read, they need a ternary style instead: when foo ? then-this : else-that.
(please take time to give example in PR descriptions for new feature so that it's easy to bootstrap the doc / write a blog post.) |
alexandre-daubois commentedJan 28, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I did so to be consistent with the Expression constraint, taking the last issue comment example as reference which seemed more in line with what already exists. But if we don't care about this point, let's do as you say, works for me as well 👍
My bad indeed, will do! |
nicolas-grekas commentedJan 28, 2025
I don't see the point of a negate option here sorry. |
Kocal commentedJan 28, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Hey! Given your proposal, the example from#57370 will become: #[Assert\When('this.getProduct()?.getNature()?.value === "SESSION"',newAssert\IsNull())]#[Assert\When('this.getProduct()?.getNature()?.value === "SESSION"',newAssert\NotNull(), negate:true)] right? What about this syntax suggested in the issue and by Nicolas above? #[Assert\When('this.getProduct()?.getNature()?.value === "SESSION"',newAssert\IsNull(), otherwise:newAssert\NotNull())] or maybe a |
alexandre-daubois commentedJan 28, 2025
|
7dcfac3 to5439efbComparealexandre-daubois commentedJan 28, 2025
It's been more complicated than expected because of how composite constraints work. Their internals has to be updated to accept multiple fields that contains nested constraints (and propagate groups). For this, So here's a new implementation, tell me what you think 👍 |
negate option in theWhen constraintotherwise option in theWhen constraintUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
5439efb tod62d845CompareUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
d62d845 to4d3393fComparealexandre-daubois commentedFeb 5, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
All comments addressed, thanks! Should a PR be sent to update to |
nicolas-grekas commentedFeb 5, 2025
get_debug_type is to be used in exception messages. that's better, but not critical either. |
fabpot commentedFeb 7, 2025
Thank you@alexandre-daubois. |
bc08cb4 intosymfony:7.3Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
This feature allows to give constraints to
Whenwhen the evaluated expression returns false: