Hi, I am new at angular I have version 5 and I am trying to do a validation to verify if a data is registered in the database, the details is that when the validation is executed, the error message is not interpreted. it is a problem of how the service returns the validation this is the code that I am used.
rutExistValidator(): ValidatorFn {
return (control: AbstractControl): { [key: string]: any } => {
return this.apiValiRut(control.value).subscribe(data => {
this.datos = data;
if (this.datos.process) {
return { 'rutExist': { value: control.value } };
}
});
}
}
and the error shows like this.
<div *ngIf="form.controls['rut'].errors.rutExist">
* este rut ya existe
</div>
If someone can guide would be very helpful thanks.