In a component with an input, I pass an array of such objects for validation:
export class ValidatorItem {
validator: ValidatorFn;
errorText: string;
}
in component:
ngOnChanges(changes: SimpleChanges): void {
if ('validators' in changes) {
this.formModel = this.formBuilder.group({
value: ['', Validators.compose(this.validators.map(v => v.validator))],
});
}
}
that is, I need to get an errorText message depending on which validator fell. How can i do this?