<div dir="ltr">2013/2/8 Emmanuel Bernard <span dir="ltr"><<a href="mailto:emmanuel@hibernate.org" target="_blank">emmanuel@hibernate.org</a>></span><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Remember that I some point we discussed the ability to associate a<br>
constraint and its implementation via a registry or service locator<br>
mechanism.<br>
<a href="https://hibernate.onjira.com/browse/BVAL-252" target="_blank">https://hibernate.onjira.com/browse/BVAL-252</a><br>
<br>
In that environment, the idea of a mandatory validatedBy element on<br>
@CrossParameterConstraint is not very appealing. We could:<br>
<br>
- make it an array but it's really the 0 or 1 semantic we are looking<br>
for<br>
- accept any class so that we can use void.class as default value<br>
- use the @Validates approach<br></blockquote><div><br></div><div style>@Validates seems the best from these to me, as the other options change the semantics/type-safety of the API.</div><div style><br></div><div style>I'm also starting to like the idea, that there is one way to define a constraint annotation type (annotate it with @Constraint), while everything related to the supported types is handled in the validator implementation.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
Emmanuel<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Fri 2013-02-08 16:10, Hardy Ferentschik wrote:<br>
> Hi,<br>
><br>
> Is this not where 'include-existing-validators="true"' 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't see a need for a provided NoOpValidator provided by the API. If you don'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>
><br>
><br>
><br>
><br>
> On 8 Jan 2013, at 2:56 PM, Gunnar Morling <<a href="mailto:gunnar@hibernate.org">gunnar@hibernate.org</a>> wrote:<br>
><br>
> > All,<br>
> ><br>
> > I just noticed that it's currently not possible to specify *no* validator type for cross-parameter constraints:<br>
> ><br>
> > @CrossParameterConstraint(validatedBy=...)<br>
> > MyCrossParamConstraint{ ... }<br>
> ><br>
> > 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's also not possible to specify ConstraintValidator.class as dummy value (doesn't compile).<br>
> ><br>
> > Note that the problem doesn't exist with @Constraint where validatedBy() expects an array of class objects, allowing empty arrays. The following solutions come to my mind:<br>
> ><br>
> > #1 Get rid of @CrossParameterConstraint, use @Validates on validator implementations, as discussed as alternative before<br>
> ><br>
> > #2 Offer a dummy NoOpValidator in the API, obviously rather inelegant<br>
> ><br>
> > #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>
> ><br>
> > On a related note, if sticking to @CrossParameterConstraint, we may consider to narrow the type of supported validators:<br>
> ><br>
> > public @interface CrossParameterConstraint {<br>
> > Class<? extends ConstraintValidator<?, Object[]>> validatedBy();<br>
> > }<br>
> ><br>
> > I.e., only validators for Object[] would be allowed (currently that's demanded by the JavaDocs only).<br>
> ><br>
> > Any thoughts?<br>
> ><br>
> > --Gunnar<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>
><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>
_______________________________________________<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>