Skip to main content

Overview

The @ParsedBody decorator is a parameter decorator that injects the validated and transformed request body into your controller method parameters. It’s specifically designed for use with CRUD operations and ensures the body has been validated and processed according to your DTO definitions.

Signature

Usage

Basic Usage

With Bulk Create

Adding Business Logic

With Update Operations

Integration Test Example

From the source tests:
packages/crud/test/crud.decorator.override.spec.ts:53-55

Combining with Validation

With File Uploads

Advanced: Conditional Processing

Implementation Details

packages/crud/src/decorators/parsed-body.decorator.ts:3-5
The decorator stores metadata about the parameter index, which the CRUD framework uses to inject the validated body.
The @ParsedBody decorator ensures the request body has been validated according to your DTO class using class-validator decorators. Any validation errors will be thrown before your method is called.
Always use @ParsedBody instead of the standard @Body decorator when overriding CRUD routes. This ensures proper integration with the CRUD validation pipeline.

CreateManyDto Structure

When using @ParsedBody with bulk create operations:
Example:

See Also