@Test public void matching_pattern() throws Exception { Field field = mockField(); MessageFormatter formatter = mockMessageFormatter(); Pattern constraint = Pattern.compile("\\d{4}"); replay(); Regexp validator = new Regexp(null); validator.validate(field, constraint, formatter, "1234"); verify(); }
public void validate(Field field, Pattern constraintValue, MessageFormatter formatter, String value) throws ValidationException { Matcher matcher = constraintValue.matcher(value); if (!matcher.matches()) throw new ValidationException(buildMessage(formatter, field, constraintValue)); }
Regexp extends AbstractValidator<Pattern, String> { public void validate(Field field, Pattern constraintValue, MessageFormatter formatter, String value) throws ValidationException { Matcher matcher = constraintValue.matcher(value); if (!matcher.matches()) throw new ValidationException(buildMessage(formatter, field, constraintValue)); } }
Regexp extends AbstractValidator<Pattern, String> { public void validate(Field field, Pattern constraintValue, MessageFormatter formatter, String value) throws ValidationException { Matcher matcher = constraintValue.matcher(value); if (!matcher.matches()) throw new ValidationException(buildMessage(formatter, field, constraintValue)); } Regexp(JavaScriptSupport javaScriptSupport); }
Regexp extends AbstractValidator<Pattern, String> { public void validate(Field field, Pattern constraintValue, MessageFormatter formatter, String value) throws ValidationException { Matcher matcher = constraintValue.matcher(value); if (!matcher.matches()) throw new ValidationException(buildMessage(formatter, field, constraintValue)); } Regexp(JavaScriptSupport javaScriptSupport); void render(Field field, Pattern constraintValue, MessageFormatter formatter, MarkupWriter writer,
                       FormSupport formSupport); void validate(Field field, Pattern constraintValue, MessageFormatter formatter, String value); }
Regexp extends AbstractValidator<Pattern, String> { public void validate(Field field, Pattern constraintValue, MessageFormatter formatter, String value) throws ValidationException { Matcher matcher = constraintValue.matcher(value); if (!matcher.matches()) throw new ValidationException(buildMessage(formatter, field, constraintValue)); } Regexp(JavaScriptSupport javaScriptSupport); void render(Field field, Pattern constraintValue, MessageFormatter formatter, MarkupWriter writer,
                       FormSupport formSupport); void validate(Field field, Pattern constraintValue, MessageFormatter formatter, String value);  }