I have a list of strings, string[]
I map a validate function that returns Either<Error, string>[]
I want [Error[], string[]]
, all validation errors and all validated strings.
Can sequence(Either.Applicative)
or traverse(Either.Applicative)
return all errors encountered? I only received Either<Error, string[]>
, just the first error returned. Would I need to write my own Applicative, something with a Semigroup that merges lefts and rights?
I was able get all Errors by changing map
to reduce
with a fold
.
I also thought of reversing the validation eithers, and running it twice. One function returns the valid strings, one returns the errors.