1 | <?php |
||
29 | class Nested implements \Caridea\Validate\Draft |
||
30 | { |
||
31 | /** |
||
32 | * @var string The operator type |
||
33 | */ |
||
34 | private $operator; |
||
35 | /** |
||
36 | * @var \Caridea\Validate\Validator Optional. A validator for nested objects. |
||
37 | */ |
||
38 | private $validator; |
||
39 | /** |
||
40 | * @var string Optional field on object that chooses rules. |
||
41 | */ |
||
42 | private $field; |
||
43 | |||
44 | /** |
||
45 | * Creates a new NestedRule. |
||
46 | * |
||
47 | * @param string $operator The operator type |
||
48 | * @param mixed|\Caridea\Validate\Validator The validator to use, or definitions to create one |
||
49 | * @param string $field Optional field on object that chooses rules |
||
50 | */ |
||
51 | 4 | protected function __construct(string $operator, $validator, string $field = null) |
|
57 | |||
58 | /** |
||
59 | * Finishes creating a rule using the parent builder. |
||
60 | * |
||
61 | * @param \Caridea\Validate\Builder $builder |
||
62 | * @return \Caridea\Validate\Rule The fully created rule |
||
63 | */ |
||
64 | 4 | public function finish(\Caridea\Validate\Builder $builder): \Caridea\Validate\Rule |
|
88 | |||
89 | /** |
||
90 | * Validates the provided value. |
||
91 | * |
||
92 | * @param mixed $value A value to validate against the rule |
||
93 | * @param array|object $data The dataset which contains this field |
||
94 | * @return array An array of error codes or null if validation succeeded |
||
95 | */ |
||
96 | 6 | public function apply($value, $data = []) |
|
131 | |||
132 | /** |
||
133 | * Verifies an object value against separate validator rules. |
||
134 | * |
||
135 | * @param object $ruleset The validation ruleset |
||
136 | * @return \Caridea\Validate\Rule\Nested the created rule |
||
137 | */ |
||
138 | 1 | public static function nestedObject(\stdClass $ruleset): Nested |
|
142 | |||
143 | /** |
||
144 | * Verifies each entry in a list using one or more rules. |
||
145 | * |
||
146 | * @param mixed $rules The rule or rules to enforce |
||
147 | * @return \Caridea\Validate\Rule\Nested the created rule |
||
148 | */ |
||
149 | 1 | public static function listOf($rules): Nested |
|
153 | |||
154 | /** |
||
155 | * Verifies each entry in a list against separate validator rules. |
||
156 | * |
||
157 | * @param object $ruleset The validation ruleset |
||
158 | * @return \Caridea\Validate\Rule\Nested the created rule |
||
159 | */ |
||
160 | 1 | public static function listOfObjects(\stdClass $ruleset): Nested |
|
164 | |||
165 | /** |
||
166 | * Verifies each entry in a list using one of several validators based on a field value. |
||
167 | * |
||
168 | * @param string $field The deciding field name |
||
169 | * @param object $rulesets The rulesets |
||
170 | * @return \Caridea\Validate\Rule\Nested the created rule |
||
171 | */ |
||
172 | 1 | public static function listOfDifferentObjects(string $field, \stdClass $rulesets): Nested |
|
176 | } |
||
177 |