| @@ 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 |
|
| @@ 216-238 (lines=23) @@ | ||
| 213 | * |
|
| 214 | * @since 2.0 |
|
| 215 | */ |
|
| 216 | public function validate ( $value, $name = null, $options = null, $fields = null, $pod = null, $id = null, $params = null ) { |
|
| 217 | $errors = array(); |
|
| 218 | ||
| 219 | $label = strip_tags( pods_var_raw( 'label', $options, ucwords( str_replace( '_', ' ', $name ) ) ) ); |
|
| 220 | ||
| 221 | $check = $this->pre_save( $value, $id, $name, $options, $fields, $pod, $params ); |
|
| 222 | ||
| 223 | if ( is_array( $check ) ) |
|
| 224 | $errors = $check; |
|
| 225 | else { |
|
| 226 | if ( 0 < strlen( $value ) && strlen( $check ) < 1 ) { |
|
| 227 | if ( 1 == pods_var( 'required', $options ) ) |
|
| 228 | $errors[] = sprintf( __( 'The %s field is required.', 'pods' ), $label ); |
|
| 229 | else |
|
| 230 | $errors[] = sprintf( __( 'Invalid website provided for the field %s.', 'pods' ), $label ); |
|
| 231 | } |
|
| 232 | } |
|
| 233 | ||
| 234 | if ( !empty( $errors ) ) |
|
| 235 | return $errors; |
|
| 236 | ||
| 237 | return true; |
|
| 238 | } |
|
| 239 | ||
| 240 | /** |
|
| 241 | * Change the value or perform actions after validation but before saving to the DB |
|