The NestJS ValidationPipe does not validate custom decorators. So, in this above example we just make a @RawBody() param decorator, and NestJS will skip validating it.
Take a look at NestJS' ValidationPipe class at the relevant points:
Here is where it checks to see if the decorator type is 'custom':
https://github.com/nestjs/nest/blob/master/packages/common/pipes/validation.pipe.ts#L164-L166
Here is where it returns if validation shouldn't apply:
https://github.com/nestjs/nest/blob/master/packages/common/pipes/validation.pipe.ts#L102-L106
Here are some links that talk about this issue and some documentation links that are relevant:
- https://docs.nestjs.com/techniques/validation
- https://docs.nestjs.com/interceptors
- nestjs/nest#2390
- nestjs/nest#3354
- https://stackoverflow.com/questions/58751743/disable-validation-in-nestjs-param-decorator?rq=1
- https://stackoverflow.com/questions/54471331/how-to-ignore-an-interceptor-for-a-particular-route-in-nestjs
- https://stackoverflow.com/questions/56273543/how-to-override-global-validationpipe-in-controller
- https://stackoverflow.com/questions/56583609/how-can-we-override-the-global-validation-pipe-in-nestjs
This was very useful, thank you! 👍