argos/dmp-frontend/src/app/common/forms/validation/validation-context.ts

21 lines
515 B
TypeScript
Raw Normal View History

2017-12-14 14:10:56 +01:00
import { ValidatorFn } from '@angular/forms';
export class ValidationContext {
2018-10-05 17:00:54 +02:00
validation: Validation[] = [];
2017-12-14 14:10:56 +01:00
2018-10-05 17:00:54 +02:00
getValidation(key: string): Validation {
for (let i = 0; i < this.validation.length; i++) {
if (this.validation[i].key === key) {
return this.validation[i];
}
}
2019-01-18 18:03:45 +01:00
throw new Error('Key ' + key + ' Was Not Found In The Validation Context');
2018-10-05 17:00:54 +02:00
}
2017-12-14 14:10:56 +01:00
}
export class Validation {
2018-10-05 17:00:54 +02:00
key: string;
validators?: ValidatorFn[] = new Array<ValidatorFn>();
descendantValidations?: ValidationContext;
2017-12-14 14:10:56 +01:00
}