acf_field_file::validate_value
validate_value
This function will validate a basic file input
Method of the class: acf_field_file{}
No Hooks.
Returns
$post_id. (int)
Usage
$acf_field_file = new acf_field_file(); $acf_field_file->validate_value( $valid, $value, $field, $input );
- $valid(required)
- .
- $value(required)
- .
- $field(required)
- .
- $input(required)
- .
Changelog
| Since 5.0.0 | Introduced. |
acf_field_file::validate_value() acf field file::validate value code ACF 6.8.8
function validate_value( $valid, $value, $field, $input ) {
// bail early if empty
if ( empty( $value ) ) {
return $valid;
}
// bail early if is numeric
if ( is_numeric( $value ) ) {
return $valid;
}
// bail early if not basic string
if ( ! is_string( $value ) ) {
return $valid;
}
// decode value
$file = null;
parse_str( $value, $file );
// bail early if no attachment
if ( empty( $file ) ) {
return $valid;
}
// get errors
$errors = acf_validate_attachment( $file, $field, 'basic_upload' );
// append error
if ( ! empty( $errors ) ) {
$valid = implode( "\n", $errors );
}
// return
return $valid;
}