Created
April 10, 2018 15:19
-
-
Save adrianhall/3cf7f28d6a73cba193c59cad2d98c35b to your computer and use it in GitHub Desktop.
Potential Kotlin code for content validation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
field.addTextChangeListener(object: TextWatcher { | |
override fun afterTextChanged(s: Editable?) { | |
val content = s?.text.toString() | |
s?.error = if (content.length >= 6) null else "Minimum length = 6" | |
} | |
override fun beforeTextChanged(s: Editable?) { } | |
override fun onTextChanged(s: Editable?) { } | |
}) | |
field.error = if (field.text.toString().length >= 6) null else "Minimum length = 6" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment