@@ 292-296 (lines=5) @@ | ||
289 | } |
|
290 | $args = $attributes['args'][ $param ]; |
|
291 | ||
292 | if ( ! empty( $args['enum'] ) ) { |
|
293 | if ( ! in_array( $value, $args['enum'] ) ) { |
|
294 | return new WP_Error( 'rest_invalid_param', sprintf( __( '%s is not one of %s' ), $param, implode( ', ', $args['enum'] ) ) ); |
|
295 | } |
|
296 | } |
|
297 | ||
298 | if ( 'integer' === $args['type'] && ! is_numeric( $value ) ) { |
|
299 | return new WP_Error( 'rest_invalid_param', sprintf( __( '%s is not of type %s' ), $param, 'integer' ) ); |
|
@@ 298-300 (lines=3) @@ | ||
295 | } |
|
296 | } |
|
297 | ||
298 | if ( 'integer' === $args['type'] && ! is_numeric( $value ) ) { |
|
299 | return new WP_Error( 'rest_invalid_param', sprintf( __( '%s is not of type %s' ), $param, 'integer' ) ); |
|
300 | } |
|
301 | ||
302 | if ( 'boolean' === $args['type'] && ! rest_is_boolean( $value ) ) { |
|
303 | return new WP_Error( 'rest_invalid_param', sprintf( __( '%s is not of type %s' ), $value, 'boolean' ) ); |
|
@@ 306-308 (lines=3) @@ | ||
303 | return new WP_Error( 'rest_invalid_param', sprintf( __( '%s is not of type %s' ), $value, 'boolean' ) ); |
|
304 | } |
|
305 | ||
306 | if ( 'string' === $args['type'] && ! is_string( $value ) ) { |
|
307 | return new WP_Error( 'rest_invalid_param', sprintf( __( '%s is not of type %s' ), $param, 'string' ) ); |
|
308 | } |
|
309 | ||
310 | if ( isset( $args['format'] ) ) { |
|
311 | switch ( $args['format'] ) { |
|
@@ 302-304 (lines=3) @@ | ||
299 | return new WP_Error( 'rest_invalid_param', sprintf( __( '%s is not of type %s' ), $param, 'integer' ) ); |
|
300 | } |
|
301 | ||
302 | if ( 'boolean' === $args['type'] && ! rest_is_boolean( $value ) ) { |
|
303 | return new WP_Error( 'rest_invalid_param', sprintf( __( '%s is not of type %s' ), $value, 'boolean' ) ); |
|
304 | } |
|
305 | ||
306 | if ( 'string' === $args['type'] && ! is_string( $value ) ) { |
|
307 | return new WP_Error( 'rest_invalid_param', sprintf( __( '%s is not of type %s' ), $param, 'string' ) ); |