NestJS — Validate requests with custom decorators
5 min readDec 18, 2019
It is a must to add validation to all your APIs to avoid unexpected usage. The official document of NestJS suggests to validate requests with the Validation Pipe. Yet, the drawback is you will have to create a DTO for each API. If you don’t like the official approach, you may try my custom decorator approach. Imagine something like this:
@Post('create-proposal')
@Validate()…