<div dir="ltr"><div>Option #3 is fine, along with narrowing @CrossParameterConstraint#validatedBy() to &lt;?, Object[]&gt;.<br><br></div><div class="gmail_extra">For the sake of discussion, I was a bit intrigued by option #2, as:<br>
<br></div><div class="gmail_extra">public interface ConstraintValidator&lt;A, T&gt; {<br></div><div class="gmail_extra">  public final class Noop implements ConstraintValidator&lt;Annotation, Object&gt; {<br></div><div class="gmail_extra">
    //appropriate impl<br></div><div class="gmail_extra">  }<br></div><div class="gmail_extra">}<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Then this class could be used anywhere.  Alternatively, it could be non-instantiable and be explicitly ignored by implementations.  But would Annotation even be the right parameter for Noop.&lt;A&gt;?  Would existing Bean Validation implementations be able to resolve this as validating a given constraint type?  Note that, if these issues could be satisfactorily resolved, it would probably be appropriate to narrow @CrossParameterContraint#validatedBy() to &lt;?, ? super Object[]&gt;.<br>
<br></div><div class="gmail_extra">Matt<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 8, 2013 at 9:10 AM, Hardy Ferentschik <span dir="ltr">&lt;<a href="mailto:hardy@hibernate.org" target="_blank">hardy@hibernate.org</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
Is this not where &#39;include-existing-validators=&quot;true&quot;&#39; in the XML config comes into play as well?<br>
So it is still possible to configure via XML with the default constraint implementation in- or excluded.<br>
I don&#39;t see a need for a provided NoOpValidator provided by the API. If you don&#39;t want to provide a<br>
actual implementation you can create your own dummy.<br>
<br>
I still against option #1. So I guess I reasoned myself into #3<br>
<br>
--Hardy<br>
<div><div class="h5"><br>
<br>
<br>
<br>
On 8 Jan 2013, at 2:56 PM, Gunnar Morling &lt;<a href="mailto:gunnar@hibernate.org">gunnar@hibernate.org</a>&gt; wrote:<br>
<br>
&gt; All,<br>
&gt;<br>
&gt; I just noticed that it&#39;s currently not possible to specify *no* validator type for cross-parameter constraints:<br>
&gt;<br>
&gt; @CrossParameterConstraint(validatedBy=...)<br>
&gt; MyCrossParamConstraint{ ... }<br>
&gt;<br>
&gt; Not specifying a validator might be relevant for people who want to hide their validator implementations and e.g. configure them via XML. Null is not allowed as annotation member value, and it&#39;s also not possible to specify ConstraintValidator.class as dummy value (doesn&#39;t compile).<br>

&gt;<br>
&gt; Note that the problem doesn&#39;t exist with @Constraint where validatedBy() expects an array of class objects, allowing empty arrays. The following solutions come to my mind:<br>
&gt;<br>
&gt; #1 Get rid of @CrossParameterConstraint, use @Validates on validator implementations, as discussed as alternative before<br>
&gt;<br>
&gt; #2 Offer a dummy NoOpValidator in the API, obviously rather inelegant<br>
&gt;<br>
&gt; #3 Ignore the problem, maybe the use case is really uncommon? If required, recommend people to use their own dummy validator and override it via XML<br>
&gt;<br>
&gt; On a related note, if sticking to @CrossParameterConstraint, we may consider to narrow the type of supported validators:<br>
&gt;<br>
&gt;     public @interface CrossParameterConstraint {<br>
&gt;         Class&lt;? extends ConstraintValidator&lt;?, Object[]&gt;&gt; validatedBy();<br>
&gt;     }<br>
&gt;<br>
&gt; I.e., only validators for Object[] would be allowed (currently that&#39;s demanded by the JavaDocs only).<br>
&gt;<br>
&gt; Any thoughts?<br>
&gt;<br>
&gt; --Gunnar<br>
&gt;<br>
</div></div>&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>
<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>
</blockquote></div><br></div></div>