Package org.springmodules.validation.bean.conf

Examples of org.springmodules.validation.bean.conf.DefaultBeanValidationConfiguration


public class BeanValidatorIntegrationTests extends TestCase {

    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


        functionsByName.put("tupper", UpperCaseFunction.class.getName());
        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

     *
     * @param clazz The class to which the validation configuration should be created.
     * @return The newly created {@link BeanValidationConfiguration}.
     */
    protected BeanValidationConfiguration createValidationConfiguration(Class clazz) {
        MutableBeanValidationConfiguration configuration = new DefaultBeanValidationConfiguration();
        handleClassAnnotations(clazz, configuration);
        handlePropertyAnnotations(clazz, configuration);
        return configuration;
    }
View Full Code Here

public class BeanValidatorIntegrationTests extends TestCase {

    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 ModelAwareErrorCodeConverter());
View Full Code Here

     * @param element The <class> element.
     * @return The created bean validation configuration.
     */
    public BeanValidationConfiguration handleClassDefinition(Class clazz, Element element) {

        DefaultBeanValidationConfiguration configuration = new DefaultBeanValidationConfiguration();

        NodeList nodes = element.getElementsByTagNameNS(DEFAULT_NAMESPACE_URL, VALIDATOR_TAG);
        for (int i=0; i<nodes.getLength(); i++) {
            Element validatorDefinition = (Element)nodes.item(i);
            handleValidatorDefinition(validatorDefinition, clazz, configuration);
View Full Code Here

        functionsByName.put("tupper", UpperCaseFunction.class.getName());
        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

     *
     * @param clazz The class to which the validation configuration should be created.
     * @return The newly created {@link BeanValidationConfiguration}.
     */
    protected BeanValidationConfiguration createValidationConfiguration(Class clazz) {
        MutableBeanValidationConfiguration configuration = new DefaultBeanValidationConfiguration();
        handleClassAnnotations(clazz, configuration);
        handlePropertyAnnotations(clazz, configuration);
        handleMethodAnnotations(clazz, configuration);
        return configuration;
    }
View Full Code Here

     * @param clazz The class for which the validation configuration is being loaded.
     * @return The created bean validation configuration.
     */
    public BeanValidationConfiguration handleClassDefinition(Class clazz, Element element) {

        DefaultBeanValidationConfiguration configuration = new DefaultBeanValidationConfiguration();

        NodeList nodes = element.getElementsByTagNameNS(DEFAULT_NAMESPACE_URL, VALIDATOR_TAG);
        for (int i = 0; i < nodes.getLength(); i++) {
            Element validatorDefinition = (Element) nodes.item(i);
            handleValidatorDefinition(validatorDefinition, clazz, configuration);
View Full Code Here

TOP

Related Classes of org.springmodules.validation.bean.conf.DefaultBeanValidationConfiguration

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.