Trying to correctly define an email form field:
this.form.addControl('email', new FormControl('', [
Validators.required, CustomFormValidators.isValidEmail
]));
Utilizing a CustomFormValidators class that includes an isValidEmail method
static isValidEmail(control: AbstractControl): ValidationErrors | null {
if (!control) return; // <- ISSUE OCCURS HERE
const regex = new RegExp(..email regex..);
if (regex.test(control.value)) return null;
return { isValidEmail: true };
}
Encountering an error with Angular's new strict mode rules:
Type 'undefined' is not assignable to type 'ValidationErrors | null'.
Struggling to find a solution for this error.