import * as t from 'io-ts'; import { pipe } from 'fp-ts/function'; import * as E from 'fp-ts/Either'; type Either = E.Either; /** * All this really does is change the shape of the error side of the Either * @param f */ export const validateEither = (f: (i: I) => Either): t.Validate => (value, context) => pipe( f(value), E.mapLeft((message: string) => [{ value, context, message }]) );