package com.vst.webapp.validators;
import com.vst.model.CompanyLicense;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;
/**
* Created by IntelliJ IDEA.
* User: Администратор
* Date: 06.07.2009
* Time: 17:33:27
* To change this template use File | Settings | File Templates.
*/
public class CompanyLicenseValidator implements Validator {
public boolean supports(Class aClass) {
return CompanyLicense.class.isAssignableFrom(aClass);
}
public void validate(Object o, Errors errors) {
CompanyLicense companyLicense = (CompanyLicense) o;
if ((companyLicense.getPhoto() == null || companyLicense.getPhoto().getFile().length == 0) && companyLicense.getLicenseId() == null) {
errors.rejectValue("photo", "companyLicense.error");
}
}
}