code: @Override
      public boolean isValid(SpaceForm spaceForm,
                             ConstraintValidatorContext context) {
          try {
              // Test validity by attempting to delete a file that does not exist
              ContentStore contentStore =
                  contentStoreFactory.create(spaceForm.getCredentialsForm(), false);
              String spaceId = spaceForm.getSpaceId();
              String contentId =
                  ".duracloud-dummy-item-" + System.currentTimeMillis();
              contentStore.deleteContent(spaceId, contentId);
              return true;
          } catch (UnauthorizedException e) {
              log.error(e.getMessage(), e);
              context.disableDefaultConstraintViolation();
              context.buildConstraintViolationWithTemplate(constraintAnnotation.message())
                     .addNode("spaceId")
                     .addConstraintViolation();
              return false;
          } catch (NotFoundException ex) {
              return true;
          } catch (Exception ex) {
              throw new RuntimeException("unexpected exception!:" + ex.getMessage(), ex);
          }
      }
docs: /*
  (non-Javadoc)
  
  @see javax.validation.ConstraintValidator#isValid(java.lang.Object,
  javax.validation.ConstraintValidatorContext)