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
@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.CreateManyDto Structure
When using@ParsedBody with bulk create operations:
See Also
- @ParsedRequest - Access parsed request data
- @Override - Override CRUD routes
- @Crud - Main CRUD decorator
- Validation - DTO validation guide