I am trying to do smth like this
@Directive({
selector: '[myVal][myCustomInputToComponent]',
providers: [
{ provide: NG_VALIDATORS, useExisting: forwardRef(() => MyVal), multi: true }
]
})
export class MyVal implements OnInit, Validator {
@Input() input: any;
constructor(private el: ElementRef) {
}
ngOnInit(): void {
console.log('validator input', this.input);
}
validate(): { [key: string]: any } {
console.log('validate', this.input)
return {
validatorName: {
valid: false
}
};
}
}
And validate
method obviously was not called. But maybe there is some way how you detect components with valid and invalid state. We are not using only FormControls to interact with customer, innit?