FormLab.kt
  1. 1sealed interface Check {
  2. 2 data class Ok(val email: String) : Check
  3. 3 data class Reason(val message: String) : Check
  4. 4}
  5. 5
  6. 6fun checkEmail(raw: String): Check {
  7. 7 val email = raw.trim()
  8. 8 if (!email.contains("@")) return Check.Reason("Need a full address")
  9. 9 return Check.Ok(email)
  10. 10}

A form that keeps null visible

An email field starts empty. Empty and null are not the same mistake.

Danville · educational · 2018AboutDeskFAQOffice