swagger
swagger copied to clipboard
classValidatorShim ignores class-validator decorators
Is there an existing issue for this?
- [X] I have searched the existing issues
Current behavior
decorators from class-validator are ignored by Nest
Minimum reproduction code
.
Steps to reproduce
1- add the plugin and enable classValidatorShim
"plugins": [
{
"name": "@nestjs/swagger",
"options": {
"introspectComments": true,
"classValidatorShim": true
}
}
]
2- create an entity, and attach @IsEmail() to a property
@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
Expected 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?
- [ ] macOS
- [ ] Windows
- [X] Linux
Other
No response
Please provide a minimum reproduction repository (Git repository/StackBlitz/CodeSandbox project).