Skip to content

Instantly share code, notes, and snippets.

@matthieu-D
Last active March 8, 2017 20:25
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 matthieu-D/4783445770ee6c60282e68237b6c3539 to your computer and use it in GitHub Desktop.
Save matthieu-D/4783445770ee6c60282e68237b6c3539 to your computer and use it in GitHub Desktop.
export class HomeComponent {
userForm: FormGroup;
constructor (formBuilder: FormBuilder) {
this.userForm = formBuilder.group({
name: ['', this.validateName ],
email: '',
address: formBuilder.group({
country: '',
city: '',
})
});
}
validateName(form) {
return form.value.trim() !== '' ? null : {
validateName : {
errors: true
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment