Hi, is there any “flatMap-ish” equivalent for `Val...
# arrow
j
Hi, is there any “flatMap-ish” equivalent for
Validated.zip(...)
? Where the last parameter (combining function) also returns ValidatedNel, not the resulting value?
s
Not out of the box 🤔 Your use-case is validating individual values, and then validating them together as a group? Can you share a snippet?
j
Can't share a snippet during weekend 🙂 but that's exactly the case. I get
val a: ValidatedNel<E,A>
from one source and
val b: ValidatedNel<E,B>
from another. But cannot simply combine them in
val c = a.zip(b,::f)
, because result can also fail for certain conditions from a and b. What I went with is
val c = a.zip(b, ::Pair).andThen{(a,b)->f(a,b)}
.