How to recheck a field in android-saripaar?

I am using android-saripaar library .

I can check all the fields EditTextfor the correctness of the data entered with validate(). If I find an error EditTextwith an error in the correct data, the error does not disappear until I call again validate().

How to check the correctness after entering text only in a specific one EditTextand remove the error from it?

Thank.

+4
source share
1 answer

You can use Saripaar Mode.IMMEDIATEin combination with instances TextWatcherto accomplish what you are looking for.

  • @Order , Saripaar. . , saripaar sequence. sequence , , , .
    @Order(1)
    @NotEmpty(sequence = 1)
    @Email(seqence = 2)
    private EditText mEmailEditText;

    @Order(2)
    @Password
    private EditText mPasswordEditText;
  1. mValidator.setMode(Mode.IMMEDIATE)

  2. TextWatcher/ .

    TextWatcher validationTextWatcher = new TextWatcher() {

        @Override
        void afterTextChanged(Editable s) {
            mValidator.validate();
        }

        // Other methods to override ...
    }

    mEmailEditText.addTextChangedListener(validationTextWatcher);
    mPasswordEditText.addTextChangedListener(validationTextWatcher);
  1. () ViewValidatedAction, EditText, . / , , ViewValidatedAction.
    mValidator.setViewValidatedAction(new ViewValidatedAction() {

        @Override
        void onAllRulesPassed(View view) {
            // ... clear errors based on the view type
        }
    });

: Saripaar

+6

All Articles