1 | <?php |
||
10 | trait ValidateTrait |
||
11 | { |
||
12 | /** |
||
13 | * Validation types. |
||
14 | * |
||
15 | * @var array |
||
16 | */ |
||
17 | protected $validationTypes = ['rules', 'messages']; |
||
18 | |||
19 | /** |
||
20 | * Custom validation options for messages and rules used for validation. |
||
21 | * |
||
22 | * @var array |
||
23 | */ |
||
24 | protected $validationOptions = []; |
||
25 | |||
26 | /** |
||
27 | * Check validation types. |
||
28 | * |
||
29 | * @param string $type |
||
30 | * |
||
31 | * @throws ValidateException |
||
32 | */ |
||
33 | 28 | protected function checkValidationTypes($type) |
|
39 | |||
40 | /** |
||
41 | * Add validation option. |
||
42 | * |
||
43 | * @param string $type |
||
44 | * @param string $key |
||
45 | * @param string $value |
||
46 | * |
||
47 | * @throws ValidateException |
||
48 | * |
||
49 | * @return array |
||
50 | */ |
||
51 | 20 | protected function addValidationOption($type, $key, $value) |
|
59 | |||
60 | /** |
||
61 | * Remove validation option. |
||
62 | * |
||
63 | * @param string $type |
||
64 | * @param string $key |
||
65 | * |
||
66 | * @throws ValidateException |
||
67 | * |
||
68 | * @return array |
||
69 | */ |
||
70 | 6 | protected function removeValidationOption($type, $key) |
|
78 | |||
79 | /** |
||
80 | * Get validation options by type. |
||
81 | * |
||
82 | * @param string $type |
||
83 | * |
||
84 | * @throws ValidateException |
||
85 | * |
||
86 | * @return mixed |
||
87 | */ |
||
88 | 24 | protected function getValidationOptions($type) |
|
94 | |||
95 | /** |
||
96 | * Validate the form data. |
||
97 | * |
||
98 | * @param array $data An array of data to validate against the rules. |
||
99 | * @param null|string $message Message to be thrown with the custom exception. |
||
100 | * |
||
101 | * @throws ValidateException |
||
102 | * |
||
103 | * @return boolean |
||
104 | */ |
||
105 | 14 | protected function validate(array $data = [], $message = null) |
|
123 | } |
||
124 |