Skip to content

Instantly share code, notes, and snippets.

@tmhpfnr
Last active November 8, 2018 17:01
Show Gist options
  • Save tmhpfnr/3f1bf5443e66e1f22e3d08d26e50d0f1 to your computer and use it in GitHub Desktop.
Save tmhpfnr/3f1bf5443e66e1f22e3d08d26e50d0f1 to your computer and use it in GitHub Desktop.
Log angular (reactive) forms field validation status to console
debugFormValidations(form: FormGroup) {
Object.keys(form.controls).forEach(k => {
const control = form.controls[k];
// see https://angular.io/api/forms/AbstractControl#status
const log = control.invalid ? console['warn'] : console['log'];
log(k, 'invalid', control.invalid, 'value', control.value);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment