mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-06 17:29:05 +00:00
REST API: Add support for the oneOf and anyOf keywords.
This allows for REST API routes to define more complex validation requirements as JSON Schema instead of procedural validation. The error code returned from `rest_validate_value_from_schema` for invalid parameter types has been changed from the generic `rest_invalid_param` to the more specific `rest_invalid_type`. Props yakimun, johnbillion, TimothyBlynJacobs. Fixes #51025. git-svn-id: https://develop.svn.wordpress.org/trunk@49246 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -128,6 +128,42 @@ class WP_REST_Test_Controller extends WP_REST_Controller {
|
||||
),
|
||||
'minProperties' => 1,
|
||||
'maxProperties' => 10,
|
||||
'anyOf' => array(
|
||||
array(
|
||||
'properties' => array(
|
||||
'object_id' => array(
|
||||
'type' => 'integer',
|
||||
'minimum' => 100,
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'properties' => array(
|
||||
'object_id' => array(
|
||||
'type' => 'integer',
|
||||
'maximum' => 100,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'oneOf' => array(
|
||||
array(
|
||||
'properties' => array(
|
||||
'object_id' => array(
|
||||
'type' => 'integer',
|
||||
'minimum' => 100,
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'properties' => array(
|
||||
'object_id' => array(
|
||||
'type' => 'integer',
|
||||
'maximum' => 100,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'ignored_prop' => 'ignored_prop',
|
||||
'context' => array( 'view' ),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user