1 | <?php |
||
18 | class ValidateSpec extends Spec |
||
19 | { |
||
20 | /** |
||
21 | * |
||
22 | * Reverse the rule, so that a "pass" is treated as a "fail". |
||
23 | * |
||
24 | * @var bool |
||
25 | * |
||
26 | */ |
||
27 | protected $reverse = false; |
||
28 | |||
29 | /** |
||
30 | * Skip checking whether field value is blank |
||
31 | * |
||
32 | * @var boolean |
||
33 | */ |
||
34 | protected $skip_blank = false; |
||
35 | |||
36 | /** |
||
37 | * |
||
38 | * Applies the rule specification to a subject. |
||
39 | * |
||
40 | * @param mixed $subject The filter subject. |
||
41 | * |
||
42 | * @return bool True on success, false on failure. |
||
43 | * |
||
44 | */ |
||
45 | 14 | public function __invoke($subject) |
|
61 | |||
62 | /** |
||
63 | * |
||
64 | * Validate the field matches this rule (blank not allowed). |
||
65 | * |
||
66 | * @param string $rule The rule name. |
||
67 | * |
||
68 | * @param ...$args Arguments for the rule. |
||
69 | * |
||
70 | * @return self |
||
71 | * |
||
72 | */ |
||
73 | 10 | public function is($rule) |
|
79 | |||
80 | /** |
||
81 | * |
||
82 | * Validate the field is blank. |
||
83 | * |
||
84 | * @return self |
||
85 | * |
||
86 | */ |
||
87 | 1 | public function isBlank() |
|
93 | |||
94 | /** |
||
95 | * |
||
96 | * Validate the field matches this rule (blank allowed). |
||
97 | * |
||
98 | * @param string $rule The rule name. |
||
99 | * |
||
100 | * @param ...$args Arguments for the rule. |
||
101 | * |
||
102 | * @return self |
||
103 | * |
||
104 | */ |
||
105 | 1 | public function isBlankOr($rule) |
|
111 | |||
112 | /** |
||
113 | * |
||
114 | * Validate the field does not match this rule (blank not allowed). |
||
115 | * |
||
116 | * @param string $rule The rule name. |
||
117 | * |
||
118 | * @param ...$args Arguments for the rule. |
||
119 | * |
||
120 | * @return self |
||
121 | * |
||
122 | */ |
||
123 | 2 | public function isNot($rule) |
|
129 | |||
130 | /** |
||
131 | * |
||
132 | * Validate the field is not blank. |
||
133 | * |
||
134 | * @return self |
||
135 | * |
||
136 | */ |
||
137 | 2 | public function isNotBlank() |
|
143 | |||
144 | /** |
||
145 | * |
||
146 | * Validate the field does not match this rule (blank allowed). |
||
147 | * |
||
148 | * @param string $rule The rule name. |
||
149 | * |
||
150 | * @param ...$args Arguments for the rule. |
||
151 | * |
||
152 | * @return self |
||
153 | * |
||
154 | */ |
||
155 | 1 | public function isBlankOrNot($rule) |
|
161 | |||
162 | /** |
||
163 | * |
||
164 | * Returns the default failure message for this rule specification. |
||
165 | * |
||
166 | * @return string |
||
167 | * |
||
168 | */ |
||
169 | 13 | protected function getDefaultMessage() |
|
189 | |||
190 | /** |
||
191 | * Skip checking whether field is blank |
||
192 | * |
||
193 | * @return self |
||
194 | */ |
||
195 | 1 | public function skipBlankRule() |
|
200 | } |
||
201 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.