Options dedicated file

Let's just have a bit more of organization with our options object.

If we want, we can also encapsulate the ValidationPipe options in a dedicated file. So, let's create the file common -> util -> common.constants and relocate the options here.

export const VALIDATION_PIPE_OPTIONS: ValidationPipeOptions = {
  whitelist: true,
  forbidNonWhitelisted: true,
  transform: true,
  transformOptions: {
    enableImplicitConversion: true,
  },
};

And finally, pass them to the ValidationPipe instantiation.

new ValidationPipe(VALIDATION_PIPE_OPTIONS)

Commit - Encapsulating options in dedicated file

Last updated