import { createValidator, findFirstError, Validator, getCurrentPath } from '../core'; export function pipe(validators: Validator[], message?: string) { return createValidator({ validate: (value, ctx) => { // find the first error in pipe const { error } = findFirstError(i => validators[i], () => value, () => ctx, validators.length); if (error && message) { return { message, path: getCurrentPath(ctx), children: null, // TODO should we really nullify children??? }; } return error; }, }); }