@Test public void testValidationSuccess() { assertTrue(underTest.isValid("right-format", context)); assertTrue(underTest.isValid("stack0123", context)); assertTrue(underTest.isValid("stack0123stack", context)); }
@Override public boolean isValid(String value, ConstraintValidatorContext context) { Pattern pattern = Pattern.compile("(^[a-z][-a-z0-9]*[a-z0-9]$)"); Matcher matcher = pattern.matcher(value); return matcher.matches(); }
StackNameFormatValidator implements ConstraintValidator<ValidStackNameFormat, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { Pattern pattern = Pattern.compile("(^[a-z][-a-z0-9]*[a-z0-9]$)"); Matcher matcher = pattern.matcher(value); return matcher.matches(); } }
StackNameFormatValidator implements ConstraintValidator<ValidStackNameFormat, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { Pattern pattern = Pattern.compile("(^[a-z][-a-z0-9]*[a-z0-9]$)"); Matcher matcher = pattern.matcher(value); return matcher.matches(); }  }
StackNameFormatValidator implements ConstraintValidator<ValidStackNameFormat, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { Pattern pattern = Pattern.compile("(^[a-z][-a-z0-9]*[a-z0-9]$)"); Matcher matcher = pattern.matcher(value); return matcher.matches(); }  @Override boolean isValid(String value, ConstraintValidatorContext context); }
StackNameFormatValidator implements ConstraintValidator<ValidStackNameFormat, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { Pattern pattern = Pattern.compile("(^[a-z][-a-z0-9]*[a-z0-9]$)"); Matcher matcher = pattern.matcher(value); return matcher.matches(); }  @Override boolean isValid(String value, ConstraintValidatorContext context);  }