Skip to content

[Validator] what about to have MinCount and MaxCount validators #2674

@makasim

Description

@makasim

Let's say we have a bloger which can assign from one to five tags to his blog. While submiting the server should count tags and check whether the collection in the allowed range. It can be done with Choice validator and min and max options. But in this case we have such problems:

  • It should fetch all tags from db to check that choices are valid,
  • Very hard to define callback in case of using $repository->findAll()

From another side we have Min\Max and MinLength\MaxLength validators but they very restrictive (the first takes only integers and second one only strings)

So I am thinking of moving count validation rules from Choice to a new validators called MinCount and MaxCount

BTW I can do a PR if you find it useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureGood first issueIdeal for your first contribution! (some Symfony experience may be required)Validator

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions