REST API: Support the JSON Schema pattern keyword.
Props jason_the_adams, birgire, sorenbronsted. Fixes #44949. Built from https://develop.svn.wordpress.org/trunk@47810 git-svn-id: http://core.svn.wordpress.org/trunk@47586 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
26bda18a23
commit
fe00d7f7bf
|
@ -1382,6 +1382,14 @@ function rest_validate_value_from_schema( $value, $args, $param = '' ) {
|
|||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( isset( $args['pattern'] ) ) {
|
||||
$pattern = str_replace( '#', '\\#', $args['pattern'] );
|
||||
if ( ! preg_match( '#' . $pattern . '#u', $value ) ) {
|
||||
/* translators: 1: Parameter, 2: Pattern. */
|
||||
return new WP_Error( 'rest_invalid_pattern', sprintf( __( '%1$s does not match pattern %2$s.' ), $param, $args['pattern'] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $args['format'] ) ) {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.5-alpha-47809';
|
||||
$wp_version = '5.5-alpha-47810';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue