Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save borisBelloc/abd4219a6e098bf0b31d3e2869f00e7f to your computer and use it in GitHub Desktop.
Save borisBelloc/abd4219a6e098bf0b31d3e2869f00e7f to your computer and use it in GitHub Desktop.

Revisions

  1. @JohannesHoppe JohannesHoppe revised this gist Jul 19, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion get-form-validation-errors.ts
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ export function getFormValidationErrors(form: FormGroup) {
    if (controlErrors) {
    Object.keys(controlErrors).forEach(keyError => {
    result.push({
    'control ': key,
    'control': key,
    'error': keyError,
    'value': controlErrors[keyError]
    });
  2. @JohannesHoppe JohannesHoppe renamed this gist May 30, 2018. 1 changed file with 0 additions and 0 deletions.
  3. @JohannesHoppe JohannesHoppe created this gist May 30, 2018.
    21 changes: 21 additions & 0 deletions get-form-validation-errors.ts.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    import { FormGroup, ValidationErrors } from '@angular/forms';

    export function getFormValidationErrors(form: FormGroup) {

    const result = [];
    Object.keys(form.controls).forEach(key => {

    const controlErrors: ValidationErrors = form.get(key).errors;
    if (controlErrors) {
    Object.keys(controlErrors).forEach(keyError => {
    result.push({
    'control ': key,
    'error': keyError,
    'value': controlErrors[keyError]
    });
    });
    }
    });

    return result;
    }