rest_validate_request_arg( mixed $value, WP_REST_Request $request, string $param )

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


Description Description


Parameters Parameters

$value

(mixed) (Required)

$request

(WP_REST_Request) (Required)

$param

(string) (Required)


Top ↑

Return Return

(WP_Error|boolean)


Top ↑

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

Top ↑

Changelog Changelog

Changelog
Version Description
4.7.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.