/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.rjconsultores.ventaboletos.web.utilerias;

import org.zkoss.util.resource.Labels;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.WrongValueException;
import org.zkoss.zul.Constraint;
import org.zkoss.zul.SimpleConstraint;

/**
 *
 * @author Rafius
 */
public class ConstraintEmailOrEmpty implements Constraint {

    public void validate(Component comp, Object value) throws WrongValueException {
        if ((value != null) && (!value.toString().equals(""))) {
            try {
                new SimpleConstraint("/.+@.+\\.[A-Z]+/").validate(comp, value);
            } catch (WrongValueException e) {
                throw new WrongValueException(comp, Labels.getLabel("MSG.emailValido"));
            }
        }
    }
}
