nestjsx / crud

NestJs CRUD for RESTful APIs
https://github.com/nestjsx/crud/wiki
MIT License
4.04k stars 533 forks source link

Feature request: Support global validation config #698

Open lucasmfredmark opened 3 years ago

lucasmfredmark commented 3 years ago

https://github.com/nestjsx/crud/wiki/Controllers#validation

Currently it's only possible to set validation configuration on controller level. It would be nice if this could be set at a global level as well, so you don't need to duplicate this for all controllers. The config should still be overridable on controller level.

vladi-strilets commented 3 years ago

You can use nestJS ValidationPipe for this.

// main.ts
async function bootstrap(): Promise<void> {
   ...
   const validationPipeOptions: ValidationPipeOptions = {
      skipMissingProperties: false,
      forbidNonWhitelisted: true,
      always: true,
      whitelist: true,
   };
   app.useGlobalPipes(new ValidationPipe(validationPipeOptions));
   ...
}