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

Skip to content
[Validator] Feature request: Constraint "Any" #21378
@TheCelavi

Description

@TheCelavi
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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0