Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[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

Closed
wants to merge 1 commit into from

Conversation

norkunas
Copy link
Contributor

Q A
Branch? 6.1
Bug fix? no
New feature? yes
Deprecations? no
Tickets #9888
License MIT
Doc PR -

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 satisfied
Some(max=2, constraints: [..]) <- at most 2 values should be satisfied
Some(exactly=3, constraints: [..]) <- exactly 3 values should be satisfied
None(constraints: []) <- alias of Some(min=0)

@carsonbot carsonbot added this to the 6.1 milestone Dec 17, 2021
@norkunas norkunas force-pushed the some-validator-constraint branch 2 times, most recently from 158c5ff to a17f5bd Compare December 17, 2021 11:51
Copy link
Contributor

@OskarStark OskarStark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌🏻

@norkunas norkunas force-pushed the some-validator-constraint branch from a17f5bd to 31e3053 Compare December 20, 2021 04:31
@norkunas
Copy link
Contributor Author

So, should I write docs for this or there is no interest in this feature?

@norkunas norkunas force-pushed the some-validator-constraint branch from 31e3053 to 456ba5d Compare March 18, 2022 07:27
@norkunas norkunas force-pushed the some-validator-constraint branch from 456ba5d to deecdea Compare April 1, 2022 12:18
@nicolas-grekas
Copy link
Member

None(constraints: []) <- alias of Some(min=0)

is that a typo? shouldn't it be an alias of Some(exactly=0?

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.

@norkunas
Copy link
Contributor Author

norkunas commented Apr 1, 2022

I submitted because i have an use case where I'd use it :/

@fabpot
Copy link
Member

fabpot commented Jul 20, 2022

I don't think this should be part of the core as the use cases seem to be quite limited. cc @symfony/mergers

@xabbuh
Copy link
Member

xabbuh commented Jul 21, 2022

I think I agree with Fabien. So I am going to close here.

@xabbuh xabbuh closed this Jul 21, 2022
@norkunas norkunas deleted the some-validator-constraint branch July 21, 2022 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants