I am working on a change password endpoint using nestjs , I want to be able to validate if the two password match
The class-validator library doesn’t seem to have that on how to validate two properties within the DTO
How do I achieve this
This is my current code
export class CreatePasswordDTO {
@MaxLength(6)
@IsString()
@Matches(/^d{6}$/, { message: "Password must be a 6-digit number" })
password: string;
@MaxLength(6)
@IsString()
@Matches(/^d{6}$/, { message: "Confirm Password must be a 6-digit number" })
// I check that the password and confirmPassword are the same
confirmPassword: string;
}