rest_validate_integer_value_from_schema() WordPress Function
The rest_validate_integer_value_from_schema() function is used to validate an integer value from a schema. The function is used to check if the value is an integer and if the value is greater than or equal to the minimum and maximum values specified in the schema. If the value is not an integer or if the value is less than the minimum or maximum value, the function will return an error.
rest_validate_integer_value_from_schema( mixed $value, array $args, string $param ) #
Validates an integer value based on a schema.
Parameters
- $value
(mixed)(Required)The value to validate.
- $args
(array)(Required)Schema array to use for validation.
- $param
(string)(Required)The parameter name, used in error messages.
Return
(true|WP_Error)
Source
File: wp-includes/rest-api.php
function rest_validate_integer_value_from_schema( $value, $args, $param ) { $is_valid_number = rest_validate_number_value_from_schema( $value, $args, $param ); if ( is_wp_error( $is_valid_number ) ) { return $is_valid_number; } if ( ! rest_is_integer( $value ) ) { return new WP_Error( 'rest_invalid_type', /* translators: 1: Parameter, 2: Type name. */ sprintf( __( '%1$s is not of type %2$s.' ), $param, 'integer' ), array( 'param' => $param ) ); } return true; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
5.7.0 | Introduced. |