Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore validation if view is gone or invisible #5

Open
oliveiradev opened this issue May 19, 2017 · 4 comments
Open

Ignore validation if view is gone or invisible #5

oliveiradev opened this issue May 19, 2017 · 4 comments

Comments

@oliveiradev
Copy link
Contributor

No description provided.

@nicbell
Copy link

nicbell commented Jun 6, 2017

This would be great.

@manandhar-aarya
Copy link

manandhar-aarya commented Aug 2, 2018

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.

@joneserick
Copy link
Contributor

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

@manandhar-aarya
Copy link

I just did. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants