|
Hereby a patch for ValidatorList (based on latest svn checkout) Feel free to comment on the implementation Edwin I have the same problem but the GenericValidator seems very verbos. Here is an example of something I am playing with: @Expressions( Ignore the fact that I am using expression language. The Expressions annotation is not linked to a ValidatorClass, but the Expression annotation is. public @interface Expressions { @ValidatorClass(ExpressionValidator.class) String value(); In ClassValidator when it initializes it gets all the annotations off of the class and members and checks if they have a ValidatorClass. It could also use reflection to see if the annotations aggregate other annotations which in turn are linked to a ValidatorClass. This would require a moderate bit of rework to ClassValidator, but would make using it much cleaner. Thoughts? Problem is the user needs to create the Annotation container for each specific type. This was easier than I thought it would be. I just added the handleAggregateAnnotations() method and called it in two places. NOTE: The source I attached is from 3.2.0.CR1, because I am still using and older version of the jboss embedded container. Btw, I would be glad to donate the EL validator, but I am using commons-jexl. Commited John's patch. I don't think Edwin's solution is needed anymore. Great! I have created a blog entry that talks about this topic: http://jroller.com/page/jgilbert01?entry=extending_the_hibernate_validation_framework cool, nice ideas. I like the EL actually I like John's solution better too |
|||||||||||||||||||||||||||||||||||||||||||
Edwin,
I believe you can implement an untyped version
@GenericValidator( class=..., parameters = @Params(key=, value=) )
Then @Validators(GenericValidator[] value() )
Hibernate Annotations has the ability to "create" annotations (ie recreate the actual validator).
have a look at org.hibernate.test.annotationfactory.AnnotationFactoryTest