Created
September 2, 2017 06:08
-
-
Save alexonozor/a3bd219c7bfecff464eafa6f3ac33106 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
/** 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