10 lines
424 B
TypeScript
10 lines
424 B
TypeScript
|
import { ValidatorFn, AbstractControl } from '@angular/forms';
|
||
|
import { BaseErrorModel } from '../../models/error/BaseErrorModel';
|
||
|
|
||
|
export function BackendErrorValidator(errorModel: BaseErrorModel, propertyName: string): ValidatorFn {
|
||
|
return (control: AbstractControl): { [key: string]: any } => {
|
||
|
const error: string = (<any>errorModel)[propertyName];
|
||
|
return error ? { 'backendError': { value: error } } : null;
|
||
|
};
|
||
|
}
|