rest_validate_request_arg
Validate a request argument based on details registered to the route.
Description
Returns (WP_Error|boolean)
Parameters (3)
- 0. $value (mixed)
- The value.
- 1. $request (WP_REST_Request)
- The request.
- 2. $param (string)
- The param.
Usage
if ( !function_exists( 'rest_validate_request_arg' ) ) { require_once ABSPATH . WPINC . '/rest-api.php'; } // The value. $value = null; // The request. $request = null; // The param. $param = ''; // NOTICE! Understand what this does before running. $result = rest_validate_request_arg($value, $request, $param);
Defined (1)
The function is defined in the following location(s).
- /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 );
- }