1 | <?php |
||
8 | class ArrayValidator extends Validator |
||
9 | { |
||
10 | /** |
||
11 | * @var Validator[] Map of field names to validators |
||
12 | */ |
||
13 | private $validators = []; |
||
14 | |||
15 | /** |
||
16 | * @var boolean Flag if unknown array items should be ignored when validating |
||
17 | */ |
||
18 | private $ignoreUnknown = false; |
||
19 | |||
20 | /** |
||
21 | * Register validators |
||
22 | * |
||
23 | * @param Validator[] $validators Map of field names to validators |
||
24 | */ |
||
25 | public function __construct(array $validators = []) |
||
31 | |||
32 | /** |
||
33 | * Add a validator |
||
34 | * |
||
35 | * @param string $name Name of field to validate |
||
36 | * @param Validator $validator The validator |
||
37 | * @return self Instance for chaining |
||
38 | */ |
||
39 | public function addValidator($name, Validator $validator) |
||
44 | |||
45 | /** |
||
46 | * Set flag if unknown items should be ignored when validating |
||
47 | * |
||
48 | * @param boolean $ignoreUnknown |
||
49 | * @return self Instance for chaining |
||
50 | */ |
||
51 | public function ignoreUnknown($ignoreUnknown = true) |
||
56 | |||
57 | /** |
||
58 | * Validate tainted data |
||
59 | * |
||
60 | * {@inheritdoc} |
||
61 | */ |
||
62 | public function validate($tainted) |
||
89 | } |
||
90 |