[bv-dev] Should getters be considered methods during validation

Hardy Ferentschik hardy at hibernate.org
Fri Nov 9 05:13:10 EST 2012


I have to back up Gunnar on this one on all counts :-)

On 9 Jan 2012, at 10:13 AM, Gunnar Morling wrote:

> Generally I don't think that considering getters during method validation really is a problem. So I wouldn't really have a problem with this being the default behavior (which it also is in the proprietary API in HV 4.3). I'd prefer that over excluding certain named methods from method validation as this goes against the principle of least surprise and would feel like an inconsistency to me.

+1

> But if validating getters during method validation really is a problem, I'd expect this to be the case generally throughout an application or system. Taking the example of JPA entities which used to be validated upon persisting only and now would their property constraints get validated upon getter invocation, then I'd prefer to disable getter validation globally instead of marking each individual property with an annotation.

+1

> If I as a user really needed a configuration per element, I could do so using validation groups. If for instance single constraints should not be validated upon getter invocation, I could use a group like this:

+1 

Are not more people have an opinion on this issue?

--Hardy


More information about the beanvalidation-dev mailing list