import { AbstractControl } from '@angular/forms'; import { emailRegex } from '../constants/email-regex'; export function emailValidator(control: AbstractControl): { [key: string]: { hint: string } } { const isValid: boolean = !control.value || emailRegex.test(control.value); return isValid ? undefined : {invalidFormat: {hint: 'e.g., test@test.com'}}; }