// kit-abm-list-check.component.ts import { Component, Input, } from '@angular/core'; import { AbmList } from '../../interface/abm-list.interface'; import { FormControl, } from '@angular/forms'; @Component({ selector: 'kit-abm-list-check', templateUrl: './kit-abm-list-check.component.html', }) export class AbmListCheckComponent { @Input() control: FormControl = new FormControl({}); @Input() label: string = ''; private _abmListInput!: AbmList; @Input() public set abmListInput(abmListInput: AbmList) { this._abmListInput = abmListInput; } public get abmListInput() { return this._abmListInput; } public validateError() { if (!this.abmListInput?.errors) return ""; let errorKey: string; for (let index = 0; index < this.abmListInput.errors.length; index++) { const element = this.abmListInput.errors[index]; errorKey = Object.keys(element.errorValidator ?? {})[0]; if (this.control.hasError(errorKey)) { return element.errorDescription; } } return ""; } }