mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 00:33:44 +00:00
* Refactor restricted imports eslint rule, add angular deps * Move FormValidationErrorsService into libs/angular * Remove angular decorators from configService * Remove angular decorator from anonymousHubService
32 lines
995 B
TypeScript
32 lines
995 B
TypeScript
import { UntypedFormGroup, ValidationErrors } from "@angular/forms";
|
|
|
|
import {
|
|
FormGroupControls,
|
|
FormValidationErrorsService as FormValidationErrorsAbstraction,
|
|
AllValidationErrors,
|
|
} from "../abstractions/form-validation-errors.service";
|
|
|
|
export class FormValidationErrorsService implements FormValidationErrorsAbstraction {
|
|
getFormValidationErrors(controls: FormGroupControls): AllValidationErrors[] {
|
|
let errors: AllValidationErrors[] = [];
|
|
Object.keys(controls).forEach((key) => {
|
|
const control = controls[key];
|
|
if (control instanceof UntypedFormGroup) {
|
|
errors = errors.concat(this.getFormValidationErrors(control.controls));
|
|
}
|
|
|
|
const controlErrors: ValidationErrors = controls[key].errors;
|
|
if (controlErrors !== null) {
|
|
Object.keys(controlErrors).forEach((keyError) => {
|
|
errors.push({
|
|
controlName: key,
|
|
errorName: keyError,
|
|
});
|
|
});
|
|
}
|
|
});
|
|
|
|
return errors;
|
|
}
|
|
}
|