Make WordPress Core


Ignore:
Timestamp:
05/03/2020 07:18:40 PM (5 years ago)
Author:
TimothyBlynJacobs
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-schema-sanitization.php

    r47450 r47753  
    9191    }
    9292
     93    /**
     94     * @ticket 50053
     95     */
     96    public function test_format_uuid() {
     97        $schema = array(
     98            'type'   => 'string',
     99            'format' => 'uuid',
     100        );
     101        $this->assertEquals( '44', rest_sanitize_value_from_schema( 44, $schema ) );
     102        $this->assertEquals( 'hello', rest_sanitize_value_from_schema( 'hello', $schema ) );
     103        $this->assertEquals(
     104            '123e4567-e89b-12d3-a456-426655440000',
     105            rest_sanitize_value_from_schema( '123e4567-e89b-12d3-a456-426655440000', $schema )
     106        );
     107    }
     108
    93109    public function test_type_array() {
    94110        $schema = array(
Note: See TracChangeset for help on using the changeset viewer.