Title: rest_validate_request_arg
Published: December 7, 2016
Last modified: February 24, 2026

---

# rest_validate_request_arg( mixed $value, WP_REST_Request $request, string $param ): true|󠀁[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)󠁿

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/rest_validate_request_arg/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/rest_validate_request_arg/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/rest_validate_request_arg/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/rest_validate_request_arg/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/rest_validate_request_arg/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/rest_validate_request_arg/?output_format=md#wp--skip-link--target)

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

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/rest_validate_request_arg/?output_format=md#parameters)󠁿

 `$value`mixedrequired

`$request`[WP_REST_Request](https://developer.wordpress.org/reference/classes/wp_rest_request/)
required

`$param`stringrequired

## 󠀁[Return](https://developer.wordpress.org/reference/functions/rest_validate_request_arg/?output_format=md#return)󠁿

 true|[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)

## 󠀁[Source](https://developer.wordpress.org/reference/functions/rest_validate_request_arg/?output_format=md#source)󠁿

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

[View all references](https://developer.wordpress.org/reference/files/wp-includes/rest-api.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/rest-api.php#L1431)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/rest-api.php#L1431-L1439)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/rest_validate_request_arg/?output_format=md#related)󠁿

| Uses | Description | 
| [rest_validate_value_from_schema()](https://developer.wordpress.org/reference/functions/rest_validate_value_from_schema/)`wp-includes/rest-api.php` |

Validate a value based on a schema.

  |

| Used by | Description | 
| [WP_REST_Menus_Controller::get_item_schema()](https://developer.wordpress.org/reference/classes/wp_rest_menus_controller/get_item_schema/)`wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php` |

Retrieves the term’s schema, conforming to JSON Schema.

  | 
| [WP_REST_Themes_Controller::sanitize_theme_status()](https://developer.wordpress.org/reference/classes/wp_rest_themes_controller/sanitize_theme_status/)`wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php` |

Sanitizes and validates the list of theme status.

  | 
| [rest_parse_request_arg()](https://developer.wordpress.org/reference/functions/rest_parse_request_arg/)`wp-includes/rest-api.php` |

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

  | 
| [WP_REST_Posts_Controller::sanitize_post_statuses()](https://developer.wordpress.org/reference/classes/wp_rest_posts_controller/sanitize_post_statuses/)`wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php` |

Sanitizes and validates the list of post statuses, including whether the user can query private statuses.

  | 
| [WP_REST_Comments_Controller::check_comment_author_email()](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/check_comment_author_email/)`wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php` |

Checks a comment author email for validity.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/rest_validate_request_arg/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.7.0](https://developer.wordpress.org/reference/since/4.7.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Frest_validate_request_arg%2F)
before being able to contribute a note or feedback.