Closed its-dibo closed 7 months ago
decorators from class-validator are ignored by Nest
.
1- add the plugin and enable classValidatorShim
classValidatorShim
"plugins": [ { "name": "@nestjs/swagger", "options": { "introspectComments": true, "classValidatorShim": true } } ]
2- create an entity, and attach @IsEmail() to a property
@IsEmail()
@Entity() class Users{ @Column({ unique: true }) @IsMobilePhone() @Matches(/^\+/) mobile: string; }
3- open swagger and create a new user (via a POST request) and perform an intented violations for the email field. no one of the attached decorators from class-validation is working only unique is considered by TypeORM
unique
the email violations are catched
7.1.14
10
20
No response
Please provide a minimum reproduction repository (Git repository/StackBlitz/CodeSandbox project).
Is there an existing issue for this?
Current behavior
decorators from class-validator are ignored by Nest
Minimum reproduction code
.
Steps to reproduce
1- add the plugin and enable
classValidatorShim
2- create an entity, and attach
@IsEmail()
to a property3- open swagger and create a new user (via a POST request) and perform an intented violations for the email field. no one of the attached decorators from class-validation is working only
unique
is considered by TypeORMExpected behavior
the email violations are catched
Package version
7.1.14
NestJS version
10
Node.js version
20
In which operating systems have you tested?
Other
No response