package com.rjconsultores.ventaboletos.web.utilerias;

import java.math.BigDecimal;
import org.zkoss.util.resource.Labels;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.WrongValueException;
import org.zkoss.zul.Constraint;

/**
 *
 * @author Claudio
 */
public class ConstraintDecimalBoxNumberValid implements Constraint {

    public void validate(Component comp, Object value) throws WrongValueException {
		try {
			new BigDecimal(value.toString().replace(".", "").replace(",", "."));
		} catch (NumberFormatException e) {
			throw new WrongValueException(comp,
					Labels.getLabel("MSG.CONSTRAINT.DECIMALBOXISNOTANUMBER"));
		} catch (NullPointerException e) {
			throw new WrongValueException(comp,
					Labels.getLabel("MSG.CONSTRAINT.DECIMALBOXISNOTANUMBER"));
		}
    }
}
