---
lang: en
title: 'API docs: rest.validaterequestbody'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/rest
permalink: /doc/en/lb4/apidocs.rest.validaterequestbody.html
---

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/rest](./rest.md) &gt; [validateRequestBody](./rest.validaterequestbody.md)

## validateRequestBody() function

Check whether the request body is valid according to the provided OpenAPI schema. The JSON schema is generated from the OpenAPI schema which is typically defined by `@requestBody()`<!-- -->. The validation leverages AJV schema validator.

**Signature:**

```typescript
export declare function validateRequestBody(body: RequestBody, requestBodySpec?: RequestBodyObject, globalSchemas?: SchemasObject, options?: ValidationOptions): Promise<void>;
```

## Parameters

<table><thead><tr><th>

Parameter


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

body


</td><td>

[RequestBody](./rest.requestbody.md)


</td><td>

The request body parsed from an HTTP request.


</td></tr>
<tr><td>

requestBodySpec


</td><td>

RequestBodyObject


</td><td>

_(Optional)_ The OpenAPI requestBody specification defined in `@requestBody()`<!-- -->.


</td></tr>
<tr><td>

globalSchemas


</td><td>

SchemasObject


</td><td>

_(Optional)_ The referenced schemas generated from `OpenAPISpec.components.schemas`<!-- -->.


</td></tr>
<tr><td>

options


</td><td>

[ValidationOptions](./rest.validationoptions.md)


</td><td>

_(Optional)_ Request body validation options for AJV


</td></tr>
</tbody></table>

**Returns:**

Promise&lt;void&gt;


