Skip to content

tonisives/fp-ts-validated-nel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

validatedNel

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(...

run

yarn tsx ./src/app.run.ts

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published