<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Interesting, I would say that remain pretty uncommon as far as use case frequency goes.<div><br><div>On an unrelated project I work on, we have introduce a relatively similar notion of registrable constraints (bridges in that project) per property return type. We could definitely try and bring that idea to Hibernate Validator and see how many people use it before moving it to BV. That would still be better than you hacking your way int he guts of Hibernate Validator :)</div><div><br></div><div>Emmanuel&nbsp;</div><div><br><div><div><div>On 29 Jul 2014, at 15:31, Richard Fanning &lt;<a href="mailto:Richard.Fanning@FINEOS.com">Richard.Fanning@FINEOS.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font face="Calibri" size="2"><span style="font-size: 11pt;"><div><font color="#632423">Hi there,</font></div><div><font color="#632423">&nbsp;</font></div><div><font color="#632423">We are starting to use bean validation in our product and something we would like to do is what I’ve coined as “implicit constraints”. I’d like to run this by the mailing list and get your thoughts on this as a potential feature in the spec.</font></div><div><font color="#632423">&nbsp;</font></div><div><font color="#632423">The use case we have is we have a “DateTime” object which represents Date &amp; Time. Our DateTime object pre-dates JDK 8 (and JodaTime).&nbsp; A DateTime for us has some constraints</font></div><div><font color="#632423">&nbsp;</font></div><ol style="margin: 0px; padding-left: 36pt;"><font color="#632423"><li>The DateTime cannot me before LOW_DATE<span class="Apple-converted-space">&nbsp;</span><font face="Wingdings">à</font><span class="Apple-converted-space">&nbsp;</span>01-01-1970 00:00:00</li><li>The DateTime cannot me after HIGH_DATE<span class="Apple-converted-space">&nbsp;</span><font face="Wingdings">à</font><span class="Apple-converted-space">&nbsp;</span>31-12-2150 23:59:59</li></font></ol><div><font color="#632423">&nbsp;</font></div><div><font color="#632423">Not sure of the exact history of these constraints but it would seem like we are trying to invent a new y2k<font face="Wingdings">J</font></font></div><div><font color="#632423">&nbsp;</font></div><div><font color="#632423">These constraints were enforced prior to our usage of Bean Validation as these were burnt into the setter of generated POJO’s (domain objects) but now that we are moving from generated domain objects to JPA style POJO’s we’d like to use Bean Validation to apply the same constraints.</font></div><div><font color="#632423">&nbsp;</font></div><div><font color="#632423">Assume we have an object which has a DateTime property as shown below</font></div><div><font color="#632423">&nbsp;</font></div><div><font face="Consolas" size="2" color="#7F0055"><span style="font-size: 10pt;"><b>public</b><font><span class="Apple-converted-space">&nbsp;</span></font><b>class</b><font><span class="Apple-converted-space">&nbsp;</span>TestObject {</font></span></font></div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Apple-converted-space">&nbsp;</span><font face="Consolas" size="2" color="#7F0055"><span style="font-size: 10pt;"><b>private</b></span></font><font face="Consolas" size="2"><span style="font-size: 10pt;"><span class="Apple-converted-space">&nbsp;</span>DateTime<span class="Apple-converted-space">&nbsp;</span></span></font><font face="Consolas" size="2" color="#0000C0"><span style="font-size: 10pt;">myDateTime</span></font><font face="Consolas" size="2"><span style="font-size: 10pt;">;</span></font></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Apple-converted-space">&nbsp;</span><font face="Consolas" size="2" color="#7F0055"><span style="font-size: 10pt;"><b>public</b></span></font><font face="Consolas" size="2"><span style="font-size: 10pt;"><span class="Apple-converted-space">&nbsp;</span>DateTime getMyDateTime() {</span></font></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Apple-converted-space">&nbsp;</span><font face="Consolas" size="2" color="#7F0055"><span style="font-size: 10pt;"><b>return</b></span></font><font face="Consolas" size="2"><span style="font-size: 10pt;"><span class="Apple-converted-space">&nbsp;</span></span></font><font face="Consolas" size="2" color="#0000C0"><span style="font-size: 10pt;">myDateTime</span></font><font face="Consolas" size="2"><span style="font-size: 10pt;">;</span></font></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Apple-converted-space">&nbsp;</span><font face="Consolas" size="2"><span style="font-size: 10pt;">}</span></font></div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Apple-converted-space">&nbsp;</span><font face="Consolas" size="2" color="#7F0055"><span style="font-size: 10pt;"><b>public</b></span></font><font face="Consolas" size="2"><span style="font-size: 10pt;"><span class="Apple-converted-space">&nbsp;</span></span></font><font face="Consolas" size="2" color="#7F0055"><span style="font-size: 10pt;"><b>void</b></span></font><font face="Consolas" size="2"><span style="font-size: 10pt;"><span class="Apple-converted-space">&nbsp;</span>setMyDateTime(DateTime<span class="Apple-converted-space">&nbsp;</span></span></font><font face="Consolas" size="2" color="#6A3E3E"><span style="font-size: 10pt;">myDateTime</span></font><font face="Consolas" size="2"><span style="font-size: 10pt;">) {</span></font></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Apple-converted-space">&nbsp;</span><font face="Consolas" size="2" color="#7F0055"><span style="font-size: 10pt;"><b>this</b></span></font><font face="Consolas" size="2"><span style="font-size: 10pt;">.</span></font><font face="Consolas" size="2" color="#0000C0"><span style="font-size: 10pt;">myDateTime</span></font><font face="Consolas" size="2"><span style="font-size: 10pt;"><span class="Apple-converted-space">&nbsp;</span>=<span class="Apple-converted-space">&nbsp;</span></span></font><font face="Consolas" size="2" color="#6A3E3E"><span style="font-size: 10pt;">myDateTime</span></font><font face="Consolas" size="2"><span style="font-size: 10pt;">;</span></font></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Apple-converted-space">&nbsp;</span><font face="Consolas" size="2"><span style="font-size: 10pt;">}</span></font></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div><div><font face="Consolas" size="2"><span style="font-size: 10pt;">}</span></font></div><div><font face="Consolas" size="2"><span style="font-size: 10pt;">&nbsp;</span></font></div><div><font color="#632423">We’d like if developers did not need to add an annotation all DateTime properties to constrain with the implicit constraints.. i.e.</font></div><div><font color="#632423">&nbsp;</font></div><div><font face="Consolas" size="2"><span style="font-size: 10pt;">@Date</span></font></div><div><font face="Consolas" size="2" color="#7F0055"><span style="font-size: 10pt;"><b>private</b><font><span class="Apple-converted-space">&nbsp;</span>DateTime<span class="Apple-converted-space">&nbsp;</span></font><font color="#0000C0">myDateTime</font><font>;</font></span></font></div><div><font color="#632423">&nbsp;</font></div><div><font color="#632423">In our opinion this annotation serves no additional purpose and would be an extra onus on the developer to add this so they ensure the value meets internal DateTime criteria.</font></div><div><font color="#632423">&nbsp;</font></div><div><font color="#632423">Looking at the 1.1 spec I cannot see any way of applying constraints without annotating (well you can use HV XML but that would need to be done for all fields).. Is that correct.</font></div><div><font color="#632423">&nbsp;</font></div><div><font color="#632423">I’ve managed to implement “implicit constraints” by using non-standard Hibernate Validator API’s (i.e. using reflection I added an additional MetaDataProvider which added ConstrainedElements ( to the BeanConfiguration)). I can share this on GitHub is anyone is interested in taking a look.</font></div><div><font color="#632423">&nbsp;</font></div><div><font color="#632423">Appreciate any feedback you might have.</font></div><div><font color="#632423">&nbsp;</font></div><div><font color="#632423">Thanks</font></div><div><font color="#632423"><br>Rich</font></div><div>&nbsp;</div><div>&nbsp;</div></span></font><p><font face="arial,helvetica,sans-serif" size="2">__________________________________________________________<br>FINEOS Corporation is the global brand name of FINEOS Corporation and its affiliated<span class="Apple-converted-space">&nbsp;</span><br>group companies worldwide.<br><br>The information contained in this e-mail is confidential, may be privileged and is intended<span class="Apple-converted-space">&nbsp;</span><br>only for the use of the recipient named above. If you are not the intended recipient or a<span class="Apple-converted-space">&nbsp;</span><br>representative of the intended recipient, you have received this e-mail in error and must<span class="Apple-converted-space">&nbsp;</span><br>not copy, use or disclose the contents of this e-mail to anybody else.&nbsp;<span class="Apple-converted-space">&nbsp;</span><br><br>If you have received this e-mail in error, please notify the sender immediately by return<span class="Apple-converted-space">&nbsp;</span><br>e-mail and permanently delete the copy you received.&nbsp; This e-mail has been swept for<span class="Apple-converted-space">&nbsp;</span><br>computer viruses. However, you should carry out your own virus checks.<span class="Apple-converted-space">&nbsp;</span><br>Registered in Ireland, No. 205721.&nbsp;<span class="Apple-converted-space">&nbsp;</span><a href="http://www.fineos.com/">http://www.FINEOS.com</a><br>__________________________________________________________<br></font></p>_______________________________________________<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">https://lists.jboss.org/mailman/listinfo/beanvalidation-dev</a></div></blockquote></div><br></div></div></div></body></html>