acf_field_gallery::validate_rest_valuepublicACF 1.0

Validates file fields updated via the REST API.

Method of the class: acf_field_gallery{}

No Hooks.

Returns

boolean|WP.

Usage

$acf_field_gallery = new acf_field_gallery();
$acf_field_gallery->validate_rest_value( $valid, $value, $field );
$valid(true|false) (required)
The current validity booleean.
$value(int) (required)
The value of the field.
$field(array) (required)
The field array.

acf_field_gallery::validate_rest_value() code ACF 6.8.8

public function validate_rest_value( $valid, $value, $field ) {
	if ( ! $valid || ! is_array( $value ) ) {
		return $valid;
	}

	foreach ( $value as $attachment_id ) {
		$file_valid = acf_get_field_type( 'file' )->validate_rest_value( $valid, $attachment_id, $field );

		if ( is_wp_error( $file_valid ) ) {
			return $file_valid;
		}
	}

	return $valid;
}