Package org.springmodules.validation.bean.rule

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


     *
     * @param propertyName The name of the property associated with the added rule.
     * @param propertyRule The rule that should be applied on the value of the given property.
     */
    public void addPropertyRule(String propertyName, ValidationRule propertyRule) {
        addPropertyGlobalRule(propertyName, new PropertyValidationRule(propertyName, propertyRule));
    }
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 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

        configuration.addCascadeValidation(new CascadeValidation("name"));
        registryControl.expectAndReturn(registry.findPropertyHandler(ruleDefinition, TestBean.class, descriptor), propertyHandler);
        propertyHandler.handle(ruleDefinition, "name", configuration);

        final PropertyValidationRule propertyRule = new PropertyValidationRule("name", rule);
        loader = new DefaultXmlBeanValidationConfigurationLoader(registry) {
            protected PropertyValidationRule createPropertyRule(String propertyName, ValidationRule rule) {
                return propertyRule;
            }
        };
View Full Code Here

        // handling nullability only if more explicit validation annotations do not exit.
        if (!contains(annotations, NotNull.class) &&
            (!LibraryUtils.HIBERNATE_VALIDATOR_IN_CLASSPATH || !contains(annotations, org.hibernate.validator.NotNull.class))) {
            if (!oneToOne.optional()) {
                PropertyValidationRule propertyRule = new PropertyValidationRule(descriptor.getName(), new NotNullValidationRule());
                configuration.addPropertyRule(descriptor.getName(), propertyRule);
            }
        }

    }
View Full Code Here

        // handling nullability only if more explicit validation annotations do not exit.
        if (!contains(annotations, NotNull.class) &&
            (!LibraryUtils.HIBERNATE_VALIDATOR_IN_CLASSPATH || !contains(annotations, org.hibernate.validator.NotNull.class))) {
            if (!basic.optional()) {
                PropertyValidationRule propertyRule = new PropertyValidationRule(descriptor.getName(), new NotNullValidationRule());
                configuration.addPropertyRule(descriptor.getName(), propertyRule);
            }
        }

    }
View Full Code Here

        }

        if (isConditionGloballyScoped(element)) {
            configuration.addPropertyRule(propertyName, rule);
        } else {
            PropertyValidationRule propertyRule = new PropertyValidationRule(propertyName, rule);

            // By definition, the applicability condition should be evaluated on the validated bean and not on the
            // validated bean property. Thus we need to explicitely set the applicability condition on the validation
            // rule otherwise the default applicability condition to be evaluated on the property value.
            if (applicabilityCondition != null) {
                propertyRule.setApplicabilityCondition(applicabilityCondition);
            }

            if (applicableContexts != null) {
                propertyRule.setContextTokens(applicableContexts);
            }

            configuration.addPropertyRule(propertyName, propertyRule);
        }
View Full Code Here

        // handling max length only if other explicit validation annotations do not exist and if the property is a string.
        if (String.class == descriptor.getPropertyType() &&
            (!LibraryUtils.HIBERNATE_VALIDATOR_IN_CLASSPATH || !contains(annotations, org.hibernate.validator.Length.class))) {
            int length = column.length();
            PropertyValidationRule propertyRule = new PropertyValidationRule(descriptor.getName(), new MaxLengthValidationRule(length));
            configuration.addPropertyRule(descriptor.getName(), propertyRule);
        }

        // handling nullability only if other explicit validation annotations do not exist.
        if (!contains(annotations, NotNull.class) &&
            (!LibraryUtils.HIBERNATE_VALIDATOR_IN_CLASSPATH || !contains(annotations, org.hibernate.validator.NotNull.class))) {
            if (!column.nullable()) {
                PropertyValidationRule propertyRule = new PropertyValidationRule(descriptor.getName(), new NotNullValidationRule());
                configuration.addPropertyRule(descriptor.getName(), propertyRule);
            }
        }

    }
View Full Code Here

        // handling nullability only if more explicit validation annotations do not exit.
        if (!contains(annotations, NotNull.class) &&
            (!LibraryUtils.HIBERNATE_VALIDATOR_IN_CLASSPATH || !contains(annotations, org.hibernate.validator.NotNull.class))) {
            if (!manyToOne.optional()) {
                PropertyValidationRule propertyRule = new PropertyValidationRule(descriptor.getName(), new NotNullValidationRule());
                configuration.addPropertyRule(descriptor.getName(), propertyRule);
            }
        }

    }
View Full Code Here

            handler.handle(ruleDefinition, propertyName, configuration);
        }
    }

    protected PropertyValidationRule createPropertyRule(String propertyName, ValidationRule rule) {
        return new PropertyValidationRule(propertyName, rule);
    }
View Full Code Here

TOP

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

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.