我创建了我的验证器接口,以使用以下代码验证两个bean属性是否匹配:
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE )
@Constraint(validatedBy = FieldMatchesValidator.class)
@Documented
@interface FieldMatches {
String fieldName();
String dependFieldName();
String message() default "{FieldMatches.message}";
Class<?>[] groups() default [];
Class<? extends Payload>[] payload() default [];
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE )
@Documented
@interface List {
FieldMatches[] value();
}
}
在注释中,我期待的是:
@FieldMatches.List([
@FieldMatches(
fieldName = "pass",
dependFieldName = "confpass1"),
@FieldMatches(
fieldName = "pass",
dependFieldName = "confpass1")
])
有了这个,我收到以下错误:
Annotation type cannot be inner
提前感谢您的帮助。