Can I use class-validator
to validate Entity
columns?
This doesn't validate the columns:
import { IsEmail } from 'class-validator'; @Entity() export class Admin extends BaseEntity { @Column({ unique: true }) @IsEmail() email: string; }
However when I use the class-validator
anywhere else in the code other than entities it validates properly and doesn't allow for bad inputs.
This works:
@InputType() export class RegisterInput { @Field() @IsEmail() email: string; }
https://stackoverflow.com/questions/67340193/class-validator-doesnt-validate-entity May 01, 2021 at 04:39AM
没有评论:
发表评论