<div><div><div><font class="Apple-style-span" face="arial, sans-serif"><div>hi,</div><div><br></div><div>@MethodValidator</div><div>+1 for the concept in general</div><div>however, if there isn&#39;t a reason for using T object compared to Class&lt;T&gt; clazz (see [1]) as parameter, i would prefer Class&lt;T&gt;.</div>

<div><br></div><div>@BeanDescriptor (renaming it to TypeDescriptor)</div><div>it&#39;s a type-safe change - but still -1</div><div><br></div><div>@named parameters:</div><div>(for the spec.) i don&#39;t like the idea to re-use @Named for it (the package javax.inject and therefore the dependency in general look strange from the perspective of bv)</div>

<div>imo we should re-visit cross-field validation. a solution for it might influence this topic as well (to keep it consistent).</div><div><br></div><div>regards,</div><div>gerhard</div><div><br></div></font></div><div>
[1] <a href="https://svn.apache.org/repos/asf/incubator/bval/tags/0.3-incubating/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodValidator.java">https://svn.apache.org/repos/asf/incubator/bval/tags/0.3-incubating/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodValidator.java</a></div>

<div><br><div class="gmail_quote">2011/9/6 Gunnar Morling <span dir="ltr">&lt;<a href="mailto:gunnar.morling@googlemail.com">gunnar.morling@googlemail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Hi,<br>
<div class="im"><br>
&gt; Gunnar, could to take the lead on the Hibernate Validator version? You know this area best.<br>
<br>
</div>Sure. What we have in HV [1], [2] is pretty much based on appendix C<br>
of BV 1.0 [3]. More specifically that is:<br>
<br>
* IF MethodValidator:<br>
<br>
public interface MethodValidator {<br>
<br>
        &lt;T&gt; Set&lt;MethodConstraintViolation&lt;T&gt;&gt; validateParameter(T object,<br>
Method method, Object parameterValue, int parameterIndex, Class&lt;?&gt;...<br>
groups);<br>
<br>
        &lt;T&gt; Set&lt;MethodConstraintViolation&lt;T&gt;&gt; validateAllParameters(T object,<br>
Method method, Object[] parameterValues, Class&lt;?&gt;... groups);<br>
<br>
        &lt;T&gt; Set&lt;MethodConstraintViolation&lt;T&gt;&gt; validateReturnValue(T object,<br>
Method method, Object returnValue, Class&lt;?&gt;... groups);<br>
<br>
        TypeDescriptor getConstraintsForType(Class&lt;?&gt; clazz);<br>
}<br>
<br>
In BV these methods should go into javax.validation.Validator (plus<br>
validateConstructorParameters or similar).<br>
<br>
* IF MethodConstraintViolation which extends ConstraintViolation by<br>
adding getMethod(), getParameterIndex() etc. to specify the source of<br>
a violation.<br>
<br>
* MethodConstraintViolationException, wrapping a set of<br>
MethodConstraintViolations and to be thrown by integrators of the<br>
method validation feature.<br>
<br>
* Extension to the constraint meta data API based on IF TypeDescriptor:<br>
<br>
public interface TypeDescriptor extends ElementDescriptor {<br>
<br>
        boolean isTypeConstrained();<br>
<br>
        Set&lt;MethodDescriptor&gt; getConstrainedMethods();<br>
<br>
        MethodDescriptor getConstraintsForMethod(String methodName,<br>
Class&lt;?&gt;... parameterTypes);<br>
<br>
        BeanDescriptor getBeanDescriptor();<br>
}<br>
<br>
In BV 1.1 this should be merged with BeanDescriptor (which in turn<br>
should be renamed to TypeDescriptor IMO as it isn&#39;t restricted to<br>
JavaBeans any more).<br>
<br>
* Extension to the programmatic API [4] allowing to specify method<br>
constraints programmatically like this:<br>
<br>
ConstraintMapping mapping = new ConstraintMapping();<br>
mapping.type( Car.class )<br>
    .method( &quot;drive&quot;, String.class, Integer.class )<br>
        .parameter( 0 )<br>
            .constraint( new NotNullDef() )<br>
            .constraint( new MinDef().value ( 1 ) )<br>
        .returnValue()<br>
            .valid();<br>
<br>
HibernateValidatorConfiguration config = Validation.byProvider(<br>
HibernateValidator.class ).configure();<br>
config.addMapping( mapping );<br>
Validator validator = config.buildValidatorFactory().getValidator();<br>
<br>
What we don&#39;t have:<br>
<br>
* constructor validation<br>
<br>
* cross-parameter validation as discussed in BV-232.<br>
<br>
* parameter constraints may only be specified at the &quot;lowest version&quot;<br>
of an overridden method, see [5]. Though I don&#39;t think that this<br>
restriction is really an issue.<br>
<br>
* ability to specify parameter names, see [6].<br>
<br>
@Hardy: Do see anything missing?<br>
<br>
--Gunnar<br>
<br>
<br>
[1] HV reference guide on method validation:<br>
<a href="http://docs.jboss.org/hibernate/stable/validator/reference/en-US/html/validator-specifics.html#validator-customoptions-methodvalidation" target="_blank">http://docs.jboss.org/hibernate/stable/validator/reference/en-US/html/validator-specifics.html#validator-customoptions-methodvalidation</a><br>


[2] HV&#39;s method validation API:<br>
<a href="http://docs.jboss.org/hibernate/stable/validator/api/index.html?org/hibernate/validator/method/package-summary.html" target="_blank">http://docs.jboss.org/hibernate/stable/validator/api/index.html?org/hibernate/validator/method/package-summary.html</a><br>


[3] BV 1.0, Appendix C:<br>
<a href="http://beanvalidation.org/1.0/spec/#appendix-methodlevelvalidation" target="_blank">http://beanvalidation.org/1.0/spec/#appendix-methodlevelvalidation</a><br>
[4] HV&#39;s programmatic constraint API:<br>
<a href="http://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/#programmaticapi" target="_blank">http://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/#programmaticapi</a><br>


[5] Using method constraints in type hierarchies:<br>
<a href="http://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/#d0e3267" target="_blank">http://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/#d0e3267</a><br>
[6] Specifying parameter names: <a href="https://hibernate.onjira.com/browse/HV-409" target="_blank">https://hibernate.onjira.com/browse/HV-409</a><br>
<br>
<br>
2011/9/6 Emmanuel Bernard &lt;<a href="mailto:emmanuel@hibernate.org">emmanuel@hibernate.org</a>&gt;:<br>
<div><div></div><div class="h5">&gt; While we still decide what to do in which order, I&#39;d like to start thinking about method level validation in parallel.<br>
&gt;<br>
&gt; Probably the biggest feature for this new round ( <a href="http://beanvalidation.org/roadmap/" target="_blank">http://beanvalidation.org/roadmap/</a> ) is method level validation.<br>
&gt;<br>
&gt; ## Goal<br>
&gt;<br>
&gt; Offer the ability to:<br>
&gt;<br>
&gt; - annotate method and constructor parameters and return values with Bean Validation constraints.<br>
&gt; - provide validation methods to validate a method / constructor given a set of parameters<br>
&gt;<br>
&gt; This set of methods will be used by framework controlling the method execution cycle (CDI, JAX-RS, aspect oriented frameworks etc).<br>
&gt;<br>
&gt; <a href="https://hibernate.onjira.com/browse/BVAL-232" target="_blank">https://hibernate.onjira.com/browse/BVAL-232</a><br>
&gt;<br>
&gt; We need to explore this feature to clarify what we want to support, how we want to support it, how it integrates with Bean Validation 1.0.<br>
&gt;<br>
&gt; ## Usefulness<br>
&gt;<br>
&gt; This method will be useful to various other specifications including CDI and JAX-RS. That&#39;s why I&#39;d like to stabilize this feature as early as possible.<br>
&gt;<br>
&gt; ## Proposals<br>
&gt;<br>
&gt; Hibernate Validator has an implementation of such feature and I am sure OVal, Apache Bean Validation and others have something similar. Let&#39;s start with describing what we have and start the discussion from here.<br>


&gt;<br>
&gt; Gunnar, could to take the lead on the Hibernate Validator version? You know this area best.<br>
&gt;<br>
&gt; Emmanuel<br>
&gt; _______________________________________________<br>
&gt; beanvalidation-dev mailing list<br>
&gt; <a href="mailto:beanvalidation-dev@lists.jboss.org">beanvalidation-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/beanvalidation-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/beanvalidation-dev</a><br>
&gt;<br>
_______________________________________________<br>
beanvalidation-dev mailing list<br>
<a href="mailto:beanvalidation-dev@lists.jboss.org">beanvalidation-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/beanvalidation-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/beanvalidation-dev</a><br>
</div></div></blockquote></div><br></div></div></div>