public boolean supports(Class aClass) {
return AddFeedSubscriptionView.class.isAssignableFrom(aClass);
}
public void validate(Object object, Errors errors) {
AddFeedSubscriptionView view = (AddFeedSubscriptionView) object;
if (view.getName() == null || view.getName().equals("")) {
errors.rejectValue("name", "subscription.empty.name", "Empty name.");
}
if (view.getFeedUrl() == null) {
errors.rejectValue("feedUrl", "subscription.empty.url", "Empty feed URL.");
} else {
try {
URL url = new URL(view.getFeedUrl());
} catch (MalformedURLException ex) {
errors.rejectValue("feedUrl", "subscription.malformed.url", "Malformed URL.");
}
}
}