Skip to content

Instantly share code, notes, and snippets.

@NthPortal
Created September 27, 2017 06:18
Show Gist options
  • Save NthPortal/37f91d725ba96d1b09e0fcc076f09566 to your computer and use it in GitHub Desktop.
Save NthPortal/37f91d725ba96d1b09e0fcc076f09566 to your computer and use it in GitHub Desktop.
case class User(id: User.Id, firstName: User.FirstName, lastName: User.LastName, email: User.Email)
object User {
opaque type Id = Long
object Id {
def apply(value: Long): Id = value
implicit class Ops(val self: Id) extends AnyVal {
def value: Long = self
}
}
opaque type FirstName = String
object FirstName {
def apply(value: String): FirstName = value
implicit class Ops(val self: FirstName) extends AnyVal {
def value: String = self
}
}
opaque type LastName = String
object LastName {
def apply(value: String): LastName = value
implicit class Ops(val self: LastName) extends AnyVal {
def value: String = self
}
}
opaque type Email = String
object Email {
def apply(value: String): Email = value
implicit class Ops(val self: Email) extends AnyVal {
def value: String = self
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment