@Test public void isValid() { ProjectNameValidator validator = new ProjectNameValidator(); assertTrue(validator.isValid(null, null)); assertTrue(validator.isValid(StringUtils.EMPTY, null)); assertTrue(validator.isValid("project", null)); assertTrue(validator.isValid("My-Project_123", 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.PROJECT_NAME_PATTERN + "$", value); }
ProjectNameValidator implements ConstraintValidator<ValidProjectName, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { if (StringUtils.isBlank(value)) { return true; } return Pattern.matches("^" + DocumentrConstants.PROJECT_NAME_PATTERN + "$", value); } }
ProjectNameValidator implements ConstraintValidator<ValidProjectName, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { if (StringUtils.isBlank(value)) { return true; } return Pattern.matches("^" + DocumentrConstants.PROJECT_NAME_PATTERN + "$", value); }  }
ProjectNameValidator implements ConstraintValidator<ValidProjectName, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { if (StringUtils.isBlank(value)) { return true; } return Pattern.matches("^" + DocumentrConstants.PROJECT_NAME_PATTERN + "$", value); }  @Override void initialize(ValidProjectName annotation); @Override boolean isValid(String value, ConstraintValidatorContext context); }
ProjectNameValidator implements ConstraintValidator<ValidProjectName, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { if (StringUtils.isBlank(value)) { return true; } return Pattern.matches("^" + DocumentrConstants.PROJECT_NAME_PATTERN + "$", value); }  @Override void initialize(ValidProjectName annotation); @Override boolean isValid(String value, ConstraintValidatorContext context);  }