Double Validation with different Error String
regifr opened this issue · 3 comments
regifr commented
can I use two or more validator in one TextInputLayout
validator.addValidation(this, R.id.tilEmail, RegexTemplate.NOT_EMPTY, R.string.err_email_null); validator.addValidation(this, R.id.tilEmail, Patterns.EMAIL_ADDRESS, R.string.err_email);
while the tilEmail is EMPTY the error just showing Patterns.EMAIL_ADDRESS with err_email not err_email_null
thyrlian commented
- Yes, it doesn't support multiple validations on one field. So in your case, the new one will overwrite the old one.
- The idea is to wrap all validation rules into one Regex, and bind it with a field. And I've confirmed,
Patterns.EMAIL_ADDRESS
has already included validation for empty input. Thus you don't needRegexTemplate.NOT_EMPTY
.