@Override
    public void validate(IValidatable<String> validatable) {
      String vcName = validatable.getValue();

      final CoverageStoreInfo store = getCatalog().getStore(storeId, CoverageStoreInfo.class);
      List<CoverageInfo> coverages = getCatalog().getCoveragesByCoverageStore(store);
      for (CoverageInfo curr : coverages) {
        CoverageView currvc =
            curr.getMetadata().get(CoverageView.COVERAGE_VIEW, CoverageView.class);
        if (currvc != null) {
          if (coverageInfoId == null || !coverageInfoId.equals(curr.getId())) {
            if (currvc.getName().equals(vcName) && newCoverage) {
              Map<String, Object> map = new HashMap<>();
              map.put("name", vcName);
              map.put("coverageName", curr.getName());
              IValidationError err =
                  new ValidationError("duplicateCoverageViewName")
                      .addKey("duplicateCoverageViewName")
                      .setVariables(map);
              validatable.error(err);
              return;
            }
          }
        }
      }
    }
Пример #2
0
    @Override
    public void validate(IValidatable<String> validatable) {
      String username = validatable.getValue();
      String orgUsername = ((UserManageBackingBean) getDefaultModelObject()).getOriginalUsername();

      if ((StringUtils.isNotBlank(orgUsername)
          && !username.equalsIgnoreCase(orgUsername)
          && userService.getUser(username) != null)) {
        validatable.error(new ValidationError("admin.user.errorUsernameExists"));
      }
    }
 public void validate(final IValidatable<Z> validatable) {
   final Z value = validatable.getValue();
   final Z min = this.getMinimum();
   final Z max = this.getMaximum();
   if ((min != null && ((Comparable) value).compareTo(min) < 0)
       || (max != null && ((Comparable) value).compareTo(max) > 0)) {
     final ValidationError error = new ValidationError();
     error.addMessageKey(this.resourceKey());
     if (min != null) {
       error.setVariable("minimum", min);
     }
     if (max != null) {
       error.setVariable("maximum", max);
     }
     validatable.error(error);
   }
 }
    @Override
    public void validate(IValidatable validatable) {
      // logger.debug("in validate");
      if (validatable != null
          && buttonAction.equals(BUTTON_ACTION.SUBMIT)
          && StringUtils.isEmpty((String) validatable.getValue())) {

        // logger.debug("hit error " + buttonAction);

        validatable.error(
            new IValidationError() {
              @Override
              public String getErrorMessage(IErrorMessageSource messageSource) {
                return message;
              }
            });
      }
    }
 private void error(IValidatable<String> validatable, String errorKey) {
   ValidationError error = new ValidationError();
   error.addKey(getClass().getSimpleName() + "." + errorKey);
   error.setMessage(errorKey);
   validatable.error(error);
 }
 @Override
 public void validate(IValidatable<T> validatable) {
   if (!predicate.apply(validatable.getValue())) {
     validatable.error(decorate(new ValidationError(this)));
   }
 }