Make WordPress Core


Ignore:
Timestamp:
05/03/2020 07:18:40 PM (6 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-validation.php

    r47627 r47753  
    8484                $this->assertTrue( rest_validate_value_from_schema( '#FFF', $schema ) );
    8585                $this->assertWPError( rest_validate_value_from_schema( 'WordPress', $schema ) );
     86        }
     87
     88        /**
     89         * @ticket 50053
     90         */
     91        public function test_format_uuid() {
     92                $schema = array(
     93                        'type'   => 'string',
     94                        'format' => 'uuid',
     95                );
     96                $this->assertTrue( rest_validate_value_from_schema( '123e4567-e89b-12d3-a456-426655440000', $schema ) );
     97                $this->assertWPError( rest_validate_value_from_schema( '123e4567-e89b-12d3-a456-426655440000X', $schema ) );
     98                $this->assertWPError( rest_validate_value_from_schema( '123e4567-e89b-?2d3-a456-426655440000', $schema ) );
    8699        }
    87100
Note: See TracChangeset for help on using the changeset viewer.