Hi Emmanuel,<div><br></div><div>I had initially considered this, too, but then went for the current approach for two reasons:</div><div><br></div><div>* in a Java EE environment default Validator and ValidatorFactory are provided (and also registered in JNDI etc.) by the container and I don&#39;t think there is a way for Seam Validation kicking in and setting the constraint validator factory. So I think in EE specifying the factory in validation.xml is the only way to go.</div>

<div><br></div><div>* in a non-EE environment Seam Validation itself creates and registers default Validator and ValidatorFactory, so we generally could set the constraint validator factory here. But a user actually could want to use another one by specifying it in validation.xml which we then would have to override. In this case it might be unexpected by the user that the factory in use is another one than defined in validation.xml.</div>

<div><br></div><div>So at least for now sticking with validation.xml seems like the best choice to me. </div><div><br></div><div>We might re-visit this later on (at least for the non-EE case, there we could give validation.xml precedence and set the injecting factory only, if no other one was given via XML), but to keep things simple I&#39;d like to follow the current approach for Seam 3. I created <a href="https://issues.jboss.org/browse/SEAMVALIDATE-10">https://issues.jboss.org/browse/SEAMVALIDATE-10</a> for this, which we can address in a future release.</div>
<div><br></div><div>Of course a user could always create a custom qualifier annotation and a producer, which creates a Validator(Factory) in the way you describe, rendering validation.xml unnecessary.</div><div><br></div>
<div>Gunnar</div><div><br><br><div class="gmail_quote">2011/3/8 Emmanuel Bernard <span dir="ltr">&lt;<a href="mailto:emmanuel@hibernate.org" target="_blank">emmanuel@hibernate.org</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Gunnar,<br>
I was reading your doc on Seam Validation<br>
<a href="http://docs.jboss.org/seam/3/validation/latest/reference/en-US/html_single/#d0e146" target="_blank">http://docs.jboss.org/seam/3/validation/latest/reference/en-US/html_single/#d0e146</a><br>
<br>
I was thinking that we might be able to go one step further with the &quot;Dependency injection for constraint validators&quot;.<br>
Today you ask people to configure the ConstraintValidatorFactory using some XML snippet. How about Seam transparently configure it.<br>
<br>
You can do it programmatically at two levels:<br>
<br>
1. during the construction of ValidatorFactory<br>
ValidatorFactory factory = Validation<br>
       .byDefaultProvider().configure()<br>
          .constraintValidatorFactory( new InjectingConstraintValidatorFactory() )<br>
          .buildValidatorFactory();<br>
<br>
2. or during the Validator construction<br>
validator<br>
    .usingContext()<br>
        .constraintValidatorFactory( new InjectingConstraintValidatorFactory() )<br>
    .getValidator();<br>
<br>
WDYT?</blockquote></div><br></div>