code: protected boolean validate(boolean validateEmptyFields) {
          boolean isValid = false;
          String value = dataType == PASSWORD ? getText() : getText().trim();
          if (!validateEmptyFields && value.isEmpty()) {
              return true;
          }
  
          switch (dataType) {
              case TEXT_NAME:
              case NUMBER:
              case PASSWORD:
              case NON_EMPTY_USERNAME:
                  isValid = !value.isEmpty();
                  break;
              case EMAIL:
                  isValid = value.matches(EMAIL_REGEX);
                  break;
              case USERNAME:
                  isValid = value.matches(USERNAME_REGEX) && value.length() >= 1 && value.length() <= 15;
                  break;
              case USERNAME_OR_EMAIL:
                  final boolean validEmail = value.matches(EMAIL_REGEX);
                  final boolean validUsername = value.matches(USERNAME_REGEX) && value.length() >= 1 && value.length() <= 15;
                  isValid = validEmail || validUsername;
                  break;
              case MOBILE_PHONE:
              case PHONE_NUMBER:
                  isValid = value.matches(PHONE_NUMBER_REGEX);
                  break;
              case MFA_CODE:
                  isValid = value.matches(CODE_REGEX);
                  break;
          }
  
          Log.v(TAG, "Field validation results: Is valid? " + isValid);
          return isValid;
      }
docs: Validates the input data and updates the icon. DataType must be set.
  
  @param validateEmptyFields if an empty input should be considered invalid.
  @return whether the data is valid or not.