BranchNameBlacklistValidator implements ConstraintValidator<BranchNameNotBlacklisted, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { if (StringUtils.isBlank(value)) { return true; } return !Pattern.matches("^" + DocumentrConstants.BRANCH_NAMES_BLACKLIST_PATTERN + "$", value); }  @Override void initialize(BranchNameNotBlacklisted annotation); @Override boolean isValid(String value, ConstraintValidatorContext context);  }
@Test public void isValid() { BranchNameBlacklistValidator validator = new BranchNameBlacklistValidator(); assertTrue(validator.isValid(null, null)); assertTrue(validator.isValid(StringUtils.EMPTY, null)); assertTrue(validator.isValid("branch", null)); assertFalse(validator.isValid("_branch", null)); assertFalse(validator.isValid(".branch", null)); }