1 | <?php |
||
10 | class JavascriptValidator implements Arrayable |
||
11 | { |
||
12 | /** |
||
13 | * Registered validator instance. |
||
14 | * |
||
15 | * @var ValidatorHandler |
||
16 | */ |
||
17 | protected $validator; |
||
18 | |||
19 | /** |
||
20 | * Selector used in javascript generation. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $selector; |
||
25 | |||
26 | /** |
||
27 | * View that renders Javascript. |
||
28 | * |
||
29 | * @var |
||
30 | */ |
||
31 | protected $view; |
||
32 | |||
33 | /** |
||
34 | * Enable or disable remote validations. |
||
35 | * |
||
36 | * @var bool |
||
37 | */ |
||
38 | protected $remote; |
||
39 | |||
40 | /** |
||
41 | * 'ignore' option for jQuery Validation Plugin. |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | protected $ignore; |
||
46 | |||
47 | /** |
||
48 | * Constructor. |
||
49 | * |
||
50 | * @param ValidatorHandler $validator |
||
51 | 192 | * @param array $options |
|
52 | */ |
||
53 | 192 | public function __construct(ValidatorHandler $validator, $options = []) |
|
58 | |||
59 | /** |
||
60 | * Set default parameters. |
||
61 | * |
||
62 | * @param $options |
||
63 | 192 | * @return void |
|
64 | */ |
||
65 | 192 | protected function setDefaults($options) |
|
75 | |||
76 | /** |
||
77 | 48 | * Render the specified view with validator data. |
|
78 | * |
||
79 | 48 | * @param null|\Illuminate\Contracts\View\View|string $view |
|
80 | 48 | * @param null|string $selector |
|
81 | * @return string |
||
82 | 48 | */ |
|
83 | 36 | public function render($view = null, $selector = null) |
|
91 | 48 | ||
92 | /** |
||
93 | 48 | * Get the view data as an array. |
|
94 | * |
||
95 | * @return array |
||
96 | */ |
||
97 | public function toArray() |
||
101 | 24 | ||
102 | /** |
||
103 | * Get the string resulting of render default view. |
||
104 | 24 | * |
|
105 | 12 | * @return string |
|
106 | 12 | */ |
|
107 | public function __toString() |
||
115 | |||
116 | /** |
||
117 | * Gets value from view data. |
||
118 | 24 | * |
|
119 | * @param $name |
||
120 | 24 | * @return string |
|
121 | 24 | * |
|
122 | 12 | * @throws \Proengsoft\JsValidation\Exceptions\PropertyNotFoundException |
|
123 | */ |
||
124 | public function __get($name) |
||
133 | 120 | ||
134 | /** |
||
135 | 120 | * Gets view data. |
|
136 | 120 | * |
|
137 | 108 | * @return array |
|
138 | */ |
||
139 | 108 | protected function getViewData() |
|
151 | |||
152 | /** |
||
153 | * Set the form selector to validate. |
||
154 | * |
||
155 | * @param string $selector |
||
156 | * @deprecated |
||
157 | */ |
||
158 | public function setSelector($selector) |
||
162 | |||
163 | 48 | /** |
|
164 | * Set the form selector to validate. |
||
165 | 48 | * |
|
166 | * @param string $selector |
||
167 | 48 | * @return \Proengsoft\JsValidation\Javascript\JavascriptValidator |
|
168 | */ |
||
169 | public function selector($selector) |
||
175 | |||
176 | 12 | /** |
|
177 | * Set the input selector to ignore for validation. |
||
178 | 12 | * |
|
179 | * @param string $ignore |
||
180 | 12 | * @return \Proengsoft\JsValidation\Javascript\JavascriptValidator |
|
181 | */ |
||
182 | public function ignore($ignore) |
||
188 | |||
189 | 48 | /** |
|
190 | * Set the view to render Javascript Validations. |
||
191 | 48 | * |
|
192 | * @param null|\Illuminate\Contracts\View\View|string $view |
||
193 | 48 | * @return \Proengsoft\JsValidation\Javascript\JavascriptValidator |
|
194 | */ |
||
195 | public function view($view) |
||
201 | |||
202 | 12 | /** |
|
203 | * Enables or disables remote validations. |
||
204 | 12 | * |
|
205 | * @param null|bool $enabled |
||
206 | 12 | * @return \Proengsoft\JsValidation\Javascript\JavascriptValidator |
|
207 | */ |
||
208 | public function remote($enabled = true) |
||
214 | |||
215 | /** |
||
216 | * Validate Conditional Validations using Ajax in specified fields. |
||
217 | 12 | * |
|
218 | * @param string $attribute |
||
219 | 12 | * @param string|array $rules |
|
220 | * @param null $callback Dummy attribute to make API seamless with Laravel sometimes() |
||
221 | 12 | * @return \Proengsoft\JsValidation\Javascript\JavascriptValidator |
|
222 | */ |
||
223 | public function sometimes($attribute, $rules, $callback = null) |
||
229 | } |
||
230 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.