https://kotlinlang.org logo
#arrow
Title
r

raulraja

02/06/2019, 3:15 PM
The example uses the encoding @streetsofboston suggest as an ADT:
Copy code
sealed class ValidationError(val msg: String) {
  data class DoesNotContain(val value: String) : ValidationError("Did not contain $value")
  data class MaxLength(val value: Int) : ValidationError("Exceeded length of $value")
  data class NotAnEmail(val reasons: Nel<ValidationError>) : ValidationError("Not a valid email")
}