MarioAriasC / funKTionale

Functional constructs for Kotlin
915 stars 71 forks source link

Simple validation API #8

Closed loicdescotte closed 7 years ago

loicdescotte commented 8 years ago

Description

Combines several either values to give a global overview of errors without stopping at the first error.

Usage

val e1: Either<String, Int> = Either.Right(1)
val e2: Either<String, Int> = Either.Left("Not a number")
val e3: Either<String, Int> = Either.Right(3)
val e4: Either<String, Int> = Either.Left("Negative value")

val validation = Validation(e1, e2, e3, e4)
assertTrue(validation.hasFailures)
assertEquals(validation.failures, listOf("Not a number", "Negative value"))
MarioAriasC commented 8 years ago

It looks good, let me test it a little bit