mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
REST API: Support the uuid JSON Schema format.
This accepts a uuid of any version. A future commit could add support for restricting uuids to a specific version. Props johnwatkins0. Fixes #50053. git-svn-id: https://develop.svn.wordpress.org/trunk@47753 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1393,6 +1393,12 @@ function rest_validate_value_from_schema( $value, $args, $param = '' ) {
|
||||
return new WP_Error( 'rest_invalid_param', sprintf( __( '%s is not a valid IP address.' ), $param ) );
|
||||
}
|
||||
break;
|
||||
case 'uuid':
|
||||
if ( ! wp_is_uuid( $value ) ) {
|
||||
/* translators: %s is the name of a JSON field expecting a valid uuid. */
|
||||
return new WP_Error( 'rest_invalid_uuid', sprintf( __( '%s is not a valid UUID.' ), $param ) );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1549,6 +1555,9 @@ function rest_sanitize_value_from_schema( $value, $args ) {
|
||||
|
||||
case 'ip':
|
||||
return sanitize_text_field( $value );
|
||||
|
||||
case 'uuid':
|
||||
return sanitize_text_field( $value );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user