vekexasia / android-edittext-validator

Android form edit text is an extension of EditText that brings data validation facilities to the edittext.
MIT License
1.45k stars 378 forks source link

two column of one has filled validation #41

Closed AnnShih closed 6 years ago

AnnShih commented 8 years ago

I just write

public class HasOneFilledValidator extends Validator { private final EditText otherEditText;

    public HasOneFilledValidator(EditText otherEditText, String errorMessage) {
        super(errorMessage);
        this.otherEditText = otherEditText;
    }

    @Override
    public boolean isValid(EditText editText) {
        return (TextUtils.getTrimmedLength(editText.getText()) > 0 || TextUtils.getTrimmedLength(otherEditText.getText())) > 0;
    }

}

and use AA.addValidator(new HasOneFilledValidator(BB, "test")); but it doen't run isValid... What did I missed?

vekexasia commented 8 years ago

did you call testValidity?

AnnShih commented 8 years ago

I celled testValidty but get empty error message instead of the message I want... What testType should I set?

AnnShih commented 8 years ago

I got error_field_must_not_be_empty message but I don't want it check empty for me... If I use AA.addValidator(new HasOneFilledValidator(BB, "test")) and filled BB, then I will get AA's empty error, but I want one of them has filled can be true.

vekexasia commented 8 years ago

Hello @AnnShih did you solve this?