|
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:
@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 {};
}
@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) {
return true;
}
}
The above constraint is used in a method as follows:
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:
<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.
|