Commit a2c2031c authored by Merzough Münker's avatar Merzough Münker
Browse files

fix(FormDirectives): add extended validation error logger

parent d9815a3b
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
# Changelog

## [0.20.2]
### Added
- (FormDirectives): add extended validation error logger

## [0.20.1]
### Added
- (FormDirectives): add extended validation error logger

## [0.20.0]
### Added
- (FormControl): add support for reset with the initial state
+1 −1
Original line number Diff line number Diff line
{
  "name": "@rxap/forms",
  "version": "0.20.0",
  "version": "0.20.2",
  "private": false,
  "author": "Merzough Münker",
  "homepage": "https://gitlab.com/rxap/packages",
+34 −0
Original line number Diff line number Diff line
@@ -234,6 +234,40 @@ export class FormDirective<T extends Record<string, any> = any> extends FormGrou
    } else {
      if (isDevMode()) {
        console.log('Form submit is not valid for: ' + this.form.controlId, this.form.errors);

        function printErrorControls(control: any) {
          if (!control.valid) {
            console.group(control.controlId);
            if (control.controls) {
              if (Array.isArray(control.controls)) {
                for (let i = 0; i < control.controls.length; i++) {
                  const child = control.controls[ i ];
                  if (!child.valid) {
                    console.group(`index: ${i}`);
                    printErrorControls(child);
                    console.groupEnd();
                  }
                }
              } else {
                for (const child of Object.values(control.controls)) {
                  printErrorControls(child);
                }
              }
            } else {
              if (control.errors) {
                for (const [ key, value ] of Object.entries(control.errors)) {
                  console.group(key);
                  console.log(value);
                  console.groupEnd();
                }
              }
              console.log('value: ', control.value);
            }
            console.groupEnd();
          }
        }

        printErrorControls(this.form);
      }
      this.invalidSubmit.emit();
    }