Last active
June 6, 2022 10:00
-
-
Save shemmjunior/50e628c91260e5a824d859c6eb3a3d40 to your computer and use it in GitHub Desktop.
Get error fields on form validation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| getFormValidationErrors(): any { | |
| const errors = []; | |
| Object.keys(this.tenantForm.controls).forEach(key => { | |
| const controlErrors: ValidationErrors = this.tenantForm.get(key).errors; | |
| if (controlErrors != null) { | |
| Object.keys(controlErrors).forEach(keyError => { | |
| errors.push({ | |
| 'field': key, | |
| 'error': keyError, | |
| 'value': controlErrors[keyError] | |
| }); | |
| this.createErrorNotification('bottomLeft', `You have an error in the ${key} field`); | |
| }); | |
| } | |
| }); | |
| return JSON.stringify(errors); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment