Changeset 50007
- Timestamp:
- 01/24/2021 03:57:39 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api.php
r50005 r50007 1682 1682 1683 1683 return new WP_Error( 1684 'rest_ invalid_param',1684 'rest_no_matching_schema', 1685 1685 /* translators: 1: Parameter, 2: Schema title, 3: Reason. */ 1686 1686 sprintf( __( '%1$s is not a valid %2$s. Reason: %3$s' ), $param, $title, $reason ), … … 1690 1690 1691 1691 return new WP_Error( 1692 'rest_ invalid_param',1692 'rest_no_matching_schema', 1693 1693 /* translators: 1: Parameter, 2: Reason. */ 1694 1694 sprintf( __( '%1$s does not match the expected format. Reason: %2$s' ), $param, $reason ), … … 1759 1759 if ( count( $schema_titles ) === count( $errors ) ) { 1760 1760 /* translators: 1: Parameter, 2: Schema titles. */ 1761 return new WP_Error( 'rest_ invalid_param', wp_sprintf( __( '%1$s is not a valid %2$l.' ), $param, $schema_titles ) );1761 return new WP_Error( 'rest_no_matching_schema', wp_sprintf( __( '%1$s is not a valid %2$l.' ), $param, $schema_titles ) ); 1762 1762 } 1763 1763 1764 1764 /* translators: 1: Parameter. */ 1765 return new WP_Error( 'rest_ invalid_param', sprintf( __( '%1$s does not match any of the expected formats.' ), $param ) );1765 return new WP_Error( 'rest_no_matching_schema', sprintf( __( '%1$s does not match any of the expected formats.' ), $param ) ); 1766 1766 } 1767 1767 … … 1857 1857 if ( count( $schema_titles ) === count( $matching_schemas ) ) { 1858 1858 return new WP_Error( 1859 'rest_ invalid_param',1859 'rest_one_of_multiple_matches', 1860 1860 /* translators: 1: Parameter, 2: Schema titles. */ 1861 1861 wp_sprintf( __( '%1$s matches %2$l, but should match only one.' ), $param, $schema_titles ), … … 1865 1865 1866 1866 return new WP_Error( 1867 'rest_ invalid_param',1867 'rest_one_of_multiple_matches', 1868 1868 /* translators: 1: Parameter. */ 1869 1869 sprintf( __( '%1$s matches more than one of the expected formats.' ), $param ), … … 2011 2011 if ( isset( $args['minItems'] ) && count( $value ) < $args['minItems'] ) { 2012 2012 return new WP_Error( 2013 'rest_ invalid_param',2013 'rest_too_few_items', 2014 2014 sprintf( 2015 2015 /* translators: 1: Parameter, 2: Number. */ … … 2027 2027 if ( isset( $args['maxItems'] ) && count( $value ) > $args['maxItems'] ) { 2028 2028 return new WP_Error( 2029 ' rest_invalid_param',2029 'test_too_many_items', 2030 2030 sprintf( 2031 2031 /* translators: 1: Parameter, 2: Number. */ … … 2043 2043 if ( ! empty( $args['uniqueItems'] ) && ! rest_validate_array_contains_unique_items( $value ) ) { 2044 2044 /* translators: 1: Parameter. */ 2045 return new WP_Error( 'rest_ invalid_param', sprintf( __( '%1$s has duplicate items.' ), $param ) );2045 return new WP_Error( 'rest_duplicate_items', sprintf( __( '%1$s has duplicate items.' ), $param ) ); 2046 2046 } 2047 2047 } … … 2096 2096 if ( false === $args['additionalProperties'] ) { 2097 2097 /* translators: %s: Property of an object. */ 2098 return new WP_Error( 'rest_ invalid_param', sprintf( __( '%1$s is not a valid property of Object.' ), $property ) );2098 return new WP_Error( 'rest_additional_properties_forbidden', sprintf( __( '%1$s is not a valid property of Object.' ), $property ) ); 2099 2099 } 2100 2100 … … 2110 2110 if ( isset( $args['minProperties'] ) && count( $value ) < $args['minProperties'] ) { 2111 2111 return new WP_Error( 2112 'rest_ invalid_param',2112 'rest_too_few_properties', 2113 2113 sprintf( 2114 2114 /* translators: 1: Parameter, 2: Number. */ … … 2126 2126 if ( isset( $args['maxProperties'] ) && count( $value ) > $args['maxProperties'] ) { 2127 2127 return new WP_Error( 2128 'rest_ invalid_param',2128 'rest_too_many_properties', 2129 2129 sprintf( 2130 2130 /* translators: 1: Parameter, 2: Number. */ … … 2157 2157 if ( ! in_array( $value, $args['enum'], true ) ) { 2158 2158 /* translators: 1: Parameter, 2: List of valid values. */ 2159 return new WP_Error( 'rest_ invalid_param', sprintf( __( '%1$s is not one of %2$s.' ), $param, implode( ', ', $args['enum'] ) ) );2159 return new WP_Error( 'rest_not_in_enum', sprintf( __( '%1$s is not one of %2$s.' ), $param, implode( ', ', $args['enum'] ) ) ); 2160 2160 } 2161 2161 } … … 2173 2173 if ( isset( $args['multipleOf'] ) && fmod( $value, $args['multipleOf'] ) !== 0.0 ) { 2174 2174 /* translators: 1: Parameter, 2: Multiplier. */ 2175 return new WP_Error( 'rest_invalid_ param', sprintf( __( '%1$s must be a multiple of %2$s.' ), $param, $args['multipleOf'] ) );2175 return new WP_Error( 'rest_invalid_multiple', sprintf( __( '%1$s must be a multiple of %2$s.' ), $param, $args['multipleOf'] ) ); 2176 2176 } 2177 2177 } … … 2207 2207 if ( isset( $args['minLength'] ) && mb_strlen( $value ) < $args['minLength'] ) { 2208 2208 return new WP_Error( 2209 'rest_ invalid_param',2209 'rest_too_short', 2210 2210 sprintf( 2211 2211 /* translators: 1: Parameter, 2: Number of characters. */ … … 2219 2219 if ( isset( $args['maxLength'] ) && mb_strlen( $value ) > $args['maxLength'] ) { 2220 2220 return new WP_Error( 2221 'rest_ invalid_param',2221 'rest_too_long', 2222 2222 sprintf( 2223 2223 /* translators: 1: Parameter, 2: Number of characters. */ … … 2261 2261 if ( ! rest_is_ip_address( $value ) ) { 2262 2262 /* translators: %s: IP address. */ 2263 return new WP_Error( 'rest_invalid_ param', sprintf( __( '%s is not a valid IP address.' ), $param ) );2263 return new WP_Error( 'rest_invalid_ip', sprintf( __( '%s is not a valid IP address.' ), $param ) ); 2264 2264 } 2265 2265 break; … … 2277 2277 if ( ! empty( $args['exclusiveMinimum'] ) && $value <= $args['minimum'] ) { 2278 2278 /* translators: 1: Parameter, 2: Minimum number. */ 2279 return new WP_Error( 'rest_ invalid_param', sprintf( __( '%1$s must be greater than %2$d' ), $param, $args['minimum'] ) );2279 return new WP_Error( 'rest_out_of_bounds', sprintf( __( '%1$s must be greater than %2$d' ), $param, $args['minimum'] ) ); 2280 2280 } elseif ( empty( $args['exclusiveMinimum'] ) && $value < $args['minimum'] ) { 2281 2281 /* translators: 1: Parameter, 2: Minimum number. */ 2282 return new WP_Error( 'rest_ invalid_param', sprintf( __( '%1$s must be greater than or equal to %2$d' ), $param, $args['minimum'] ) );2282 return new WP_Error( 'rest_out_of_bounds', sprintf( __( '%1$s must be greater than or equal to %2$d' ), $param, $args['minimum'] ) ); 2283 2283 } 2284 2284 } elseif ( isset( $args['maximum'] ) && ! isset( $args['minimum'] ) ) { 2285 2285 if ( ! empty( $args['exclusiveMaximum'] ) && $value >= $args['maximum'] ) { 2286 2286 /* translators: 1: Parameter, 2: Maximum number. */ 2287 return new WP_Error( 'rest_ invalid_param', sprintf( __( '%1$s must be less than %2$d' ), $param, $args['maximum'] ) );2287 return new WP_Error( 'rest_out_of_bounds', sprintf( __( '%1$s must be less than %2$d' ), $param, $args['maximum'] ) ); 2288 2288 } elseif ( empty( $args['exclusiveMaximum'] ) && $value > $args['maximum'] ) { 2289 2289 /* translators: 1: Parameter, 2: Maximum number. */ 2290 return new WP_Error( 'rest_ invalid_param', sprintf( __( '%1$s must be less than or equal to %2$d' ), $param, $args['maximum'] ) );2290 return new WP_Error( 'rest_out_of_bounds', sprintf( __( '%1$s must be less than or equal to %2$d' ), $param, $args['maximum'] ) ); 2291 2291 } 2292 2292 } elseif ( isset( $args['maximum'] ) && isset( $args['minimum'] ) ) { … … 2294 2294 if ( $value >= $args['maximum'] || $value <= $args['minimum'] ) { 2295 2295 /* translators: 1: Parameter, 2: Minimum number, 3: Maximum number. */ 2296 return new WP_Error( 'rest_ invalid_param', sprintf( __( '%1$s must be between %2$d (exclusive) and %3$d (exclusive)' ), $param, $args['minimum'], $args['maximum'] ) );2296 return new WP_Error( 'rest_out_of_bounds', sprintf( __( '%1$s must be between %2$d (exclusive) and %3$d (exclusive)' ), $param, $args['minimum'], $args['maximum'] ) ); 2297 2297 } 2298 2298 } elseif ( empty( $args['exclusiveMinimum'] ) && ! empty( $args['exclusiveMaximum'] ) ) { 2299 2299 if ( $value >= $args['maximum'] || $value < $args['minimum'] ) { 2300 2300 /* translators: 1: Parameter, 2: Minimum number, 3: Maximum number. */ 2301 return new WP_Error( 'rest_ invalid_param', sprintf( __( '%1$s must be between %2$d (inclusive) and %3$d (exclusive)' ), $param, $args['minimum'], $args['maximum'] ) );2301 return new WP_Error( 'rest_out_of_bounds', sprintf( __( '%1$s must be between %2$d (inclusive) and %3$d (exclusive)' ), $param, $args['minimum'], $args['maximum'] ) ); 2302 2302 } 2303 2303 } elseif ( ! empty( $args['exclusiveMinimum'] ) && empty( $args['exclusiveMaximum'] ) ) { 2304 2304 if ( $value > $args['maximum'] || $value <= $args['minimum'] ) { 2305 2305 /* translators: 1: Parameter, 2: Minimum number, 3: Maximum number. */ 2306 return new WP_Error( 'rest_ invalid_param', sprintf( __( '%1$s must be between %2$d (exclusive) and %3$d (inclusive)' ), $param, $args['minimum'], $args['maximum'] ) );2306 return new WP_Error( 'rest_out_of_bounds', sprintf( __( '%1$s must be between %2$d (exclusive) and %3$d (inclusive)' ), $param, $args['minimum'], $args['maximum'] ) ); 2307 2307 } 2308 2308 } elseif ( empty( $args['exclusiveMinimum'] ) && empty( $args['exclusiveMaximum'] ) ) { 2309 2309 if ( $value > $args['maximum'] || $value < $args['minimum'] ) { 2310 2310 /* translators: 1: Parameter, 2: Minimum number, 3: Maximum number. */ 2311 return new WP_Error( 'rest_ invalid_param', sprintf( __( '%1$s must be between %2$d (inclusive) and %3$d (inclusive)' ), $param, $args['minimum'], $args['maximum'] ) );2311 return new WP_Error( 'rest_out_of_bounds', sprintf( __( '%1$s must be between %2$d (inclusive) and %3$d (inclusive)' ), $param, $args['minimum'], $args['maximum'] ) ); 2312 2312 } 2313 2313 } … … 2394 2394 if ( ! empty( $args['uniqueItems'] ) && ! rest_validate_array_contains_unique_items( $value ) ) { 2395 2395 /* translators: 1: Parameter. */ 2396 return new WP_Error( 'rest_ invalid_param', sprintf( __( '%1$s has duplicate items.' ), $param ) );2396 return new WP_Error( 'rest_duplicate_items', sprintf( __( '%1$s has duplicate items.' ), $param ) ); 2397 2397 } 2398 2398 -
trunk/tests/phpunit/tests/rest-api/rest-controller.php
r49547 r50007 165 165 166 166 $this->assertErrorResponse( 167 'rest_ invalid_param',167 'rest_not_in_enum', 168 168 rest_validate_request_arg( 'd', $this->request, 'someenum' ) 169 169 );
Note: See TracChangeset
for help on using the changeset viewer.