NestJS 11 · Validation, guards and interceptors
Enable validation globally
Validate and transform every request body. whitelist removes properties the DTO doesn't declare.
app.useGlobalPipes(new ValidationPipe({ whitelist: true, transform: true }));
Official NestJS 11 documentation
More validation, guards and interceptors commands
- Describe and validate a request body
- Protect routes with a guard
- Run code around handlers
- Customize error responses
- Enable CORS
- Generate OpenAPI docs
All validation, guards and interceptors commands · NestJS 11 cheatsheet