8000 [Validator] Feature request: Constraint "Any" · Issue #21378 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
8000

[Validator] Feature request: Constraint "Any" #21378

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
TheCelavi opened this issue Jan 23, 2017 · 2 comments
Closed

[Validator] Feature request: Constraint "Any" #21378

TheCelavi opened this issue Jan 23, 2017 · 2 comments

Comments

@TheCelavi
Copy link
Contributor
Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? no
Symfony version 2., 3.

Description: There is constraint "All" that allows us to provide several fundamental constraints that all has to be valid for validation to pass. There is no constraint "Any" for which we can provide several fundamental constraints expecting at least one of those to be valid.

Example: We can, per example, have several classes, Invoice, ProInvoice, DebitNote, CreditNote (accounting). For some property path, we can expect for, per example, Invoice or ProInvoice to be provided, example:

@Assert\Any([ @Assert\Type(type="Model\Invoice"), @Assert\Type(type="Model\ProInvoice") ])

This can be done differently, via Callback validator, or Expression validator, or whatever...

However, "Any" seams a "syntactic sugar", if there is no reason for "No" I would like to submit a PR.

@ostrolucky
Copy link
Contributor

This is a duplicity of #9888

@fabpot
Copy link
Member
fabpot commented Dec 18, 2017

Closing as a duplicate then.

@fabpot fabpot closed this as completed Dec 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
0