Interesting, I would say that remain pretty uncommon as far as use case frequency goes.
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 :)
Emmanuel
On 29 Jul 2014, at 15:31, Richard Fanning <Richard.Fanning(a)FINEOS.com> wrote:
Hi there,
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.
The use case we have is we have a “DateTime” object which represents Date & Time. Our
DateTime object pre-dates JDK 8 (and JodaTime). A DateTime for us has some constraints
The DateTime cannot me before LOW_DATE à 01-01-1970 00:00:00
The DateTime cannot me after HIGH_DATE à 31-12-2150 23:59:59
Not sure of the exact history of these constraints but it would seem like we are trying
to invent a new y2kJ
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.
Assume we have an object which has a DateTime property as shown below
public class TestObject {
private DateTime myDateTime;
public DateTime getMyDateTime() {
return myDateTime;
}
public void setMyDateTime(DateTime myDateTime) {
this.myDateTime = myDateTime;
}
}
We’d like if developers did not need to add an annotation all DateTime properties to
constrain with the implicit constraints.. i.e.
@Date
private DateTime myDateTime;
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.
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.
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.
Appreciate any feedback you might have.
Thanks
Rich
__________________________________________________________
FINEOS Corporation is the global brand name of FINEOS Corporation and its affiliated
group companies worldwide.
The information contained in this e-mail is confidential, may be privileged and is
intended
only for the use of the recipient named above. If you are not the intended recipient or a
representative of the intended recipient, you have received this e-mail in error and must
not copy, use or disclose the contents of this e-mail to anybody else.
If you have received this e-mail in error, please notify the sender immediately by return
e-mail and permanently delete the copy you received. This e-mail has been swept for
computer viruses. However, you should carry out your own virus checks.
Registered in Ireland, No. 205721.
http://www.FINEOS.com
__________________________________________________________
_______________________________________________
beanvalidation-dev mailing list
beanvalidation-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/beanvalidation-dev