I created a Base Validator
method with a 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 iterate through all the validators and call their ASYNC method
//one by one and stop when there is an error ???
}
}
}
Each validator
method has a validate()
function that returns an observable.
export interface IValidator {
validate(): Observable<ValidatorModel>;
}
The ValidatorModel looks like this:
export class ValidatorModel {
readonly isSuccessful: boolean;
errors: Array<string>;
}
My main concern is :
How can I loop through all the validators and call their ASYNC methods one by one, stopping when an error occurs?