We're updating the issue view to help you get more done. 

Cross-parameter constraint is disallowed by Annotation Processor

Description

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:

CrossParameterConstraint.java

1 2 3 4 5 6 7 8 9 10 11 12 13 @Target({ANNOTATION_TYPE, METHOD, CONSTRUCTOR}) @Retention(RUNTIME) @Constraint(validatedBy = {CrossParameterConstraintValidator.class}) @Documented public @interface CrossParameterConstraint { String message() default "{CrossParameterConstraint.message}"; Class<?>[] groups() default {}; Class<? extends Payload>[] payload() default {}; }

CrossParameterConstraintValidator.java

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 @SupportedValidationTarget(ValidationTarget.PARAMETERS) public class CrossParameterConstraintValidator implements CrossParameterConstraintValidator<CrossParameterConstraint, Object[]> { @Override public void initialize(final CrossParameterConstraint constraintAnnotation) { } @Override public boolean isValid(final Object[] value, final ConstraintValidatorContext context) { // some validation logic return true; } }

The above constraint is used in a method as follows:

CrossParameterConstraintUsageExample.java

1 2 3 4 5 6 public class CrossParameterConstraintUsageExample { @CrossParameterConstraint public String test(Integer parameter, String anotherParameter) { return parameter + anotherParameter; } }

I have configured the Annotation Processor in pom.xml
as follows:

pom.xml

1 2 3 4 5 <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator-annotation-processor</artifactId> <version>5.0.3.Final</version> </dependency>

When trying to compile, the Annotation Processor reports the following error:

The annotation @CrossParameterConstraint is disallowed for the return type of this method.

Environment

hibernate validator 5.0.3 with Java 1.6.0_45-b06-451 on OSX 10.9.1.

Status

Assignee

Unassigned

Reporter

George Fountopoulos

Worked in

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Community Help Wanted

None

Suitable for new contributors

Yes, likely

Requires Release Note

None

backportDecision

None

backportReEvaluate

None

Components

Fix versions

Affects versions

5.0.3.Final
5.1.0.Beta1

Priority

Major