diff --git a/src/wp-includes/rest-api.php b/src/wp-includes/rest-api.php index 8c252b4d1c..ad9bf62b2e 100644 --- a/src/wp-includes/rest-api.php +++ b/src/wp-includes/rest-api.php @@ -1068,18 +1068,18 @@ function rest_validate_value_from_schema( $value, $args, $param = '' ) { if ( isset( $args['minimum'] ) && ! isset( $args['maximum'] ) ) { if ( ! empty( $args['exclusiveMinimum'] ) && $value <= $args['minimum'] ) { /* translators: 1: parameter, 2: minimum number */ - return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be greater than %2$d (exclusive)' ), $param, $args['minimum'] ) ); + return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be greater than %2$d' ), $param, $args['minimum'] ) ); } elseif ( empty( $args['exclusiveMinimum'] ) && $value < $args['minimum'] ) { /* translators: 1: parameter, 2: minimum number */ - return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be greater than %2$d (inclusive)' ), $param, $args['minimum'] ) ); + return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be greater than or equal to %2$d' ), $param, $args['minimum'] ) ); } } elseif ( isset( $args['maximum'] ) && ! isset( $args['minimum'] ) ) { if ( ! empty( $args['exclusiveMaximum'] ) && $value >= $args['maximum'] ) { /* translators: 1: parameter, 2: maximum number */ - return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be less than %2$d (exclusive)' ), $param, $args['maximum'] ) ); + return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be less than %2$d' ), $param, $args['maximum'] ) ); } elseif ( empty( $args['exclusiveMaximum'] ) && $value > $args['maximum'] ) { /* translators: 1: parameter, 2: maximum number */ - return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be less than %2$d (inclusive)' ), $param, $args['maximum'] ) ); + return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be less than or equal to %2$d' ), $param, $args['maximum'] ) ); } } elseif ( isset( $args['maximum'] ) && isset( $args['minimum'] ) ) { if ( ! empty( $args['exclusiveMinimum'] ) && ! empty( $args['exclusiveMaximum'] ) ) { diff --git a/tests/phpunit/tests/rest-api/rest-categories-controller.php b/tests/phpunit/tests/rest-api/rest-categories-controller.php index ff24dbb960..fbf7d06018 100644 --- a/tests/phpunit/tests/rest-api/rest-categories-controller.php +++ b/tests/phpunit/tests/rest-api/rest-categories-controller.php @@ -186,7 +186,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); $data = $response->get_data(); $first_error = array_shift( $data['data']['params'] ); - $this->assertContains( 'page must be greater than 1 (inclusive)', $first_error ); + $this->assertContains( 'page must be greater than or equal to 1', $first_error ); } public function test_get_items_include_query() { diff --git a/tests/phpunit/tests/rest-api/rest-schema-validation.php b/tests/phpunit/tests/rest-api/rest-schema-validation.php index f504cb7ee1..82f58e58d8 100644 --- a/tests/phpunit/tests/rest-api/rest-schema-validation.php +++ b/tests/phpunit/tests/rest-api/rest-schema-validation.php @@ -19,6 +19,7 @@ class WP_Test_REST_Schema_Validation extends WP_UnitTestCase { ); $this->assertTrue( rest_validate_value_from_schema( 1, $schema ) ); $this->assertTrue( rest_validate_value_from_schema( 2, $schema ) ); + $this->assertWPError( rest_validate_value_from_schema( 0.9, $schema ) ); $this->assertWPError( rest_validate_value_from_schema( 3, $schema ) ); $this->assertWPError( rest_validate_value_from_schema( true, $schema ) ); } @@ -31,6 +32,7 @@ class WP_Test_REST_Schema_Validation extends WP_UnitTestCase { ); $this->assertTrue( rest_validate_value_from_schema( 1, $schema ) ); $this->assertTrue( rest_validate_value_from_schema( 2, $schema ) ); + $this->assertWPError( rest_validate_value_from_schema( 0, $schema ) ); $this->assertWPError( rest_validate_value_from_schema( 3, $schema ) ); $this->assertWPError( rest_validate_value_from_schema( 1.1, $schema ) ); }