acf_field_text::validate_value
validate_value
Validates a field's value.
Method of the class: acf_field_text{}
No Hooks.
Returns
(true|false|String).
Usage
$acf_field_text = new acf_field_text(); $acf_field_text->validate_value( $valid, $value, $field, $input );
- $valid(required)
- .
- $value(mixed) (required)
- The field value.
- $field(array) (required)
- The field array.
- $input(string) (required)
- The HTML input name.
Changelog
| Since 5.7.11 | Introduced. |
acf_field_text::validate_value() acf field text::validate value code ACF 6.0.4
function validate_value( $valid, $value, $field, $input ) {
// Check maxlength
if ( $field['maxlength'] && ( acf_strlen( $value ) > $field['maxlength'] ) ) {
return sprintf( __( 'Value must not exceed %d characters', 'acf' ), $field['maxlength'] );
}
// Return.
return $valid;
}