Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Skyyo
Created August 22, 2021 13:18
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 Skyyo/028795ad56cebc69005e20d46a0bd53a to your computer and use it in GitHub Desktop.
Save Skyyo/028795ad56cebc69005e20d46a0bd53a to your computer and use it in GitHub Desktop.
object InputValidator {
fun getNameErrorIdOrNull(input: String): Int? {
return when {
input.length < 2 -> R.string.name_too_short
//ideally provide different error messages for different errors
else -> null
}
}
fun getCardNumberErrorIdOrNull(input: String): Int? {
return when {
input.length < 16 -> R.string.card_number_too_short
//ideally provide different error messages for different errors
else -> null
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment