On this page
rest_validate_integer_value_from_schema( mixed $value, array $args, string $param ): true|WP_Error
Validates an integer value based on a schema.
Parameters
$valuemixed Required-
The value to validate.
$argsarray Required-
Schema array to use for validation.
$paramstring Required-
The parameter name, used in error messages.
Return
true|WP_Error
Source
File: wp-includes/rest-api.php. View all references
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;
}
Related
Uses
| Uses | Description |
|---|---|
| rest_validate_number_value_from_schema() wp-includes/rest-api.php | Validates a number value based on a schema. |
| rest_is_integer() wp-includes/rest-api.php | Determines if a given value is integer-like. |
| __() wp-includes/l10n.php | Retrieves the translation of $text. |
| is_wp_error() wp-includes/load.php | Checks whether the given variable is a WordPress Error. |
| WP_Error::__construct() wp-includes/class-wp-error.php | Initializes the error. |
Used By
| Used By | Description |
|---|---|
| rest_validate_value_from_schema() wp-includes/rest-api.php | Validate a value based on a schema. |
Changelog
| Version | Description |
|---|---|
| 5.7.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/rest_validate_integer_value_from_schema