Skip to content

Instantly share code, notes, and snippets.

@tmhpfnr
Last active April 2, 2025 11:49
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);
});
}
@schulto
Copy link

schulto commented Apr 2, 2025

Lifesaver, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment