@Test public void isValid() { BranchNameValidator validator = new BranchNameValidator(); assertTrue(validator.isValid(null, null)); assertTrue(validator.isValid(StringUtils.EMPTY, null)); assertTrue(validator.isValid("branch", null)); assertTrue(validator.isValid("My-Branch_1.2.3", null)); assertFalse(validator.isValid("1,2,3", null)); }
@Override public boolean isValid(String value, ConstraintValidatorContext context) { if (StringUtils.isBlank(value)) { return true; } return Pattern.matches("^" + DocumentrConstants.BRANCH_NAME_PATTERN + "$", value); }
BranchNameValidator implements ConstraintValidator<ValidBranchName, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { if (StringUtils.isBlank(value)) { return true; } return Pattern.matches("^" + DocumentrConstants.BRANCH_NAME_PATTERN + "$", value); } }
BranchNameValidator implements ConstraintValidator<ValidBranchName, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { if (StringUtils.isBlank(value)) { return true; } return Pattern.matches("^" + DocumentrConstants.BRANCH_NAME_PATTERN + "$", value); }  }
BranchNameValidator implements ConstraintValidator<ValidBranchName, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { if (StringUtils.isBlank(value)) { return true; } return Pattern.matches("^" + DocumentrConstants.BRANCH_NAME_PATTERN + "$", value); }  @Override void initialize(ValidBranchName annotation); @Override boolean isValid(String value, ConstraintValidatorContext context); }
BranchNameValidator implements ConstraintValidator<ValidBranchName, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { if (StringUtils.isBlank(value)) { return true; } return Pattern.matches("^" + DocumentrConstants.BRANCH_NAME_PATTERN + "$", value); }  @Override void initialize(ValidBranchName annotation); @Override boolean isValid(String value, ConstraintValidatorContext context);  }