package nl.quintor.commons.validator;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;

/**
 * Validator for age verification. Through attributes, the valid ages can be customized.
 *  
 * @author Benny Bottema
 */
public class AgeValidator implements Validator {

	/**
	 * Minimum age the birth date should comply to.
	 */
	private Integer min = new Integer(0);

	/**
	 * Maximum age the birth date should comply to.
	 */
	private Integer max = new Integer(120);

	public final void validate(final FacesContext context, final UIComponent component, final Object veldWaarde)
			throws ValidatorException {
		// validate age, or throw a ValidatorException
	}

	/**
	 * Bean setter for maximum age.
	 */
	public void setMax(Integer max) {
		this.max = max;
	}

	/**
	 * Bean setter for minimum age.
	 */
	public void setMin(Integer min) {
		this.min = min;
	}
}
