rest_validate_boolean_value_from_schema() WordPress Function
This function is used to validate a boolean value from a schema. The function will return true if the value is valid, and false if the value is invalid.
rest_validate_boolean_value_from_schema( mixed $value, string $param ) #
Validates a boolean value based on a schema.
Parameters
- $value
(mixed)(Required)The value to validate.
- $param
(string)(Required)The parameter name, used in error messages.
Return
(true|WP_Error)
Source
File: wp-includes/rest-api.php
function rest_validate_boolean_value_from_schema( $value, $param ) {
if ( ! rest_is_boolean( $value ) ) {
return new WP_Error(
'rest_invalid_type',
/* translators: 1: Parameter, 2: Type name. */
sprintf( __( '%1$s is not of type %2$s.' ), $param, 'boolean' ),
array( 'param' => $param )
);
}
return true;
}
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
| Version | Description |
|---|---|
| 5.7.0 | Introduced. |