Make WordPress Core


Ignore:
Timestamp:
03/12/2020 02:40:29 AM (5 years ago)
Author:
TimothyBlynJacobs
Message:

REST API: Introduce "hex-color" JSON Schema format.

Props spacedmonkey, chrisvanpatten.
Fixes #49270.

File:
1 edited

Legend:

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

    r47362 r47450  
    7171        $this->assertTrue( rest_validate_value_from_schema( 'a@b.co', $schema ) );
    7272        $this->assertWPError( rest_validate_value_from_schema( 'email', $schema ) );
     73    }
     74
     75    /**
     76     * @ticket 49270
     77     */
     78    public function test_format_hex_color() {
     79        $schema = array(
     80            'type'   => 'string',
     81            'format' => 'hex-color',
     82        );
     83        $this->assertTrue( rest_validate_value_from_schema( '#000000', $schema ) );
     84        $this->assertTrue( rest_validate_value_from_schema( '#FFF', $schema ) );
     85        $this->assertWPError( rest_validate_value_from_schema( 'WordPress', $schema ) );
    7386    }
    7487
Note: See TracChangeset for help on using the changeset viewer.