[bv-dev] Hosting of method validation methods

Hardy Ferentschik hardy at hibernate.org
Thu Jul 26 04:38:05 EDT 2012


On Jul 25, 2012, at 12:00 AM, Gunnar Morling wrote:

> Hi,
> 
> 2012/7/23 Hardy Ferentschik <hardy at hibernate.org>:
>> Hi all,
>> 
>> Let me pick up yet another TODO from the current spec.
>> 
>> Section "5.1.2. Method-level validation methods" [1] still contains a TODO whether the methods for method validation should be hosted
>> on a different interface (other than javax.validation.Validator).
>> 
>> At the moment all validation methods are hosted on javax.validation.Validator. Personally I don't see a strong reason for introducing
>> another indirection/interface. Does anyone have objections removing the todo?
> 
> I guess Emmanuel does :)
> 
> Personally, I also used to be of the opinion that a separate interface
> doesn't really add much value. What made me pondering though was the
> recent discussion about adding new bean validation methods such as
> validateProperty(T object, Path property, Class<?>... groups);
> 
> Following the interface segregation principle [1], it may indeed be a
> good idea to have two separate interfaces, one for standard bean
> validation and one for method validation. I think the main question
> is, who the consumers of the individual methods are. I think there may
> be a broader range of users of the bean validation methods
> (validate(), validateProperty() etc.) than of the method validation
> methods (validateParameters() etc.), which typically will only be
> invoked by authors of integration/glue code. So for users of the first
> group it would reduce complexity if the method validation stuff went
> into a separate interface.
> 
> With respect to retrieving method validators, instead of something
> like Validator#forMethod(Method method) etc. I could also imagine
> ValidatorFactory#getMethodValidator(). Then one doesn't have to
> retrieve a new validator for each validated method/constructor.

+1 for ValidatorFactory#getMethodValidator() in case we decide separate interfaces


--Hardy




More information about the beanvalidation-dev mailing list