I have the Base Validator method which has list of ivalidator.
import { IValidator, ValidatorModel } from "../validation/ivalidator";
import { Observable } from "rxjs/Observable";
export abstract class BaseValidator implements IValidator {
private validators = new Array<IValidator>();
//Validators are pushed to the base validator =>Not implemented yet
validate(): Observable<ValidatorModel> {
for (let i = 0; i < this.validators.length; i++) {
//How do I loop thru all the validator and call its ASYNC method
//one by one and break and return when there is an error ???
}
}
}
Each validator method exposes the validate() method which returns an observable.
export interface IValidator {
validate(): Observable<ValidatorModel>;
}
ValidatorModel is
export class ValidatorModel {
readonly isSuccessful: boolean;
errors: Array<string>;
}
My question is :
How do I loop thru all the validator and call its ASYNC method one by one and break and return when there is an error ???