PagePathValidator implements ConstraintValidator<ValidPagePath, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { if (StringUtils.isBlank(value)) { return true; } return Pattern.matches("^" + DocumentrConstants.PAGE_PATH_PATTERN + "$", value); }  @Override void initialize(ValidPagePath annotation); @Override boolean isValid(String value, ConstraintValidatorContext context);  }
@Test public void isValid() { PagePathValidator validator = new PagePathValidator(); assertTrue(validator.isValid(null, null)); assertTrue(validator.isValid(StringUtils.EMPTY, null)); assertTrue(validator.isValid("foo", null)); assertTrue(validator.isValid("foo/bar", null)); assertTrue(validator.isValid("foo,bar", null)); assertFalse(validator.isValid(".foo", null)); assertFalse(validator.isValid("foo/.bar", null)); }