REST API: Add text-field and textarea-field as available schema formats for string sanitization.

Props ocean90, TimothyBlynJacobs.
Fixes #49960.

git-svn-id: https://develop.svn.wordpress.org/trunk@51908 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Rachel Baker
2021-10-15 02:03:38 +00:00
parent dc54ceabd8
commit 66ed91d214
3 changed files with 98 additions and 21 deletions

View File

@@ -36,7 +36,7 @@ class WP_REST_Test_Controller extends WP_REST_Controller {
'title' => 'type',
'type' => 'object',
'properties' => array(
'somestring' => array(
'somestring' => array(
'type' => 'string',
'description' => 'A pretty string.',
'minLength' => 3,
@@ -44,7 +44,7 @@ class WP_REST_Test_Controller extends WP_REST_Controller {
'pattern' => '[a-zA-Z]+',
'context' => array( 'view' ),
),
'someinteger' => array(
'someinteger' => array(
'type' => 'integer',
'multipleOf' => 10,
'minimum' => 100,
@@ -53,41 +53,51 @@ class WP_REST_Test_Controller extends WP_REST_Controller {
'exclusiveMaximum' => true,
'context' => array( 'view' ),
),
'someboolean' => array(
'someboolean' => array(
'type' => 'boolean',
'context' => array( 'view' ),
),
'someurl' => array(
'someurl' => array(
'type' => 'string',
'format' => 'uri',
'context' => array( 'view' ),
),
'somedate' => array(
'somedate' => array(
'type' => 'string',
'format' => 'date-time',
'context' => array( 'view' ),
),
'someemail' => array(
'someemail' => array(
'type' => 'string',
'format' => 'email',
'context' => array( 'view' ),
),
'somehex' => array(
'somehex' => array(
'type' => 'string',
'format' => 'hex-color',
'context' => array( 'view' ),
),
'someuuid' => array(
'someuuid' => array(
'type' => 'string',
'format' => 'uuid',
'context' => array( 'view' ),
),
'someenum' => array(
'sometextfield' => array(
'type' => 'string',
'format' => 'text-field',
'context' => array( 'view' ),
),
'sometextareafield' => array(
'type' => 'string',
'format' => 'textarea-field',
'context' => array( 'view' ),
),
'someenum' => array(
'type' => 'string',
'enum' => array( 'a', 'b', 'c' ),
'context' => array( 'view' ),
),
'someargoptions' => array(
'someargoptions' => array(
'type' => 'integer',
'required' => true,
'arg_options' => array(
@@ -95,13 +105,13 @@ class WP_REST_Test_Controller extends WP_REST_Controller {
'sanitize_callback' => '__return_true',
),
),
'somedefault' => array(
'somedefault' => array(
'type' => 'string',
'enum' => array( 'a', 'b', 'c' ),
'context' => array( 'view' ),
'default' => 'a',
),
'somearray' => array(
'somearray' => array(
'type' => 'array',
'items' => array(
'type' => 'string',
@@ -111,7 +121,7 @@ class WP_REST_Test_Controller extends WP_REST_Controller {
'uniqueItems' => true,
'context' => array( 'view' ),
),
'someobject' => array(
'someobject' => array(
'type' => 'object',
'additionalProperties' => array(
'type' => 'string',