| @@ 134-159 (lines=26) @@ | ||
| 131 | /** |
|
| 132 | * {@inheritdoc} |
|
| 133 | */ |
|
| 134 | public function validate( $value, $name = null, $options = null, $fields = null, $pod = null, $id = null, $params = null ) { |
|
| 135 | ||
| 136 | $errors = array(); |
|
| 137 | ||
| 138 | $check = $this->pre_save( $value, $id, $name, $options, $fields, $pod, $params ); |
|
| 139 | ||
| 140 | if ( is_array( $check ) ) { |
|
| 141 | $errors = $check; |
|
| 142 | } else { |
|
| 143 | if ( 0 < strlen( $value ) && '' === $check ) { |
|
| 144 | $label = pods_v( 'label', $options, ucwords( str_replace( '_', ' ', $name ) ) ); |
|
| 145 | ||
| 146 | if ( 1 === (int) pods_v( 'required', $options ) ) { |
|
| 147 | $errors[] = sprintf( __( '%s is required', 'pods' ), $label ); |
|
| 148 | } else { |
|
| 149 | $errors[] = sprintf( __( 'Invalid e-mail provided for %s', 'pods' ), $label ); |
|
| 150 | } |
|
| 151 | } |
|
| 152 | } |
|
| 153 | ||
| 154 | if ( ! empty( $errors ) ) { |
|
| 155 | return $errors; |
|
| 156 | } |
|
| 157 | ||
| 158 | return true; |
|
| 159 | } |
|
| 160 | ||
| 161 | /** |
|
| 162 | * {@inheritdoc} |
|
| @@ 151-176 (lines=26) @@ | ||
| 148 | /** |
|
| 149 | * {@inheritdoc} |
|
| 150 | */ |
|
| 151 | public function validate( $value, $name = null, $options = null, $fields = null, $pod = null, $id = null, $params = null ) { |
|
| 152 | ||
| 153 | $errors = array(); |
|
| 154 | ||
| 155 | $label = strip_tags( pods_v( 'label', $options, ucwords( str_replace( '_', ' ', $name ) ) ) ); |
|
| 156 | ||
| 157 | $check = $this->pre_save( $value, $id, $name, $options, $fields, $pod, $params ); |
|
| 158 | ||
| 159 | if ( is_array( $check ) ) { |
|
| 160 | $errors = $check; |
|
| 161 | } else { |
|
| 162 | if ( 0 < strlen( $value ) && '' === $check ) { |
|
| 163 | if ( 1 === (int) pods_v( 'required', $options ) ) { |
|
| 164 | $errors[] = sprintf( __( 'The %s field is required.', 'pods' ), $label ); |
|
| 165 | } else { |
|
| 166 | $errors[] = sprintf( __( 'Invalid phone number provided for the field %s.', 'pods' ), $label ); |
|
| 167 | } |
|
| 168 | } |
|
| 169 | } |
|
| 170 | ||
| 171 | if ( ! empty( $errors ) ) { |
|
| 172 | return $errors; |
|
| 173 | } |
|
| 174 | ||
| 175 | return true; |
|
| 176 | } |
|
| 177 | ||
| 178 | /** |
|
| 179 | * {@inheritdoc} |
|
| @@ 177-201 (lines=25) @@ | ||
| 174 | /** |
|
| 175 | * {@inheritdoc} |
|
| 176 | */ |
|
| 177 | public function validate( $value, $name = null, $options = null, $fields = null, $pod = null, $id = null, $params = null ) { |
|
| 178 | $errors = array(); |
|
| 179 | ||
| 180 | $label = strip_tags( pods_v( 'label', $options, ucwords( str_replace( '_', ' ', $name ) ) ) ); |
|
| 181 | ||
| 182 | $check = $this->pre_save( $value, $id, $name, $options, $fields, $pod, $params ); |
|
| 183 | ||
| 184 | if ( is_array( $check ) ) { |
|
| 185 | $errors = $check; |
|
| 186 | } else { |
|
| 187 | if ( 0 < strlen( $value ) && '' === $check ) { |
|
| 188 | if ( 1 === (int) pods_v( 'required', $options ) ) { |
|
| 189 | $errors[] = sprintf( __( 'The %s field is required.', 'pods' ), $label ); |
|
| 190 | } else { |
|
| 191 | $errors[] = sprintf( __( 'Invalid website provided for the field %s.', 'pods' ), $label ); |
|
| 192 | } |
|
| 193 | } |
|
| 194 | } |
|
| 195 | ||
| 196 | if ( ! empty( $errors ) ) { |
|
| 197 | return $errors; |
|
| 198 | } |
|
| 199 | ||
| 200 | return true; |
|
| 201 | } |
|
| 202 | ||
| 203 | /** |
|
| 204 | * {@inheritdoc} |
|