rest_parse_request_arg()WP 4.7.0

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

Runs a validation check and sanitizes the value, primarily to be used via the sanitize_callback arguments in the endpoint args registration.

No Hooks.

Return

Mixed.

Usage

rest_parse_request_arg( $value, $request, $param );
$value(mixed) (required)
-
$request(WP_REST_Request) (required)
-
$param(string) (required)
-

Changelog

Since 4.7.0 Introduced.

rest_parse_request_arg() code WP 6.5.2

function rest_parse_request_arg( $value, $request, $param ) {
	$is_valid = rest_validate_request_arg( $value, $request, $param );

	if ( is_wp_error( $is_valid ) ) {
		return $is_valid;
	}

	$value = rest_sanitize_request_arg( $value, $request, $param );

	return $value;
}