Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.3k
Closed
Labels
Milestone
Description
As of 2.1, there are two new constraints that can be used withCollection:Optional andRequired. They give more flexibility over the existing optionsallowExtraFields andallowMissingFields.
Usage:
use Symfony\Component\Validator\Constraints as Assert;use Symfony\Component\Validator\Constraints\Collection\Optional;use Symfony\Component\Validator\Constraints\Collection\Required;/** * @Assert\Collection({ * foo = @Required(), * bar = @Optional(), * baz = @Required(@Assert\Min(3)), * bam = @Optional({@Assert\NotNull, @Assert\MinLength(7)}) * )}private $options = array( 'foo' => null, 'baz' => 10,);