Last active
January 3, 2021 08:06
-
-
Save lucapiccinelli/b094810ea1014fd81634059236d2b1ee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed class Email(val value: String){ | |
data class Verified(private val email: Unverified): Email(email.value) | |
class Unverified private constructor(value: String): Email(value){ | |
companion object{ | |
fun of(value: String): Result<Email.Unverified> = valikate { | |
validate(Email.Unverified(value)){ | |
validate(Email.Unverified::value).isEmail() | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment