1 | <?php |
||
5 | trait JavascriptRulesTrait |
||
6 | { |
||
7 | |||
8 | /** |
||
9 | * Handles multidimensional attribute names. |
||
10 | * |
||
11 | * @param string $attribute |
||
12 | * |
||
13 | * @return string |
||
14 | */ |
||
15 | abstract protected function getJsAttributeName($attribute); |
||
16 | |||
17 | |||
18 | /** |
||
19 | * Confirmed rule is applied to confirmed attribute. |
||
20 | * |
||
21 | * @param $attribute |
||
22 | * @param array $parameters |
||
23 | * |
||
24 | * @return array |
||
25 | */ |
||
26 | protected function jsRuleConfirmed($attribute, array $parameters) |
||
33 | |||
34 | /** |
||
35 | * Returns Javascript parameters for After rule. |
||
36 | * |
||
37 | * @param $attribute |
||
38 | * @param array $parameters |
||
39 | * |
||
40 | * @return array |
||
41 | */ |
||
42 | protected function jsRuleAfter($attribute, array $parameters) |
||
51 | |||
52 | /** |
||
53 | * Returns Javascript parameters for Before rule. |
||
54 | * |
||
55 | * @param $attribute |
||
56 | * @param array $parameters |
||
57 | * |
||
58 | * @return array |
||
59 | */ |
||
60 | protected function jsRuleBefore($attribute, array $parameters) |
||
64 | |||
65 | /** |
||
66 | * Validate that two attributes match. |
||
67 | * |
||
68 | * @param string $attribute |
||
69 | * @param array $parameters |
||
70 | * |
||
71 | * @return array |
||
72 | */ |
||
73 | protected function jsRuleSame($attribute, array $parameters) |
||
79 | |||
80 | /** |
||
81 | * Validate that an attribute is different from another attribute. |
||
82 | * |
||
83 | * @param string $attribute |
||
84 | * @param array $parameters |
||
85 | * |
||
86 | * @return array |
||
87 | */ |
||
88 | protected function jsRuleDifferent($attribute, array $parameters) |
||
92 | |||
93 | /** |
||
94 | * Validate that an attribute exists when any other attribute exists. |
||
95 | * |
||
96 | * @param string $attribute |
||
97 | * @param mixed $parameters |
||
98 | * |
||
99 | * @return array |
||
100 | */ |
||
101 | protected function jsRuleRequiredWith($attribute, array $parameters) |
||
107 | |||
108 | /** |
||
109 | * Validate that an attribute exists when all other attributes exists. |
||
110 | * |
||
111 | * @param string $attribute |
||
112 | * @param mixed $parameters |
||
113 | * |
||
114 | * @return array |
||
115 | */ |
||
116 | protected function jsRuleRequiredWithAll($attribute, array $parameters) |
||
120 | |||
121 | /** |
||
122 | * Validate that an attribute exists when another attribute does not. |
||
123 | * |
||
124 | * @param string $attribute |
||
125 | * @param mixed $parameters |
||
126 | * |
||
127 | * @return array |
||
128 | */ |
||
129 | protected function jsRuleRequiredWithout($attribute, array $parameters) |
||
133 | |||
134 | /** |
||
135 | * Validate that an attribute exists when all other attributes do not. |
||
136 | * |
||
137 | * @param string $attribute |
||
138 | * @param mixed $parameters |
||
139 | * |
||
140 | * @return array |
||
141 | */ |
||
142 | protected function jsRuleRequiredWithoutAll($attribute, array $parameters) |
||
146 | |||
147 | /** |
||
148 | * Validate that an attribute exists when another attribute has a given value. |
||
149 | * |
||
150 | * @param string $attribute |
||
151 | * @param mixed $parameters |
||
152 | * |
||
153 | * @return array |
||
154 | */ |
||
155 | protected function jsRuleRequiredIf($attribute, array $parameters) |
||
161 | |||
162 | |||
163 | } |
||
164 |