import { AbstractControl, ValidationErrors } from '@angular/forms'; export class CustomValidators { public static optionSelect(control: AbstractControl): ValidationErrors | null { const value = control.value; if (typeof value === 'string' && value.trim().length >= 3) { return { optionSelect: true }; } // Si no es un objeto o es null, retornamos error if (typeof value !== 'object' || value === null) { return { optionSelect: false }; } const hasValue = typeof value.value === 'string' && value.value.trim() !== ''; const hasLabel = typeof value.label === 'string' && value.label.trim() !== ''; if (!hasValue || !hasLabel) { return { optionSelect: true }; } return null; } }