in src/app/common/validator/account-exists.validator.ts [28:43]
export function accountExists(accountingService: AccountingService): AsyncValidatorFn {
return (control: AbstractControl): Observable<any> => {
if (!control.dirty || isEmptyInputValue(control.value)) {
return Observable.of(null);
}
if (isString(control.value) && control.value.trim().length === 0) {
return invalid;
}
return accountingService.findAccount(control.value, true)
.map(account => null)
.catch(() => invalid);
};
}