I am using tsoa with class-validator in express js
Now when i define DTO with class-validator and define type for body in tsoa route, it only validates the datataype of the body object values & if it is required or not. It does not validate other properties of class-validator like @IsEmail() or @Length() etc.
Code Example:
// Dto
export class RegisterUserDto {
@IsEmail()
email!: string
}
// Route
@Route('user')
export class UserController extends Controller {
@Post('/register')
async createUser(@Body() body: RegisterUserDto) {
return userService.registerUser(body)
}
}
// Tsoa generated routes file
const models = {
"RegisterUserDto": {
"dataType": "refObject",
"properties": {
// Here it should also check if this property is a valid email or not.
"email": { "dataType": "string", "required": true },
},
"additionalProperties": false,
},
}
// Package versions
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"tsoa": "6.2.1",