---
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 markdown="1">

body


</td><td markdown="1">

[RequestBody](./rest.requestbody.md)


</td><td markdown="1">

The request body parsed from an HTTP request.


</td></tr>
<tr><td markdown="1">

requestBodySpec


</td><td markdown="1">

RequestBodyObject


</td><td markdown="1">

_(Optional)_ The OpenAPI requestBody specification defined in `@requestBody()`<!-- -->.


</td></tr>
<tr><td markdown="1">

globalSchemas


</td><td markdown="1">

SchemasObject


</td><td markdown="1">

_(Optional)_ The referenced schemas generated from `OpenAPISpec.components.schemas`<!-- -->.


</td></tr>
<tr><td markdown="1">

options


</td><td markdown="1">

[ValidationOptions](./rest.validationoptions.md)


</td><td markdown="1">

_(Optional)_ Request body validation options for AJV


</td></tr>
</tbody></table>

**Returns:**

Promise&lt;void&gt;


