@@ 178-200 (lines=23) @@ | ||
175 | * @return array|bool |
|
176 | * @since 2.0 |
|
177 | */ |
|
178 | public function validate ( $value, $name = null, $options = null, $fields = null, $pod = null, $id = null, $params = null ) { |
|
179 | $errors = array(); |
|
180 | ||
181 | $check = $this->pre_save( $value, $id, $name, $options, $fields, $pod, $params ); |
|
182 | ||
183 | if ( is_array( $check ) ) |
|
184 | $errors = $check; |
|
185 | else { |
|
186 | if ( 0 < strlen( $value ) && strlen( $check ) < 1 ) { |
|
187 | $label = pods_var( 'label', $options, ucwords( str_replace( '_', ' ', $name ) ) ); |
|
188 | ||
189 | if ( 1 == pods_var( 'required', $options ) ) |
|
190 | $errors[] = sprintf( __( '%s is required', 'pods' ), $label ); |
|
191 | else |
|
192 | $errors[] = sprintf( __( 'Invalid e-mail provided for %s', 'pods' ), $label ); |
|
193 | } |
|
194 | } |
|
195 | ||
196 | if ( !empty( $errors ) ) |
|
197 | return $errors; |
|
198 | ||
199 | return true; |
|
200 | } |
|
201 | ||
202 | /** |
|
203 | * Change the value or perform actions after validation but before saving to the DB |
@@ 185-207 (lines=23) @@ | ||
182 | * |
|
183 | * @since 2.0 |
|
184 | */ |
|
185 | public function validate ( $value, $name = null, $options = null, $fields = null, $pod = null, $id = null, $params = null ) { |
|
186 | $errors = array(); |
|
187 | ||
188 | $label = strip_tags( pods_var_raw( 'label', $options, ucwords( str_replace( '_', ' ', $name ) ) ) ); |
|
189 | ||
190 | $check = $this->pre_save( $value, $id, $name, $options, $fields, $pod, $params ); |
|
191 | ||
192 | if ( is_array( $check ) ) |
|
193 | $errors = $check; |
|
194 | else { |
|
195 | if ( 0 < strlen( $value ) && strlen( $check ) < 1 ) { |
|
196 | if ( 1 == pods_var( 'required', $options ) ) |
|
197 | $errors[] = sprintf( __( 'The %s field is required.', 'pods' ), $label ); |
|
198 | else |
|
199 | $errors[] = sprintf( __( 'Invalid phone number provided for the field %s.', 'pods' ), $label ); |
|
200 | } |
|
201 | } |
|
202 | ||
203 | if ( !empty( $errors ) ) |
|
204 | return $errors; |
|
205 | ||
206 | return true; |
|
207 | } |
|
208 | ||
209 | /** |
|
210 | * Change the value or perform actions after validation but before saving to the DB |
@@ 218-240 (lines=23) @@ | ||
215 | * |
|
216 | * @since 2.0 |
|
217 | */ |
|
218 | public function validate ( $value, $name = null, $options = null, $fields = null, $pod = null, $id = null, $params = null ) { |
|
219 | $errors = array(); |
|
220 | ||
221 | $label = strip_tags( pods_var_raw( 'label', $options, ucwords( str_replace( '_', ' ', $name ) ) ) ); |
|
222 | ||
223 | $check = $this->pre_save( $value, $id, $name, $options, $fields, $pod, $params ); |
|
224 | ||
225 | if ( is_array( $check ) ) |
|
226 | $errors = $check; |
|
227 | else { |
|
228 | if ( 0 < strlen( $value ) && strlen( $check ) < 1 ) { |
|
229 | if ( 1 == pods_var( 'required', $options ) ) |
|
230 | $errors[] = sprintf( __( 'The %s field is required.', 'pods' ), $label ); |
|
231 | else |
|
232 | $errors[] = sprintf( __( 'Invalid website provided for the field %s.', 'pods' ), $label ); |
|
233 | } |
|
234 | } |
|
235 | ||
236 | if ( !empty( $errors ) ) |
|
237 | return $errors; |
|
238 | ||
239 | return true; |
|
240 | } |
|
241 | ||
242 | /** |
|
243 | * Change the value or perform actions after validation but before saving to the DB |