rest_validate_request_arg() WordPress Function
The rest_validate_request_arg() function is used to validate a request argument based on the registered route arguments. This function returns either the valid value or WP_Error object if the value is invalid.
rest_validate_request_arg( mixed $value, WP_REST_Request $request, string $param ) #
Validate a request argument based on details registered to the route.
Parameters
- $value
(mixed)(Required)
- $request
(WP_REST_Request)(Required)
- $param
(string)(Required)
Return
(true|WP_Error)
Source
File: wp-includes/rest-api.php
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 ); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
4.7.0 | Introduced. |