1 | <?php |
||
5 | trait JavascriptRulesTrait |
||
6 | { |
||
7 | /** |
||
8 | * Handles multidimensional attribute names. |
||
9 | * |
||
10 | * @param string $attribute |
||
11 | * |
||
12 | * @return string |
||
13 | */ |
||
14 | abstract protected function getAttributeName($attribute); |
||
15 | |||
16 | /** |
||
17 | * Parse named parameters to $key => $value items. |
||
18 | * |
||
19 | * @param array $parameters |
||
20 | * @return array |
||
21 | */ |
||
22 | abstract public function parseNamedParameters($parameters); |
||
23 | |||
24 | /** |
||
25 | * Confirmed rule is applied to confirmed attribute. |
||
26 | * |
||
27 | * @param $attribute |
||
28 | * @param array $parameters |
||
29 | * |
||
30 | * @return array |
||
31 | */ |
||
32 | 1 | protected function ruleConfirmed($attribute, array $parameters) |
|
39 | |||
40 | /** |
||
41 | * Returns Javascript parameters for After rule. |
||
42 | * |
||
43 | * @param $attribute |
||
44 | * @param array $parameters |
||
45 | * |
||
46 | * @return array |
||
47 | */ |
||
48 | 4 | protected function ruleAfter($attribute, array $parameters) |
|
56 | |||
57 | /** |
||
58 | * Returns Javascript parameters for Before rule. |
||
59 | * |
||
60 | * @param $attribute |
||
61 | * @param array $parameters |
||
62 | * |
||
63 | * @return array |
||
64 | */ |
||
65 | 2 | protected function ruleBefore($attribute, array $parameters) |
|
69 | |||
70 | /** |
||
71 | * Validate that two attributes match. |
||
72 | * |
||
73 | * @param string $attribute |
||
74 | * @param array $parameters |
||
75 | * |
||
76 | * @return array |
||
77 | */ |
||
78 | 2 | protected function ruleSame($attribute, array $parameters) |
|
84 | |||
85 | /** |
||
86 | * Validate that an attribute is different from another attribute. |
||
87 | * |
||
88 | * @param string $attribute |
||
89 | * @param array $parameters |
||
90 | * |
||
91 | * @return array |
||
92 | */ |
||
93 | 1 | protected function ruleDifferent($attribute, array $parameters) |
|
97 | |||
98 | /** |
||
99 | * Validate that an attribute exists when any other attribute exists. |
||
100 | * |
||
101 | * @param string $attribute |
||
102 | * @param mixed $parameters |
||
103 | * |
||
104 | * @return array |
||
105 | */ |
||
106 | 4 | protected function ruleRequiredWith($attribute, array $parameters) |
|
112 | |||
113 | /** |
||
114 | * Validate that an attribute exists when all other attributes exists. |
||
115 | * |
||
116 | * @param string $attribute |
||
117 | * @param mixed $parameters |
||
118 | * |
||
119 | * @return array |
||
120 | */ |
||
121 | 1 | protected function ruleRequiredWithAll($attribute, array $parameters) |
|
125 | |||
126 | /** |
||
127 | * Validate that an attribute exists when another attribute does not. |
||
128 | * |
||
129 | * @param string $attribute |
||
130 | * @param mixed $parameters |
||
131 | * |
||
132 | * @return array |
||
133 | */ |
||
134 | 1 | protected function ruleRequiredWithout($attribute, array $parameters) |
|
138 | |||
139 | /** |
||
140 | * Validate that an attribute exists when all other attributes do not. |
||
141 | * |
||
142 | * @param string $attribute |
||
143 | * @param mixed $parameters |
||
144 | * |
||
145 | * @return array |
||
146 | */ |
||
147 | 1 | protected function ruleRequiredWithoutAll($attribute, array $parameters) |
|
151 | |||
152 | /** |
||
153 | * Validate that an attribute exists when another attribute has a given value. |
||
154 | * |
||
155 | * @param string $attribute |
||
156 | * @param mixed $parameters |
||
157 | * |
||
158 | * @return array |
||
159 | */ |
||
160 | 3 | protected function ruleRequiredIf($attribute, array $parameters) |
|
166 | |||
167 | /** |
||
168 | * Validate that an attribute exists when another attribute does not have a given value. |
||
169 | * |
||
170 | * @param string $attribute |
||
171 | * @param mixed $parameters |
||
172 | * |
||
173 | * @return array |
||
174 | */ |
||
175 | 1 | protected function ruleRequiredUnless($attribute, array $parameters) |
|
179 | |||
180 | /** |
||
181 | * Validate the dimensions of an image matches the given values. |
||
182 | * |
||
183 | * @param string $attribute |
||
184 | * @param array $parameters |
||
185 | * |
||
186 | * @return array |
||
187 | */ |
||
188 | 1 | protected function ruleDimensions($attribute, $parameters) |
|
194 | } |
||
195 |