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
| fun TextInputEditText.isNotNullOrEmpty(errorString: String): Boolean { | |
| val textInputLayout = this.parent.parent as TextInputLayout | |
| textInputLayout.errorIconDrawable = null | |
| this.onChange { textInputLayout.error = null } | |
| return if (this.text.toString().trim().isEmpty()) { | |
| textInputLayout.error = errorString | |
| false | |
| } else { | |
| true |
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
| if(TextInputEditText.isNotNullOrEmpty("This field is required") and | |
| (TextInputEditText.isNotNullOrEmpty("This field is required")) { | |
| //this will be executed only if the TextInputEditText contains | |
| // some text else error will be displayed by the extension function itself | |
| } |