On this page
rest_validate_request_arg( mixed $value, WP_REST_Request $request, string $param ): true|WP_Error
Validate a request argument based on details registered to the route.
Parameters
$valuemixed Required$requestWP_REST_Request Required$paramstring Required
Return
true|WP_Error
Source
File: wp-includes/rest-api.php. View all references
function rest_validate_request_arg( $value, $request, $param ) {
$attributes = $request->get_attributes();
if ( ! isset( $attributes['args'][ $param ] ) || ! is_array( $attributes['args'][ $param ] ) ) {
return true;
}
$args = $attributes['args'][ $param ];
return rest_validate_value_from_schema( $value, $args, $param );
}
Related
Uses
| Uses | Description |
|---|---|
| rest_validate_value_from_schema() wp-includes/rest-api.php | Validate a value based on a schema. |
Used By
| Used By | Description |
|---|---|
| WP_REST_Menus_Controller::get_item_schema() wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php | Retrieves the term’s schema, conforming to JSON Schema. |
| WP_REST_Themes_Controller::sanitize_theme_status() wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php | Sanitizes and validates the list of theme status. |
| rest_parse_request_arg() wp-includes/rest-api.php | Parse a request argument based on details registered to the route. |
| WP_REST_Posts_Controller::sanitize_post_statuses() wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php | Sanitizes and validates the list of post statuses, including whether the user can query private statuses. |
| WP_REST_Comments_Controller::check_comment_author_email() wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php | Checks a comment author email for validity. |
Changelog
| Version | Description |
|---|---|
| 4.7.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/rest_validate_request_arg