nestjs-api-tutorial
nestjs-api-tutorial copied to clipboard
whitelist: true option not working for new ValidationPipe
I have been trying to reproduce the validation part using dtos and global pipes but for some reason the whitelist option is not working. I know there have been ground breaking changes with nest, and their document hasn't been updated for the same, but the issue persists.
Here is my auth.dto.ts:
import { IsEmail, IsNotEmpty, IsString } from "class-validator"
export class AuthDto {
@IsEmail()
@IsNotEmpty()
email: string;
@IsString()
@IsNotEmpty()
password: string;
}
Here is my main.ts:
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { ValidationPipe } from '@nestjs/common';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.useGlobalPipes(new ValidationPipe({
whitelist: true,
}));
await app.listen(3333);
}
bootstrap();
did you solve it ?