Put in order · NestJS course · Module 1: NestJS Basics
Steps for Adding DTO Validation
Arrange the steps for adding DTO validation in NestJS:
Items to put in order
- Adding validation decorators to DTO class fields
- Activating ValidationPipe in main.ts
- Using DTO in the controller: @Body() dto: CreateDto
- Install: npm install class-validator class-transformer
Show the answer
Correct order:
- Install: npm install class-validator class-transformer
- Using DTO in the controller: @Body() dto: CreateDto
- Adding validation decorators to DTO class fields
- Activating ValidationPipe in main.ts