Issue
An error message "Expected 1-2 arguments but got 3. ts(2554)" is displayed when attempting to add a confirm email as the third argument.
I am currently working on an Angular 7 project where I am creating a register users form.
The problem arises when trying to validate and compare the user's email with the confirmation email in a Reactive form.
The function group does not allow for adding the argument for the confirm email, resulting in the error mentioned above.
How can I successfully add a confirm email field to the register form?
import {MustMatchEmail} from '../helpers/EmailValidator';
import {MustMatch} from '../helpers/must-match.validator';
constructor() {}
UserMail = new FormControl('', [Validators.required, Validators.email, Validators.pattern('^[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,4}$'), Validators.maxLength(100)]);
ConfirmedEmail = new FormControl('', [Validators.required, Validators.email, Validators.maxLength(100)])
ngOnInit() {
this.createFormValidations();
}
createFormValidations() {
this.registerForm = this.formBuilder.group({
UserMail: this.UserMail,
ConfirmedEmail: this.ConfirmedEmail,
UserPass: this.UserPass,
ConfirmedPassword: this.ConfirmedPassword,
}, {
validator: MustMatch('UserPass', 'ConfirmedPassword')
},
//The issue arises here, as the function does not accept the confirmation email
{
validator: MustMatchEmail('UserMail', 'ConfirmedEmail')
}
);
}