i'am trying to implement a function to check email and confirmation email with angular, when i type a different confirmation email, my function work and i get an error , now when i try to correct the email and make it same as the confirmation email i still get the error even if the two emails are same
the body of the function:
static checkEmails(group: FormGroup): ValidationErrors | null {
const email = group.controls.email.value;
const confirmEmail = group.controls.confirmEmail.value;
const responseKo = { NOT_SAME: true };
const responseOk = null;
let identical = false;
if (email.toLowerCase() === confirmEmail.toLowerCase()) {
identical = true;
} else {
group.controls.confirmEmail.setErrors(responseKo);
}
return identical ? responseOk : responseKo;
}