1 | <?php |
||
9 | class ValidatorHandler |
||
10 | { |
||
11 | use UseDelegatedValidatorTrait; |
||
12 | |||
13 | /** |
||
14 | * Rule used to disable validations. |
||
15 | * |
||
16 | * @const string |
||
17 | */ |
||
18 | const JSVALIDATION_DISABLE = 'NoJsValidation'; |
||
19 | |||
20 | /** |
||
21 | * @var RuleParser |
||
22 | */ |
||
23 | protected $rules; |
||
24 | /** |
||
25 | * @var MessageParser |
||
26 | */ |
||
27 | protected $messages; |
||
28 | |||
29 | protected $conditional = []; |
||
30 | |||
31 | /** |
||
32 | * Create a new JsValidation instance. |
||
33 | * |
||
34 | * @param RuleParser $rules |
||
35 | * @param MessageParser $messages |
||
36 | */ |
||
37 | 7 | public function __construct(RuleParser $rules, MessageParser $messages) |
|
43 | |||
44 | /** |
||
45 | * Sets delegated Validator instance. |
||
46 | * |
||
47 | * @param \Proengsoft\JsValidation\Support\DelegatedValidator $validator |
||
48 | */ |
||
49 | 3 | public function setDelegatedValidator(DelegatedValidator $validator) |
|
55 | |||
56 | 3 | protected function generateJavascriptValidations($includeRemote = true) |
|
71 | |||
72 | /** |
||
73 | * Make Laravel Validations compatible with JQuery Validation Plugin. |
||
74 | * |
||
75 | * @param $attribute |
||
76 | * @param $rules |
||
77 | * @param bool $includeRemote |
||
78 | * |
||
79 | * @return array |
||
80 | */ |
||
81 | 2 | protected function jsConvertRules($attribute, $rules, $includeRemote) |
|
98 | |||
99 | /** |
||
100 | * Check if rule should be validated with javascript. |
||
101 | * |
||
102 | * @param $jsRule |
||
103 | * @param $includeRemote |
||
104 | * @return bool |
||
105 | */ |
||
106 | 2 | protected function isValidatable($jsRule, $includeRemote) |
|
110 | |||
111 | /** |
||
112 | * Check if JS Validation is disabled for attribute. |
||
113 | * |
||
114 | * @param $attribute |
||
115 | * |
||
116 | * @return bool |
||
117 | */ |
||
118 | 3 | public function jsValidationEnabled($attribute) |
|
122 | |||
123 | /** |
||
124 | * Returns view data to render javascript. |
||
125 | * |
||
126 | * @param bool $remote |
||
127 | * @return array |
||
128 | */ |
||
129 | 3 | public function validationData($remote = true) |
|
139 | |||
140 | /** |
||
141 | * Validate Conditional Validations using Ajax in specified fields. |
||
142 | * |
||
143 | * @param string $attribute |
||
144 | * @param string|array $rules |
||
145 | */ |
||
146 | public function sometimes($attribute, $rules = []) |
||
156 | |||
157 | /** |
||
158 | * Determine if rule is passed with sometimes. |
||
159 | * |
||
160 | * @param $attribute |
||
161 | * @param $rule |
||
162 | * @return bool |
||
163 | */ |
||
164 | 2 | protected function isConditionalRule($attribute, $rule) |
|
169 | } |
||
170 |