Skip to content

Instantly share code, notes, and snippets.

@lucapiccinelli
Last active January 3, 2021 16:07
Show Gist options
  • Save lucapiccinelli/c154f871dcfc09e5ace0d37ce15807a2 to your computer and use it in GitHub Desktop.
Save lucapiccinelli/c154f871dcfc09e5ace0d37ce15807a2 to your computer and use it in GitHub Desktop.
data class ContactInfo(
val name: PersonalName,
val email: Email)
data class PersonalName(
val firstname: NotEmptyString,
val middleInitial: NotEmptyString?,
val lastname: NotEmptyString){
... // construction code here
}
sealed class Email(val value: String){
data class Verified(private val email: Unverified): Email(email.value)
class Unverified private constructor(value: String): Email(value){
... // construction code here
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment