Skip to content

Instantly share code, notes, and snippets.

@dcampogiani
Created February 11, 2018 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcampogiani/4f4221b3f149448feddb47234f0edbf2 to your computer and use it in GitHub Desktop.
Save dcampogiani/4f4221b3f149448feddb47234f0edbf2 to your computer and use it in GitHub Desktop.
fun String.validatedMail(): Validated<Nel<ValidationError>, String> =
when {
validMail(this) -> this.valid()
else -> ValidationError.InvalidMail.nel().invalid()
}
fun String.validatedPhoneNumber(): Validated<Nel<ValidationError>, String> =
when {
validNumber(this) -> this.valid()
else -> ValidationError.InvalidPhoneNumber.nel().invalid()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment