Type: New Feature
Affects Version/s: None
Fix Version/s: 2.1-ideas
Last commented by a user?:true
I'm using the Hibernate Validators since the day it got released. I wrote some extensions which also might be useful to other users:
I extended the MessageInterpolator so that I can use the rootBean, leafBean and the invalidValue in the message templates. Further I added support for nested properties. Here are some samples for (extended) message templates:
While this information is unnecessary while you are typing the data and see the whole record, it might be essential if the input is a file and the message is written to a log.
It would also useful to provide some custom properties in the MessageInterpolator context:
While the leafBean is available as validatedValue in the MessageInterpolator.Context, I had to extend the context to provide the other values.
The validator has only access to the validated object and the annotation. It is not always possible and reasonable to set the context information on the validated object. It would be good to have some context available in the validator. Now I pass the context information through a ThreadLocal variable which is very ugly and error prone. E.g. a validator could check if a value is equal to an entry of a dynamic list which depends on the context.
Sometimes it would be useful to pass some context to the validator:
Of course time consuming validation should not be triggered too often. A constaint causing such a validation would typically not define the Default.class group.
http://relation.to/Bloggers/JSRBeanVali ... mment19490