This is a simple custom validation rule for comparing two attributes for custom-validator.
npm install class-validator-same-as --save
import { IsEmail, IsNotEmpty, registerDecorator } from 'class-validator';
import sameAs from 'class-validator-same-as';
const IsSameAs = sameAs(registerDecorator);
export class RegisterUserDto {
@IsEmail()
email: string;
@IsNotEmpty()
password: string;
@IsNotEmpty()
@IsSameAs('password')
password_confirmation: string;
}
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.