diff --git a/src/wp-includes/rest-api.php b/src/wp-includes/rest-api.php
index 9a615419b9..cc326eb0da 100644
a
|
b
|
function rest_validate_value_from_schema( $value, $args, $param = '' ) { |
2151 | 2151 | break; |
2152 | 2152 | |
2153 | 2153 | case 'date-time': |
2154 | | if ( ! rest_parse_date( $value ) ) { |
| 2154 | if ( false === rest_parse_date( $value ) ) { |
2155 | 2155 | return new WP_Error( 'rest_invalid_date', __( 'Invalid date.' ) ); |
2156 | 2156 | } |
2157 | 2157 | break; |
diff --git a/tests/phpunit/tests/rest-api/rest-schema-validation.php b/tests/phpunit/tests/rest-api/rest-schema-validation.php
index 2fab13fe0a..b3c87a902a 100644
a
|
b
|
class WP_Test_REST_Schema_Validation extends WP_UnitTestCase { |
103 | 103 | 'type' => 'string', |
104 | 104 | 'format' => 'date-time', |
105 | 105 | ); |
| 106 | $this->assertTrue( rest_validate_value_from_schema( '1970-01-01T00:00:00', $schema ) ); |
| 107 | $this->assertTrue( rest_validate_value_from_schema( '1970-01-01T00:00:00Z', $schema ) ); |
106 | 108 | $this->assertTrue( rest_validate_value_from_schema( '2016-06-30T05:43:21', $schema ) ); |
107 | 109 | $this->assertTrue( rest_validate_value_from_schema( '2016-06-30T05:43:21Z', $schema ) ); |
108 | 110 | $this->assertTrue( rest_validate_value_from_schema( '2016-06-30T05:43:21+00:00', $schema ) ); |
| 111 | $this->assertWPError( rest_validate_value_from_schema( '19700101T000000Z', $schema ) ); |
109 | 112 | $this->assertWPError( rest_validate_value_from_schema( '20161027T163355Z', $schema ) ); |
110 | 113 | $this->assertWPError( rest_validate_value_from_schema( '2016', $schema ) ); |
111 | 114 | $this->assertWPError( rest_validate_value_from_schema( '2016-06-30', $schema ) ); |