In your Validated docs, about half way down, you t...
# arrow
s
In your Validated docs, about half way down, you talk about taking two Validated's and doing something only if both are Valid's, and you post up code for parallelValidation:
Copy code
fun <E, A, B, C> parallelValidate
        (v1: Validated<E, A>, v2: Validated<E, B>, f: (A, B) -> C): Validated<NonEmptyList<E>, C> {
    return when {
        v1 is Validated.Valid && v2 is Validated.Valid -> Validated.Valid(f(v1.a, v2.a))
        v1 is Validated.Valid && v2 is Validated.Invalid -> v2.toValidatedNel()
        v1 is Validated.Invalid && v2 is Validated.Valid -> v1.toValidatedNel()
        v1 is Validated.Invalid && v2 is Validated.Invalid -> Validated.Invalid(NonEmptyList(v1.e, listOf(v2.e)))
        else -> throw IllegalStateException("Not possible value")
    }
}
I need to do exactly this, is this actually built in somewhere because the docs don't mention it. So I'm doing the huge when at the moment.