@@ -46,12 +46,34 @@ looks like this::
4646 // ...
4747 }
4848
49- By calling ``validate `` on the validator, you can pass in a raw value and
49+ By calling ``validate() `` on the validator, you can pass in a raw value and
5050the constraint object that you want to validate that value against. A full
5151list of the available constraints - as well as the full class name for each
5252constraint - is available in the :doc: `constraints reference </reference/constraints >`
5353section.
5454
55+ Validation of arrays is possible using the ``Collection `` constraint::
56+
57+ use Symfony\Component\Validator\Validation;
58+ use Symfony\Component\Validator\Constraints as Assert;
59+
60+ $validator = Validation::createValidator();
61+
62+ $constraint = new Assert\Collection(array(
63+ // the keys correspond to the keys in the input array
64+ 'name' => new Assert\Collection(array(
65+ 'first_name' => new Assert\Length(array('min' => 101)),
66+ 'last_name' => new Assert\Length(array('min' => 1)),
67+ )),
68+ 'email' => new Assert\Email(),
69+ 'simple' => new Assert\Length(array('min' => 102)),
70+ 'gender' => new Assert\Choice(array(3, 4)),
71+ 'file' => new Assert\File(),
72+ 'password' => new Assert\Length(array('min' => 60)),
73+ ));
74+
75+ $violations = $validator->validateValue($input, $constraint);
76+
5577The ``validate() `` method returns a :class: `Symfony\\ Component\\ Validator\\ ConstraintViolationList `
5678object, which acts just like an array of errors. Each error in the collection
5779is a :class: `Symfony\\ Component\\ Validator\\ ConstraintViolation ` object,
0 commit comments