@Test public void null_value() { Field field = mockFieldWithLabel("My Field"); MessageFormatter formatter = mockMessageFormatter(); train_format(formatter, "{message}", "My Field"); Html5Support html5Support = mockHtml5Support(); replay(); try { new Required(null, html5Support).validate(field, null, formatter, null); unreachable(); } catch (ValidationException ex) { assertEquals(ex.getMessage(), "{message}"); } verify(); }
public void validate(Field field, Void constraintValue, MessageFormatter formatter, Object value) throws ValidationException { if (value == null || InternalUtils.isEmptyCollection(value) || InternalUtils.isBlank(value.toString())) throw new ValidationException(buildMessage(formatter, field)); }
Required extends AbstractValidator<Void, Object> { public void validate(Field field, Void constraintValue, MessageFormatter formatter, Object value) throws ValidationException { if (value == null || InternalUtils.isEmptyCollection(value) || InternalUtils.isBlank(value.toString())) throw new ValidationException(buildMessage(formatter, field)); } }
Required extends AbstractValidator<Void, Object> { public void validate(Field field, Void constraintValue, MessageFormatter formatter, Object value) throws ValidationException { if (value == null || InternalUtils.isEmptyCollection(value) || InternalUtils.isBlank(value.toString())) throw new ValidationException(buildMessage(formatter, field)); } Required(JavaScriptSupport javaScriptSupport, Html5Support html5Support); }
Required extends AbstractValidator<Void, Object> { public void validate(Field field, Void constraintValue, MessageFormatter formatter, Object value) throws ValidationException { if (value == null || InternalUtils.isEmptyCollection(value) || InternalUtils.isBlank(value.toString())) throw new ValidationException(buildMessage(formatter, field)); } Required(JavaScriptSupport javaScriptSupport, Html5Support html5Support); void validate(Field field, Void constraintValue, MessageFormatter formatter, Object value); boolean isRequired(); void render(Field field, Void constraintValue, MessageFormatter formatter, MarkupWriter writer,
                       FormSupport formSupport); }
Required extends AbstractValidator<Void, Object> { public void validate(Field field, Void constraintValue, MessageFormatter formatter, Object value) throws ValidationException { if (value == null || InternalUtils.isEmptyCollection(value) || InternalUtils.isBlank(value.toString())) throw new ValidationException(buildMessage(formatter, field)); } Required(JavaScriptSupport javaScriptSupport, Html5Support html5Support); void validate(Field field, Void constraintValue, MessageFormatter formatter, Object value); boolean isRequired(); void render(Field field, Void constraintValue, MessageFormatter formatter, MarkupWriter writer,
                       FormSupport formSupport);  }