Hi all,
Another question with respect to method validation:
Constraints at JavaBean getter methods can be interpreted as
property-level bean constraint but also as method-level return value
constraint. So they would be validated when calling
Validator#validate() for the bean, but also when performing
method-level validation when the getter is invoked by some code and
the bean is enabled for method validation.
My question is whether we need a way to further control the behavior
here. In HV 4.2 getter constraints are considered in both cases, I
think in OVal there is some way to specify the intended behavior.
Possible options could be:
#1 Handle getter constraints as property as well as return value
constraints, don't provide means of configuration
#2 Have an attribute in @MethodValidated (a.k.a. @ValidateGroups),
e.g. use validationMode
#3 Provide a dedicated annotation, e.g. @IgnoreForMethodValidation
(handling getter constraints as property-level constraints needs to be
the default to be compatible with current behavior)
#4 Have a global option in bootstrap API, ValidatorFactory or Validator
Personally I tend to think that #1 is enough, I don't really see the
need for further configuration. Plus, validation groups could also be
used. Any thoughts?
--Gunnar
Show replies by date