/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package hu.nir.nmail.validators;

import hu.nir.nmail.spring.beans.POP3Data;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

/**
 *
 * @author attila
 */
public class POP3Validator implements Validator {

    public boolean supports(Class clazz) {
        return clazz.equals(POP3Data.class);
    }

    public void validate(Object target, Errors errors) {
        POP3Data pop3Data = (POP3Data) target;
        
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "pop3Host", "required.pop3Host");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "pop3UserName", "required.pop3UserName");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "pop3Password", "required.pop3Password");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "port", "required.port");
    }

}
