-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] Add Some and None collection constraints #44688
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
Conversation
158c5ff
to
a17f5bd
Compare
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.
👌🏻
a17f5bd
to
31e3053
Compare
So, should I write docs for this or there is no interest in this feature? |
31e3053
to
456ba5d
Compare
456ba5d
to
deecdea
Compare
is that a typo? shouldn't it be an alias of But I'm like you I don't see a lot of traction here. Let's close? I also don't see when I'd use this honestly. |
I submitted because i have an use case where I'd use it :/ |
I don't think this should be part of the core as the use cases seem to be quite limited. cc @symfony/mergers |
I think I agree with Fabien. So I am going to close here. |
This adds Some and None collection constraints which are built on top of
AtLeastOneOf
constraint which validates that value must at least satisfy one constraint, so we will now be able to validate that the required numbers of elements should match the provided constraints:Some(min=1, constraints: [..])
<- at least 1 value should be satified (default)Some(min=2, constraints: [..])
<- at least 2 values should be satisfiedSome(max=2, constraints: [..])
<- at most 2 values should be satisfiedSome(exactly=3, constraints: [..])
<- exactly 3 values should be satisfiedNone(constraints: [])
<- alias ofSome(min=0)