Advertisement
Guest User

Untitled

a guest
Jul 16th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.46 KB | None | 0 0
  1. fun <L : Any, R : Any, R1 : Any, R2 : Any, ... , R22 : Any> validate(
  2.         p1: Disjunction<L, R1>, p2: Disjunction<L, R2>, ... , p22: Disjunction<L, R22>,
  3.         ifValid: (R1, R2, ... , R22) -> R
  4. ): Disjunction<List<L>, R> {
  5.     val validation = Validation(p1, p2, ... , p22)
  6.     return if (validation.hasFailures) {
  7.         Disjunction.Left(validation.failures)
  8.     } else {
  9.         Disjunction.Right(ifValid(p1.get(), p2.get(), ... , p22.get()))
  10.     }
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement