Skip to content

Instantly share code, notes, and snippets.

@alexonozor
Created September 2, 2017 06:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexonozor/a3bd219c7bfecff464eafa6f3ac33106 to your computer and use it in GitHub Desktop.
Save alexonozor/a3bd219c7bfecff464eafa6f3ac33106 to your computer and use it in GitHub Desktop.
/** A user name can't match the given regular expression */
export function forbiddenUserNameValidator(nameRe: RegExp): ValidatorFn {
return (control: AbstractControl): {[key: string]: any} => {
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