Hi Gunnar,
I'm not intimately familiar with Apache BVal's custom method
validation module, but from what I can tell at a high level we
likewise have no special handling for getter methods. When I spoke of
implementation-specific mechanisms for ignoring these (or, more
generally, any pattern the user might like to configure), I thought
more along the lines of the integration modules responsible for
actually invoking methods of MethodValidator (which Apache BVal does
not provide).
br,
Matt
On Fri, Oct 26, 2012 at 12:31 PM, Gunnar Morling <gunnar(a)hibernate.org> wrote:
Hi,
I think getters should be handled as any other methods during method validation.
Not considering them during method validation would IMO be some form
irregularity, causing getter-named methods not to be validated
although a user might expect it:
//subject to method validation
public class OrderService {
//not validated upon invocation
@NotNull
List<Order> getAllOrders() { ... }
//validated upon invocation
@NotNull
Order findOrderById(long id) { ... }
}
I'd also expect that in many cases different types/objects are subject
to method validation than to validation of property-level constraints.
IMO the former typically applies more on a service level (e.g. via
CDI), while the latter typically applies to model objects/bean (e.g.
via JPA), so maybe there is not really a big area of overlap.
Things of course change a bit when taking technologies such as AspectJ
into account which could apply a method validation interceptor to any
kind of object. But also then I'd say a validation of getter
(property) constraints during method validation shouldn't do any harm.
One could still make use of validation groups to control which
constraints are to be applied.
Maybe we could even consider providing a mechanism to optionally apply
getter constraints upon invocation of the corresponding setter to
avoid storing illegal parameter values in the first place?
@Matt: How is it in Apache Validation, are there any mechanisms to
control the exact behavior? In HV, getters are handled as any other
methods.
--Gunnar
2012/10/26 Emmanuel Bernard <emmanuel(a)hibernate.org>:
> Any other input? Gunnar and Hardy you had some thoughts on the subject
> afair :)
>
> Emmanuel
>
> On Tue 2012-10-23 12:37, Matt Benson wrote:
>> On Tue, Oct 23, 2012 at 12:19 PM, Emmanuel Bernard
>> <emmanuel(a)hibernate.org> wrote:
>> > For method validation, we have so far managed to get away with
>> > requiring an annotation based metadata to direct how method validation
>> > behaves.
>> >
>> > One question that popped up during the recent write up is whether or not
>> > getters should be considered regular methods and thus be intercepted and
>> > validation by CDI or AspectJ interceptors.
>> >
>> > I have my own ideas, but I'd like to get your opinion on the subject.
>>
>> Hi, Emmanuel! Great/horrible question. :)
>>
>> My inclination, for the purposes of the specification, is "a method is
>> a method" but I'd hope to see implementation-specific mechanisms to
>> globally disable method validation on getters.
>>
>> $0.02,
>> Matt
>>
>> >
>> > Emmanuel
>> > _______________________________________________
>> > beanvalidation-dev mailing list
>> > beanvalidation-dev(a)lists.jboss.org
>> >
https://lists.jboss.org/mailman/listinfo/beanvalidation-dev
>> _______________________________________________
>> beanvalidation-dev mailing list
>> beanvalidation-dev(a)lists.jboss.org
>>
https://lists.jboss.org/mailman/listinfo/beanvalidation-dev
> _______________________________________________
> beanvalidation-dev mailing list
> beanvalidation-dev(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/beanvalidation-dev
_______________________________________________
beanvalidation-dev mailing list
beanvalidation-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/beanvalidation-dev