REST API: Include attribute name in schema validation error message.

Props bobbingwide.
Fixes #51231.


git-svn-id: https://develop.svn.wordpress.org/trunk@48969 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Helen Hou-Sandi 2020-09-10 16:32:52 +00:00
parent c0570b1398
commit b8e4f37a57
1 changed files with 2 additions and 2 deletions

View File

@ -209,7 +209,7 @@ class WP_Block_Type {
*/ */
public function prepare_attributes_for_render( $attributes ) { public function prepare_attributes_for_render( $attributes ) {
// If there are no attribute definitions for the block type, skip // If there are no attribute definitions for the block type, skip
// processing and return vebatim. // processing and return verbatim.
if ( ! isset( $this->attributes ) ) { if ( ! isset( $this->attributes ) ) {
return $attributes; return $attributes;
} }
@ -227,7 +227,7 @@ class WP_Block_Type {
// its default, if one exists. This occurs by virtue of the missing // its default, if one exists. This occurs by virtue of the missing
// attributes loop immediately following. If there is not a default // attributes loop immediately following. If there is not a default
// assigned, the attribute value should remain unset. // assigned, the attribute value should remain unset.
$is_valid = rest_validate_value_from_schema( $value, $schema ); $is_valid = rest_validate_value_from_schema( $value, $schema, $attribute_name );
if ( is_wp_error( $is_valid ) ) { if ( is_wp_error( $is_valid ) ) {
unset( $attributes[ $attribute_name ] ); unset( $attributes[ $attribute_name ] );
} }