Created
June 29, 2022 11:51
-
-
Save mustafayigitt/9f7e51aa59355860c49c6eff7c3bc583 to your computer and use it in GitHub Desktop.
Validator.Builder example
This file contains 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
Validator.Builder() | |
.addRules( | |
ValidatableRule.Email("Enter valid mail address"), | |
ValidatableRule.Required("Input is required"), | |
) | |
.addCollector { | |
mBinding.editText.doOnTextChanged { text, _, _, _ -> | |
inputValidator.input = text.toString() | |
} | |
} | |
.onValidate { isValid, errorMessage -> | |
Log.d("Validator", "isValid: $isValid, errorMessage: $errorMessage") | |
mBinding.btnAction.isEnabled = isValid | |
} | |
.build() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment