required fields
This commit is contained in:
parent
45a62b9d54
commit
7e0c292d7c
@ -20,7 +20,6 @@ public class EntryValidator implements Validator {
|
|||||||
|
|
||||||
private UrlValidator urlValidator = new UrlValidator();
|
private UrlValidator urlValidator = new UrlValidator();
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.springframework.validation.Validator#supports(java.lang.Class)
|
* @see org.springframework.validation.Validator#supports(java.lang.Class)
|
||||||
*/
|
*/
|
||||||
@ -29,9 +28,9 @@ public class EntryValidator implements Validator {
|
|||||||
return clazz.isAssignableFrom(Entry.class);
|
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
|
@Override
|
||||||
public void validate(Object target, Errors errors) {
|
public void validate(Object target, Errors errors) {
|
||||||
@ -42,10 +41,12 @@ public class EntryValidator implements Validator {
|
|||||||
|
|
||||||
if (entry.getEntryType() == null) {
|
if (entry.getEntryType() == null) {
|
||||||
errors.rejectValue("entrytype", "REQUIRED");
|
errors.rejectValue("entrytype", "REQUIRED");
|
||||||
} else if (EntryType.LINK.equals(entry.getEntryType())) {
|
} else if (EntryType.LINK.equals(entry.getEntryType())
|
||||||
if (!StringUtils.hasText(entry.getUrl())) {
|
&& !StringUtils.hasText(entry.getUrl())) {
|
||||||
errors.rejectValue("url", "REQUIRED");
|
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())) {
|
if (StringUtils.hasText(entry.getUrl()) && !urlValidator.isValid(entry.getUrl())) {
|
||||||
|
Loading…
Reference in New Issue
Block a user