-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
ValidatoractionableClear and specific issues ready for anyone to take them.Clear and specific issues ready for anyone to take them.good first issueIdeal for your first contribution! (some Symfony experience may be required)Ideal for your first contribution! (some Symfony experience may be required)
Milestone
Description
As of 2.1, there are two new constraints that can be used with Collection
: Optional
and Required
. They give more flexibility over the existing options allowExtraFields
and allowMissingFields
.
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,
);
Metadata
Metadata
Assignees
Labels
ValidatoractionableClear and specific issues ready for anyone to take them.Clear and specific issues ready for anyone to take them.good first issueIdeal for your first contribution! (some Symfony experience may be required)Ideal for your first contribution! (some Symfony experience may be required)