Skip to content

Instantly share code, notes, and snippets.

@ababup1192
Created December 18, 2019 14:27
Show Gist options
  • Save ababup1192/268e137a24fd1e40eb11f03e259c0079 to your computer and use it in GitHub Desktop.
Save ababup1192/268e137a24fd1e40eb11f03e259c0079 to your computer and use it in GitHub Desktop.
case class LastName private (value: String) extends AnyVal
object LastName {
private[this] val maxLength = 32
def apply(value: String): LastName = {
val trimmed = value.trim
require(!trimmed.isEmpty && trimmed.length <= maxLength)
new LastName(trimmed)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment