Title: WP_HTTP_Polling_Sync_Server::validate_request
Published: May 20, 2026

---

# WP_HTTP_Polling_Sync_Server::validate_request( WP_REST_Request $request ): true|󠀁[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)󠁿

## In this article

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

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

Validates that the request body does not exceed the maximum allowed size.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_http_polling_sync_server/validate_request/?output_format=md#description)󠁿

Runs as the route-level validate_callback, after per-arg schema validation has already
passed.

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

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

The REST request.

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

 true|[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/) True
if valid, [WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)
if the body is too large.

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

    ```php
    public function validate_request( WP_REST_Request $request ) {
    	$body = $request->get_body();
    	if ( is_string( $body ) && strlen( $body ) > self::MAX_BODY_SIZE ) {
    		return new WP_Error(
    			'rest_sync_body_too_large',
    			__( 'Request body is too large.' ),
    			array( 'status' => 413 )
    		);
    	}

    	return true;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/collaboration/class-wp-http-polling-sync-server.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/collaboration/class-wp-http-polling-sync-server.php#L264)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/collaboration/class-wp-http-polling-sync-server.php#L264-L275)

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

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

Retrieves the translation of $text.

  | 
| [WP_Error::__construct()](https://developer.wordpress.org/reference/classes/wp_error/__construct/)`wp-includes/class-wp-error.php` |

Initializes the error.

  |

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

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

## User Contributed Notes

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