Попробуйте это
ngOnInit() {
this.changePassForm = this.formBuilder.group({
oldPassword: ['', [Validators.required]],
password: [null, Validators.compose([
Validators.required,
PasswordValidation.patternValidator(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/, {isPasswordValid: true})
])],
confirm_password: [null, Validators.compose([Validators.required])],
}, {
validator: this.checkPasswords
});
}
checkPasswords(group: FormGroup) {
let password = group.get('password').value;
let confirmPassword = group.get('confirm_password').value;
return password === confirmPassword ? null : { notSame: true }
}
Надеюсь, это поможет.