Package org.drools.ide.common.client.factconstraints

Examples of org.drools.ide.common.client.factconstraints.ValidationResult


    }

    @Override
    public ValidationResult validate(Object value,
            ConstraintConfiguration config) {
        ValidationResult result = new ValidationResult();

        if (value == null) {
            result.setSuccess(false);
            result.setMessage("The value could not be null"); // TODO: I18N
        } else {
            result.setSuccess(true);
        }

        return result;
    }
View Full Code Here


    public String getVerifierRule(ConstraintConfiguration config) {
        return template.replaceAll("\\{0\\}", String.valueOf(System.nanoTime())).replaceAll("\\{1\\}", config.getFactType()).replaceAll("\\{2\\}", config.getFieldName()).replaceAll("\\{3\\}", this.getMin(config)).replaceAll("\\{4\\}", this.getMax(config));
    }

    public ValidationResult validate(Object value, ConstraintConfiguration config) {
        ValidationResult result = new ValidationResult();

        try {
            if (value == null || !(value instanceof Number || value instanceof String)) {
                result.setSuccess(false);
                if (value == null) {
                    result.setMessage("The value is null"); // TODO: I18N
                } else {
                    result.setMessage("Invalid value type " + value.getClass().getName()); // TODO:
                    // I18N
                }
            } else {
                double min = Double.parseDouble(getMin(config));
                double max = Double.parseDouble(getMax(config));
                double d = Double.parseDouble(value.toString());
                result.setSuccess(d > min && d < max);
                if (!result.isSuccess()) {
                    result.setMessage("The value should be between " + min + " and " + max); // TODO:
                    // I18N
                }
            }
        } catch (Throwable t) {
            result.setSuccess(false);
            result.setMessage(t.getMessage()); // TODO: I18N
        }

        return result;
    }
View Full Code Here

TOP

Related Classes of org.drools.ide.common.client.factconstraints.ValidationResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.