[bv-dev] Method Validation: Why Example 4.11 should be allowed

Hardy Ferentschik hardy at hibernate.org
Mon Jul 23 06:17:07 EDT 2012


Hi,

just to add my 0.02$ 

AFAICS there are two ways at looking at things.

#1 Gunnar's strictly OO approach. Any sub-type can be used where its super-types can be used. This principle is 
violated if parameter constraints could be added to sub-types, putting more constraints in place to be obeyed by the caller. 

For a caller it must be clear which constraints exist when calling a method. For this reason constraints need to be 
defined on the interface and implementation could not add constraints. 

#2 Paul's suggestion is saying the runtime type is the determining factor. When an implementation of an interface method 
is called evaluate the constraints on the implementation. This could be useful in case different implementation really have 
different constraints/preconditions. 

I can see use cases for both options and feel undecided. Maybe this could be handled via an option? 

--Hardy


More information about the beanvalidation-dev mailing list