@Test public void testValidURI() { URIValidator validator = new URIValidator(); Assert.assertTrue(validator.isValid("/vmfs/1234", context)); }
@Override public boolean isValid(String value, ConstraintValidatorContext context) { try { new java.net.URI(value); } catch (Exception ex) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate(String.format("%s is invalid URI: %s", value, ex.getMessage())) .addConstraintViolation(); return false; } return true; }
URIValidator implements ConstraintValidator<URI, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { try { new java.net.URI(value); } catch (Exception ex) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate(String.format("%s is invalid URI: %s", value, ex.getMessage())) .addConstraintViolation(); return false; } return true; } }
URIValidator implements ConstraintValidator<URI, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { try { new java.net.URI(value); } catch (Exception ex) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate(String.format("%s is invalid URI: %s", value, ex.getMessage())) .addConstraintViolation(); return false; } return true; } @Inject  URIValidator(); }
URIValidator implements ConstraintValidator<URI, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { try { new java.net.URI(value); } catch (Exception ex) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate(String.format("%s is invalid URI: %s", value, ex.getMessage())) .addConstraintViolation(); return false; } return true; } @Inject  URIValidator(); @Override void initialize(URI constraintAnnotation); @Override boolean isValid(String value, ConstraintValidatorContext context); }
URIValidator implements ConstraintValidator<URI, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { try { new java.net.URI(value); } catch (Exception ex) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate(String.format("%s is invalid URI: %s", value, ex.getMessage())) .addConstraintViolation(); return false; } return true; } @Inject  URIValidator(); @Override void initialize(URI constraintAnnotation); @Override boolean isValid(String value, ConstraintValidatorContext context);  }