Created
December 18, 2023 19:39
-
-
Save andrewarosario/7ccec8a0489e7281481d59fd73a816da to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { AbstractControl, ValidationErrors, ValidatorFn } from '@angular/forms'; | |
export function forbiddenNameValidator(nameRe: RegExp): ValidatorFn { | |
return (control: AbstractControl): ValidationErrors | null => { | |
const forbidden = nameRe.test(control.value); | |
return forbidden ? { forbiddenName: { value: control.value } } : null; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment