A WordPress-centric search engine for devs and theme authors



rest_validate_request_arg ›

Since4.7.0
Deprecatedn/a
rest_validate_request_arg ( $value, $request, $param )
Parameters: (3)
  • (mixed) $value
    Required: Yes
  • (WP_REST_Request) $request
    Required: Yes
  • (string) $param
    Required: Yes
Returns:
  • (WP_Error|boolean)
Defined at:
Codex:

Validate a request argument based on details registered to the route.



Source

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 );
}