symfony/symfony — Issue #2674: [2.1][Validator] what about to have MinCount and MaxCount validators
Author: makasim
Created: 2011-11-18 13:06:09+00:00
State: open

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.