Skip to content

Instantly share code, notes, and snippets.

@AhmedMourad0
Last active September 10, 2020 00:05
Show Gist options
  • Save AhmedMourad0/374ce8b7ca3ee49eeda88c44ccde746d to your computer and use it in GitHub Desktop.
Save AhmedMourad0/374ce8b7ca3ee49eeda88c44ccde746d to your computer and use it in GitHub Desktop.
Code snippets for the `value-based classes and error-handling` Medium article.
data class Password private constructor(val value: String) {
companion object {
fun of(value: String): Password? {
return if (value.isAGoodPassword()) Password(value) else null
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment