I am using hibernate validator 5.0.3 with Java 1.6.0_45-b06-451 on OSX 10.9.1.
I have created a cross-parameter constraint as follows:
The above constraint is used in a method as follows:
I have configured the Annotation Processor in pom.xml
When trying to compile, the Annotation Processor reports the following error:
The annotation @CrossParameterConstraint is disallowed for the return type of this method.
hibernate validator 5.0.3 with Java 1.6.0_45-b06-451 on OSX 10.9.1.
Changing the type parameter from Object to Object in CrossParameterConstraintValidator seems to do the trick. However, the issue still applies for the case when Object type parameter is used. As mentioned in cross-parameter constraint documentation: The type parameter T from the ConstraintValidator interface must resolve to either Object or Object in order to receive the array of method/constructor arguments in the isValid() method.
Hi Georgios, thanks for reporting this issue. The annotation processor does not yet support method/constructor constraints and thus cross-parameter constraints. Good to hear that you found a workaround for the time being.
That said, would you be interested in contributing a fix for this? The processor code base is quite straight-forward so it would be a great chance if you'd like to dive a bit into Hibernate Validator development If you're interested I could give you some guidance on the general design and how to get started.
Thanks for the response Gunnar. I would very much like to contribute a fix, however, am working on new product development at the moment and on a pretty tight schedule. I will try and find some time to create the fix but cannot promise it will be any time soon. The good thing is that the issue is not a blocker and there is a workaround that I can use for now.
I found out that cross-parameter constraints were not supported by hibernate annotation processor. In the example provided, the processor was trying to compare Object or Object to the return type of the method, not to the parameters.
I've implemented the support for cross-parameter constraints, added most of the checks and related test cases.
The code is attached to the following pull request: https://github.com/hibernate/hibernate-validator/pull/455