Package org.springmodules.validation.bean.rule

Examples of org.springmodules.validation.bean.rule.DefaultValidationRule


    public void testBeanValidator_WithManualConfiguration() throws Exception {

        // creating the validation configuration for the bean.
        DefaultBeanValidationConfiguration personValidationConfiguration = new DefaultBeanValidationConfiguration();
        personValidationConfiguration.addGlobalRule(new DefaultValidationRule(Conditions.minLength("name", 4), "minLength"));
        personValidationConfiguration.addPropertyRule("name", new DefaultValidationRule(Conditions.minLength("name", 5), "minLength"));
        SimpleBeanValidationConfigurationLoader loader = new SimpleBeanValidationConfigurationLoader();
        loader.setClassValidation(Person.class, personValidationConfiguration);

        BeanValidator validator = new BeanValidator();
        validator.setErrorCodeConverter(new DefaultErrorCodeConverter());
View Full Code Here


        ValangCondition goodCondition = new ValangCondition("tupper(name) == 'URI'", functionsByName, null);
        ValangCondition badCondition = new ValangCondition("tupper(name) == 'Uri'", functionsByName, null);

        // creating the validation configuration for the bean.
        DefaultBeanValidationConfiguration personValidationConfiguration = new DefaultBeanValidationConfiguration();
        personValidationConfiguration.addGlobalRule(new DefaultValidationRule(goodCondition, "good"));
        personValidationConfiguration.addGlobalRule(new DefaultValidationRule(badCondition, "bad"));
        SimpleBeanValidationConfigurationLoader loader = new SimpleBeanValidationConfigurationLoader();
        loader.setClassValidation(Person.class, personValidationConfiguration);

        BeanValidator validator = new BeanValidator(loader);
View Full Code Here

        Condition fieldValueCondition,
        String errorCode,
        String message,
        Object[] args) {

        addPropertyRule(propertyName, new DefaultValidationRule(fieldValueCondition, errorCode, message, args));
    }
View Full Code Here

     * @param errorCode The error code of the added rule.
     * @param message The error message of the added rule.
     * @param args The arguments for the error of the added rule.
     */
    public void addGlobalRule(Condition condition, String errorCode, String message, Object[] args) {
        addGlobalRule(new DefaultValidationRule(condition, errorCode, message, args));
    }
View Full Code Here

     * @param condition The condition of the added rule.
     * @param errorCode The error code of the added rule.
     * @param message The default error message of the added rule.
     */
    public void addGlobalRule(Condition condition, String errorCode, String message) {
        addGlobalRule(new DefaultValidationRule(condition, errorCode, message, new Object[0]));
    }
View Full Code Here

                }
                return Character.isUpperCase(text.charAt(0));
            }
        };
        String propertyName = descriptor.getName();
        DefaultValidationRule rule = new DefaultValidationRule(cond, "is.first.letter.capitalized");
        configuration.addPropertyRule(propertyName, new PropertyValidationRule(propertyName, rule));
    }
View Full Code Here

                    return false;
                }
                return Character.isUpperCase(text.charAt(0));
            }
        };
        DefaultValidationRule rule = new DefaultValidationRule(cond, "is.first.letter.capitalized");
        configuration.addPropertyRule(propertyName, new PropertyValidationRule(propertyName, rule));
    }
View Full Code Here

            message = annotationClass.getSimpleName() + ".error";
        } catch (InvocationTargetException e) {
            message = annotationClass.getSimpleName() + ".error";
        }

        configuration.addPropertyRule(descriptor.getName(), new DefaultValidationRule(condition, message, message, new Object[0]));

    }
View Full Code Here

                    return false;
                }
                return Character.isUpperCase(text.charAt(0));
            }
        };
        DefaultValidationRule rule = new DefaultValidationRule(cond, "is.first.letter.capitalized");
        configuration.addPropertyRule(propertyName, new PropertyValidationRule(propertyName, rule));
    }
View Full Code Here

     * @see #addPropertyRule(String, org.springmodules.validation.util.condition.Condition, String, Object[])
     */
    public void addPropertyRule(String propertyName, Condition fieldValueCondition, String errorCode, String message,
            Object[] args) {

        addPropertyRule(propertyName, new DefaultValidationRule(fieldValueCondition, errorCode, message, args));
    }
View Full Code Here

TOP

Related Classes of org.springmodules.validation.bean.rule.DefaultValidationRule

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.