1 | <?php |
||
9 | class Validator |
||
10 | { |
||
11 | /** |
||
12 | * @var array |
||
13 | */ |
||
14 | protected $data; |
||
15 | |||
16 | /** |
||
17 | * @var array |
||
18 | */ |
||
19 | protected $rules; |
||
20 | |||
21 | /** |
||
22 | * @var \Infinitypaul\Validator\Errors\ErrorBag |
||
23 | */ |
||
24 | protected $errors; |
||
25 | |||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | protected static $aliases = []; |
||
30 | |||
31 | /** |
||
32 | * Validator constructor. |
||
33 | * |
||
34 | * @param array $data |
||
35 | */ |
||
36 | public function __construct(array $data) |
||
41 | |||
42 | /** |
||
43 | * @param array $data |
||
44 | * @param string $root |
||
45 | * @param array $results |
||
46 | * |
||
47 | * @return array |
||
48 | */ |
||
49 | protected function extractWildCardData(array $data, $root = '', $results = []): array |
||
61 | |||
62 | /** |
||
63 | * @param array $rules |
||
64 | */ |
||
65 | public function setRules(array $rules) |
||
69 | |||
70 | /** |
||
71 | * Loop Through The Rules. |
||
72 | */ |
||
73 | public function validate() |
||
84 | |||
85 | protected function resolveRulesContainOptional(array $rules) |
||
95 | |||
96 | /** |
||
97 | * @param $rules |
||
98 | * |
||
99 | * @return array |
||
100 | */ |
||
101 | protected function resolveRules($rules) |
||
111 | |||
112 | /** |
||
113 | * @param $rule |
||
114 | * |
||
115 | * @return mixed |
||
116 | */ |
||
117 | protected function getRuleFromString($rule) |
||
123 | |||
124 | /** |
||
125 | * @param $rule |
||
126 | * @param $options |
||
127 | * |
||
128 | * @return mixed |
||
129 | */ |
||
130 | protected function ruleFromMap($rule, $options) |
||
134 | |||
135 | /** |
||
136 | * @param $field |
||
137 | * @param \Infinitypaul\Validator\Rules\Rule $rule |
||
138 | * @param bool $optional |
||
139 | */ |
||
140 | protected function validateRule($field, Rule $rule, $optional = false) |
||
151 | |||
152 | /** |
||
153 | * @param $field |
||
154 | * @param $value |
||
155 | * @param \Infinitypaul\Validator\Rules\Rule $rule |
||
156 | */ |
||
157 | protected function validateUsingRuleObject($field, $value, Rule $rule) |
||
163 | |||
164 | /** |
||
165 | * @param $field |
||
166 | * |
||
167 | * @return array |
||
168 | */ |
||
169 | protected function getMatchingData($field) |
||
179 | |||
180 | /** |
||
181 | * @param $field |
||
182 | * @param $data |
||
183 | * |
||
184 | * @return mixed|null |
||
185 | */ |
||
186 | protected function getFieldValue($field, $data) |
||
190 | |||
191 | /** |
||
192 | * @return array |
||
193 | */ |
||
194 | public function getErrors(): array |
||
198 | |||
199 | /* |
||
200 | * Set Aliases |
||
201 | */ |
||
202 | public function setAliases(array $aliases) |
||
206 | |||
207 | public static function alias($field) |
||
211 | |||
212 | /** |
||
213 | * @param array $fields |
||
214 | * |
||
215 | * @return array |
||
216 | */ |
||
217 | public static function aliases(array $fields): array |
||
223 | } |
||
224 |