rest_find_any_matching_schema()
Finds the matching schema among the "anyOf" schemas.
Хуков нет.
Возвращает
Массив|WP_Error. The matching schema or WP_Error instance if all schemas do not match.
Использование
rest_find_any_matching_schema( $value, $args, $param );
- $value(разное) (обязательный)
- The value to validate.
- $args(массив) (обязательный)
- The schema array to use.
- $param(строка) (обязательный)
- The parameter name, used in error messages.
Список изменений
| С версии 5.6.0 | Введена. |
Код rest_find_any_matching_schema() rest find any matching schema WP 7.0
function rest_find_any_matching_schema( $value, $args, $param ) {
$errors = array();
foreach ( $args['anyOf'] as $index => $schema ) {
if ( ! isset( $schema['type'] ) && isset( $args['type'] ) ) {
$schema['type'] = $args['type'];
}
$is_valid = rest_validate_value_from_schema( $value, $schema, $param );
if ( ! is_wp_error( $is_valid ) ) {
return $schema;
}
$errors[] = array(
'error_object' => $is_valid,
'schema' => $schema,
'index' => $index,
);
}
return rest_get_combining_operation_error( $value, $param, $errors );
}