Skip to content

Instantly share code, notes, and snippets.

@alexonozor
Created September 2, 2017 06:27
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/76e93fe9eba5e5c85a031b216b443af0 to your computer and use it in GitHub Desktop.
Save alexonozor/76e93fe9eba5e5c85a031b216b443af0 to your computer and use it in GitHub Desktop.
const userForm = new FormGroup({
userName: new FormControl('', [
Validators.required,
Validators.minLength(2),
forbiddenNameValidator(/bob/i) // <-- Here's how you pass in the custom validator.
]),
firstName: new FormControl('', [ Validators.required, Validators.minLength(2)]),
lastName: new FormControl(''),
address: new FormGroup({
street: new FormControl('', Validators.required),
city: new FormControl(''),
zipCode: new FormControl('')
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment