import { AbstractControl , FormControl , ValidationErrors , ValidatorFn } from '@angular/forms' ; export const ValidRegexValidator = ( control ) : ValidationErrors | null => { let regexInValid ; try { new RegExp ( control . value ) ; regexInValid = false ; } catch ( e ) { regexInValid = true ; } return regexInValid ? { regexInValid : { value : control . value } } : null ; } ;