1 package javax.validation;
2
3 import java.util.Set;
4
5 /***
6 * Validate a given object type
7 *
8 */
9 public interface Validator<T> {
10 /***
11 * validate all constraints on object
12 *
13 * @param object
14 * object to validate
15 * @param groups
16 * group name(s) targeted for validation (default to
17 * <code>default</code>)
18 * @return invalid constrains or an empty Set if none
19 * @throws IllegalArgumentException
20 * e if object is null
21 */
22 Set<InvalidConstraint<T>> validate(T object, String... groups);
23
24 /***
25 * validate all constraints on <code>propertyName</code> property of
26 * object
27 *
28 *
29 * @param object
30 * object to validate
31 * @param propertyName
32 * property to validate
33 * @param groups
34 * group name(s) targeted for validation (default to
35 * <code>default</code>)
36 * @return invalid constrains or an empty Set if none
37 * @throws IllegalArgumentException
38 * e if object is null
39 */
40 Set<InvalidConstraint<T>> validateProperty(T object, String propertyName,
41 String... groups);
42
43 /***
44 * validate all constraints on <code>propertyName</code> property if the
45 * property value is <code>value</code>
46 *
47 * TODO express limitations of InvalidConstraint in this case
48 *
49 * @param propertyName
50 * property to validate
51 * @param value
52 * property value to validate
53 * @param groups
54 * group name(s) targeted for validation (default to
55 * <code>default</code>)
56 * @return invalid constrains or an empty Set if none
57 */
58 Set<InvalidConstraint<T>> validateValue(String propertyName, Object value,
59 String... groups);
60
61 /***
62 * return true if at least one constraint declaration is present for the
63 * given bean or if one property is marked for validation cascade
64 */
65 boolean hasConstraints();
66
67 /***
68 * return the class level constraints
69 */
70 ElementDescriptor getBeanConstraints();
71
72 /***
73 * return the property level constraints for a given propertyName or null if
74 * either the property does not exist or has no constraint
75 */
76 ElementDescriptor getConstraintsForProperty(String propertyName);
77
78 /***
79 * return the property names having at least a constraint defined
80 */
81 Set<String> getValidatedProperties();
82 }