1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springmodules.validation.bean.conf;
18
19 import org.springframework.validation.Validator;
20 import org.springmodules.validation.bean.rule.ValidationRule;
21
22 /**
23 * Holds the various validatoin rules of a bean. This configuration is made out of the following configuration rules:
24 * <ul>
25 * <li>
26 * <code>Global Rules</code> - Rules that are associated with the bean itself. Validation error of this rule will
27 * be associated with the bean as well (see {@link org.springframework.validation.Errors#getGlobalError()}).
28 * </li>
29 * <li>
30 * <code>Property Rules</code> - Rules that are associated with a specific property of the bean. Validation error
31 * of this rule will be associated with the property as well
32 * (see {@link org.springframework.validation.Errors#getFieldError(String)}). Note that the condition of these
33 * rules however sould still be applied on the bean itself.
34 * </li>
35 * <li>
36 * <code>Custom Validator</code> - This is not a validation rule per se, but a custom validator that can be
37 * associated with the bean. This enables associating already exsiting or perhaps very complex validators with
38 * the bean.
39 * </li>
40 * <li>
41 * <code>Required Validatable Properties</code> - These are all the bean properties that need to be valid on their
42 * own in order for the bean itself to be valid. A simple example can be a collection property, where in order
43 * for the bean to be valid, all elements in the collection need to be valid as well.
44 * </li>
45 * </ul>
46 *
47 * @author Uri Boness
48 */
49 public interface BeanValidationConfiguration {
50
51 /**
52 * Returns the global validation rules for the bean. This method never returns <code>null</code>. If no global rule
53 * is defined, an empty array is returned.
54 *
55 * @return The global validation rules for the bean.
56 */
57 ValidationRule[] getGlobalRules();
58
59 /**
60 * Returns the property validation rules for the bean that are associated with the given property name. This method
61 * never returns <code>null</code>. If no rule is associated with the given property, an empty array is returned.
62 *
63 * @param propertyName The name of the bean property.
64 * @return The property validation rules for the bean.
65 */
66 ValidationRule[] getPropertyRules(String propertyName);
67
68 /**
69 * Returns a list of all properties that are associated with validation rules.
70 *
71 * @return A list of all properties that are associated with validation rules.
72 */
73 String[] getValidatedProperties();
74
75 /**
76 * Returns the custom validator associated with this configuration, <code>null</code> if no custom validator
77 * is associated.
78 *
79 * @return The customer validator associated with this configuration.
80 */
81 Validator getCustomValidator();
82
83 /**
84 * Returns the configured cascade validations.
85 *
86 * @return The configured cascade validations.
87 */
88 CascadeValidation[] getCascadeValidations();
89
90 }