@Test public void long_value() throws Exception { String label = "My Field"; Field field = mockFieldWithLabel(label); MessageFormatter formatter = mockMessageFormatter(); String value = "Now the student has become the master."; String message = "{message}"; Integer constraint = value.length() - 1; train_format(formatter, message, constraint, label); replay(); MaxLength validator = new MaxLength(null); try { validator.validate(field, constraint, formatter, value); unreachable(); } catch (ValidationException ex) { assertEquals(ex.getMessage(), message); } verify(); }
public void validate(Field field, Integer constraintValue, MessageFormatter formatter, String value) throws ValidationException { if (value.length() > constraintValue) throw new ValidationException(buildMessage(formatter, field, constraintValue)); }
MaxLength extends AbstractValidator<Integer, String> { public void validate(Field field, Integer constraintValue, MessageFormatter formatter, String value) throws ValidationException { if (value.length() > constraintValue) throw new ValidationException(buildMessage(formatter, field, constraintValue)); } }
MaxLength extends AbstractValidator<Integer, String> { public void validate(Field field, Integer constraintValue, MessageFormatter formatter, String value) throws ValidationException { if (value.length() > constraintValue) throw new ValidationException(buildMessage(formatter, field, constraintValue)); } MaxLength(JavaScriptSupport javaScriptSupport); }
MaxLength extends AbstractValidator<Integer, String> { public void validate(Field field, Integer constraintValue, MessageFormatter formatter, String value) throws ValidationException { if (value.length() > constraintValue) throw new ValidationException(buildMessage(formatter, field, constraintValue)); } MaxLength(JavaScriptSupport javaScriptSupport); void validate(Field field, Integer constraintValue, MessageFormatter formatter, String value); void render(Field field, Integer constraintValue, MessageFormatter formatter, MarkupWriter writer,
                       FormSupport formSupport); }
MaxLength extends AbstractValidator<Integer, String> { public void validate(Field field, Integer constraintValue, MessageFormatter formatter, String value) throws ValidationException { if (value.length() > constraintValue) throw new ValidationException(buildMessage(formatter, field, constraintValue)); } MaxLength(JavaScriptSupport javaScriptSupport); void validate(Field field, Integer constraintValue, MessageFormatter formatter, String value); void render(Field field, Integer constraintValue, MessageFormatter formatter, MarkupWriter writer,
                       FormSupport formSupport);  }