1 | <?php |
||
29 | class SwitchValidator extends Validator |
||
30 | { |
||
31 | /** |
||
32 | * @var string Field name to inspect |
||
33 | */ |
||
34 | protected $field; |
||
35 | /** |
||
36 | * @var Validator[] Associative array of field value to validator |
||
37 | */ |
||
38 | protected $validators; |
||
39 | |||
40 | /** |
||
41 | * Creates a new switch validator. |
||
42 | * |
||
43 | * @param string Field name to inspect |
||
44 | * @param array $validators Associative array of field value to validator |
||
45 | */ |
||
46 | 3 | public function __construct(string $field, array $validators) |
|
52 | |||
53 | /** |
||
54 | * Iterates over the ruleset and collects any error codes. |
||
55 | * |
||
56 | * @param object|array $values An object or associative array to validate |
||
57 | * @return array Associative array of field name to error |
||
58 | * @throws \InvalidArgumentException if `$values` is null or matching validator |
||
59 | */ |
||
60 | 3 | protected function iterate($values): array |
|
72 | } |
||
73 |