File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,31 @@ characters long::
4545 echo $violation->getMessage().'<br>';
4646 }
4747 }
48+
49+ Validation of arrays is possible using the `Collection ` constraint::
50+
51+
52+ use Symfony\Component\Validator\Validation;
53+ use Symfony\Component\Validator\Constraints as Assert;
54+
55+ $validator = Validation::createValidator();
56+
57+ $constraint = new Assert\Collection(array(
58+ 'name' => new Assert\Collection(array(
59+ 'first_name' => new Assert\Length(array('min' => 101)),
60+ 'last_name' => new Assert\Length(array('min' => 1)),
61+ )),
62+ 'email' => new Assert\Email(),
63+ 'simple' => new Assert\Length(array('min' => 102)),
64+ 'gender' => new Assert\Choice(array(3, 4)),
65+ 'file' => new Assert\File(),
66+ 'password' => new Assert\Length(array('min' => 60)),
67+ ));
68+
69+ $violations = $validator->validateValue($input, $constraint);
70+
71+
72+ Again, the validator returns the list of violations.
4873
4974Retrieving a Validator Instance
5075-------------------------------
You can’t perform that action at this time.
0 commit comments