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::
45
45
echo $violation->getMessage().'<br>';
46
46
}
47
47
}
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.
48
73
49
74
Retrieving a Validator Instance
50
75
-------------------------------
You can’t perform that action at this time.
0 commit comments