data-binding-validator icon indicating copy to clipboard operation
data-binding-validator copied to clipboard

Ignore validation if view is gone or invisible

Open oliveiradev opened this issue 8 years ago • 4 comments

oliveiradev avatar May 19 '17 11:05 oliveiradev

This would be great.

nicbell avatar Jun 06 '17 10:06 nicbell

Hi, This is an old issue but it might help others in the future.

In the rule, while checking for valid, you can check if the view is visible. If the view is invisible or gone, then return true.

Code sample for EmptyRule: @Override public boolean isValid(TextView view) { //if view is invisible or gone then always return valid boolean isHidden = !(view.getVisibility()== View.VISIBLE); return isHidden || !value || !TextUtils.isEmpty(view.getText()); }

or to apply to all rules, you can add to the isValid function of class Rule<ViewType extends View, ValueType> itself.

manandhar-aarya avatar Aug 02 '18 08:08 manandhar-aarya

@manandhar-aarya Can you submit a pull request with your solution?

joneserick avatar Oct 17 '18 21:10 joneserick

I just did. :)

manandhar-aarya avatar Oct 25 '18 05:10 manandhar-aarya