@Test public void testValidationFailure() { assertFalse(underTest.isValid("-stack-invalid", context)); assertFalse(underTest.isValid("Astack", context)); assertFalse(underTest.isValid("stack.stack", context)); assertFalse(underTest.isValid("stack_stack", context)); assertFalse(underTest.isValid("stack-", 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);  }