Check out my blog post for more information.
In short, validatedNel is used to validate multiple problems and then merge them together into a single error string.
This repo shows how to handle this in a fp-ts context. It uses pipe
and getApplicativeValidation
let Ap = TE.getApplicativeTaskValidation(T.ApplyPar,
pipe(string.Semigroup, S.intercalate(", "))
)
let validateInput = (input: Input): E.Either<Error, Input> => {
let Ap = E.getApplicativeValidation(
pipe(string.Semigroup, S.intercalate(", "))
)
let apS = A.apS(Ap)
let res = pipe(
E.Do,
apS("fileName", validateFileName(input.fileName)),
apS("bucket", validateBucket(input.bucket)),
let res = await pipe(
validateInput(input),
TE.fromEither,
TE.fold(...
yarn
tsx ./src/app.run.ts