<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't a reason for using T object compared to Class<T> clazz (see [1]) as parameter, i would prefer Class<T>.</div>
<div><br></div><div>@BeanDescriptor (renaming it to TypeDescriptor)</div><div>it's a type-safe change - but still -1</div><div><br></div><div>@named parameters:</div><div>(for the spec.) i don'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"><<a href="mailto:gunnar.morling@googlemail.com">gunnar.morling@googlemail.com</a>></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>
> 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>
<T> Set<MethodConstraintViolation<T>> validateParameter(T object,<br>
Method method, Object parameterValue, int parameterIndex, Class<?>...<br>
groups);<br>
<br>
<T> Set<MethodConstraintViolation<T>> validateAllParameters(T object,<br>
Method method, Object[] parameterValues, Class<?>... groups);<br>
<br>
<T> Set<MethodConstraintViolation<T>> validateReturnValue(T object,<br>
Method method, Object returnValue, Class<?>... groups);<br>
<br>
TypeDescriptor getConstraintsForType(Class<?> 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<MethodDescriptor> getConstrainedMethods();<br>
<br>
MethodDescriptor getConstraintsForMethod(String methodName,<br>
Class<?>... 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'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( "drive", 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'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 "lowest version"<br>
of an overridden method, see [5]. Though I don'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'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'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 <<a href="mailto:emmanuel@hibernate.org">emmanuel@hibernate.org</a>>:<br>
<div><div></div><div class="h5">> While we still decide what to do in which order, I'd like to start thinking about method level validation in parallel.<br>
><br>
> 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>
><br>
> ## Goal<br>
><br>
> Offer the ability to:<br>
><br>
> - annotate method and constructor parameters and return values with Bean Validation constraints.<br>
> - provide validation methods to validate a method / constructor given a set of parameters<br>
><br>
> This set of methods will be used by framework controlling the method execution cycle (CDI, JAX-RS, aspect oriented frameworks etc).<br>
><br>
> <a href="https://hibernate.onjira.com/browse/BVAL-232" target="_blank">https://hibernate.onjira.com/browse/BVAL-232</a><br>
><br>
> 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>
><br>
> ## Usefulness<br>
><br>
> This method will be useful to various other specifications including CDI and JAX-RS. That's why I'd like to stabilize this feature as early as possible.<br>
><br>
> ## Proposals<br>
><br>
> Hibernate Validator has an implementation of such feature and I am sure OVal, Apache Bean Validation and others have something similar. Let's start with describing what we have and start the discussion from here.<br>
><br>
> Gunnar, could to take the lead on the Hibernate Validator version? You know this area best.<br>
><br>
> Emmanuel<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>
><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>