diff --git a/src/main/java/de/bstly/board/controller/validation/EntryValidator.java b/src/main/java/de/bstly/board/controller/validation/EntryValidator.java index 5e7f1b9..f860200 100644 --- a/src/main/java/de/bstly/board/controller/validation/EntryValidator.java +++ b/src/main/java/de/bstly/board/controller/validation/EntryValidator.java @@ -20,7 +20,6 @@ public class EntryValidator implements Validator { private UrlValidator urlValidator = new UrlValidator(); - /* * @see org.springframework.validation.Validator#supports(java.lang.Class) */ @@ -29,9 +28,9 @@ public class EntryValidator implements Validator { return clazz.isAssignableFrom(Entry.class); } - /* - * @see org.springframework.validation.Validator#validate(java.lang.Object, org.springframework.validation.Errors) + * @see org.springframework.validation.Validator#validate(java.lang.Object, + * org.springframework.validation.Errors) */ @Override public void validate(Object target, Errors errors) { @@ -42,10 +41,12 @@ public class EntryValidator implements Validator { if (entry.getEntryType() == null) { errors.rejectValue("entrytype", "REQUIRED"); - } else if (EntryType.LINK.equals(entry.getEntryType())) { - if (!StringUtils.hasText(entry.getUrl())) { - errors.rejectValue("url", "REQUIRED"); - } + } else if (EntryType.LINK.equals(entry.getEntryType()) + && !StringUtils.hasText(entry.getUrl())) { + errors.rejectValue("url", "REQUIRED"); + } else if (!EntryType.LINK.equals(entry.getEntryType()) + && !StringUtils.hasText(entry.getText())) { + errors.rejectValue("text", "REQUIRED"); } if (StringUtils.hasText(entry.getUrl()) && !urlValidator.isValid(entry.getUrl())) {