in src/app/common/validator/customer-exists.validator.ts [28:42]
export function customerExists(customerService: CustomerService): AsyncValidatorFn {
return (control: AbstractControl): Observable<any> => {
if (!control.dirty || !control.value || control.value.length === 0) {
return Observable.of(null);
}
if (isString(control.value) && control.value.trim().length === 0) {
return invalid;
}
return customerService.getCustomer(control.value, true)
.map(customer => null)
.catch(() => invalid);
};
}