Skip to content

Instantly share code, notes, and snippets.

@dcampogiani
Created February 11, 2018 21:06
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/0c04304d56f6b27252296297a3490096 to your computer and use it in GitHub Desktop.
Save dcampogiani/0c04304d56f6b27252296297a3490096 to your computer and use it in GitHub Desktop.
fun handleInvalid(errors: Nel<ValidationError>) {
errors.map { handleInvalidField(it) }.all.forEach { it.second.error = it.first }
}
fun handleInvalidField(validationError: ValidationError): Pair<String, TextInputLayout> =
when (validationError) {
ValidationError.InvalidMail -> Pair(getString(R.string.invalid_mail), emailWrapper)
ValidationError.InvalidPhoneNumber -> Pair(getString(R.string.invalid_phone_number), numberWrapper)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment