1 | <?php |
||
15 | class ValidatorResolver extends Validator |
||
16 | { |
||
17 | |||
18 | protected $currentRule; |
||
19 | |||
20 | /** |
||
21 | * The validation rules that imply the field is required. |
||
22 | * |
||
23 | * @var array |
||
24 | */ |
||
25 | protected $implicitRules = [ |
||
26 | 'Required', 'Filled', 'RequiredWith', 'RequiredWithAll', 'RequiredWithout', 'RequiredWithoutAll', |
||
27 | 'RequiredIf', 'RequiredUnless', 'Accepted', 'Present', 'RequiredIfAll', 'RequiredUnlessAll', |
||
28 | ]; |
||
29 | |||
30 | /** |
||
31 | * Validate Pattern Valid |
||
32 | * |
||
33 | * @param string $attribute String Attribute |
||
34 | * @param string $value String Value |
||
35 | * @param array $parameters Array Parameters |
||
36 | * |
||
37 | * @return boolean |
||
38 | */ |
||
39 | 1 | public function validatePattern($attribute, $value, $parameters = array()) |
|
40 | { |
||
41 | 1 | return (bool) (@preg_match($value, "subject") !== false); |
|
42 | } |
||
43 | |||
44 | /** |
||
45 | * Validate Current Password |
||
46 | * |
||
47 | * @param string $attribute String Attribute |
||
48 | * @param mixed $value Mixed Value |
||
49 | * @param array $parameters Array Parameters |
||
50 | * |
||
51 | * @return bool |
||
52 | */ |
||
53 | 2 | public function validateCurrentPassword($attribute, $value, $parameters = array()) |
|
54 | { |
||
55 | 2 | $guard = isset($parameters[0]) ? $parameters[0] : null; |
|
56 | 2 | $field = isset($parameters[1]) ? $parameters[1] : 'password'; |
|
57 | 2 | return password_verify($value, auth($guard)->user()->{$field}); |
|
58 | } |
||
59 | |||
60 | /** |
||
61 | * Validate that an attribute is cpf valid |
||
62 | * |
||
63 | * @param string $attribute String Attribute |
||
64 | * @param mixed $value Mixed Value |
||
65 | * @param array $parameters Array Parameters |
||
66 | * |
||
67 | * @return bool |
||
68 | */ |
||
69 | 1 | public function validateDocument($attribute, $value, $parameters = array()) |
|
70 | { |
||
71 | 1 | $value = preg_replace('/[^0-9]/', '', $value); |
|
72 | 1 | if (strlen($value) == 11) { |
|
73 | 1 | return $this->validateCpf($attribute, $value, $parameters); |
|
74 | } |
||
75 | |||
76 | 1 | return $this->validateCnpj($attribute, $value, $parameters); |
|
77 | } |
||
78 | |||
79 | /** |
||
80 | * Validate currency |
||
81 | * |
||
82 | * @param string $attribute String Attribute |
||
83 | * @param mixed $value Mixed Value |
||
84 | * @param array $parameters Array Parameters |
||
85 | * |
||
86 | * @return bool |
||
87 | */ |
||
88 | 40 | public function validateCurrency($attribute, $value, $parameters = array()) |
|
92 | |||
93 | /** |
||
94 | * Validate the not existence of an attribute value in a database table. |
||
95 | * |
||
96 | * @param string $attribute |
||
97 | * @param mixed $value |
||
98 | * @param array $parameters |
||
99 | * @return bool |
||
100 | */ |
||
101 | 2 | public function validateNotExists($attribute, $value, $parameters) |
|
105 | |||
106 | /** |
||
107 | * Validate that an attribute exists when another attribute has a given value. |
||
108 | * |
||
109 | * @param string $attribute |
||
110 | * @param mixed $value |
||
111 | * @param mixed $parameters |
||
112 | * @return bool |
||
113 | */ |
||
114 | public function validateRequiredIf($attribute, $value, $parameters) |
||
140 | |||
141 | /** |
||
142 | * Validate that an attribute exists when another attribute does not have a given value. |
||
143 | * |
||
144 | * @param string $attribute |
||
145 | * @param mixed $value |
||
146 | * @param mixed $parameters |
||
147 | * @return bool |
||
148 | */ |
||
149 | public function validateRequiredUnless($attribute, $value, $parameters) |
||
165 | |||
166 | /** |
||
167 | * Validate that an attribute exists when another attribute has a given value. |
||
168 | * |
||
169 | * @param string $attribute |
||
170 | * @param mixed $value |
||
171 | * @param mixed $parameters |
||
172 | * @return bool |
||
173 | */ |
||
174 | 6 | public function validateRequiredIfAll($attribute, $value, $parameters) |
|
208 | |||
209 | /** |
||
210 | * Validate that an attribute exists when another attribute does not have a given value. |
||
211 | * |
||
212 | * @param string $attribute |
||
213 | * @param mixed $value |
||
214 | * @param mixed $parameters |
||
215 | * @return bool |
||
216 | */ |
||
217 | 6 | public function validateRequiredUnlessAll($attribute, $value, $parameters) |
|
242 | |||
243 | /** |
||
244 | * Replace all place-holders for the after rule. |
||
245 | * |
||
246 | * @param string $message |
||
247 | * @param string $attribute |
||
248 | * @param string $rule |
||
249 | * @param array $parameters |
||
250 | * @return string |
||
251 | */ |
||
252 | 1 | public function replaceBeforeOrEqual($message, $attribute, $rule, $parameters) |
|
256 | |||
257 | /** |
||
258 | * Replace all place-holders for the after rule. |
||
259 | * |
||
260 | * @param string $message |
||
261 | * @param string $attribute |
||
262 | * @param string $rule |
||
263 | * @param array $parameters |
||
264 | * @return string |
||
265 | */ |
||
266 | 1 | public function replaceAfterOrEqual($message, $attribute, $rule, $parameters) |
|
270 | |||
271 | /** |
||
272 | * {@inheritdoc} |
||
273 | */ |
||
274 | 9 | public function __call($method, $parameters) |
|
291 | } |
||
292 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.