Exemple #1
0
  /**
   * Validate a specific EditText.
   *
   * @param editText EditText
   * @param validable Validable
   */
  private void validate(EditText editText, Validable validable) {
    validable.setValidated(true);
    for (ValidatorType validatorType : validable.getValidatorTypes()) {
      if (!validatorType.validate(editText.getEditableText().toString())) {
        if (showErrors) {
          editText.setError(validatorType.getErrorMessage(context));
        }
        validable.setValidated(false);
        break;
      }
    }

    if (validable.isValidated()) {
      editText.setError(null);
    }

    if (onValidationChanged != null) {
      onValidationChanged.onComplete();
    }
  }
Exemple #2
0
 /**
  * Setter of onValidationChanged.
  *
  * @param onValidationChanged onValidationChanged
  */
 public void setOnValidationChanged(CallbackListener onValidationChanged) {
   this.onValidationChanged = onValidationChanged;
   onValidationChanged.onComplete();
 }