0
我有自定义验证注释称为@Role
,我有自定义验证程序验证User
它的工作原理。问题是,当我想使用Set<User>
此验证程序来验证每一个元素这套这样Hibernate验证程序验证集
public class Project {
// Validates
@Role
private User creator;
// Throws error
@Role
private Set<User> users;
}
这个伤心地抛出这个错误:
javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint 'cz.studenthub.validators.annotations.Role' validating type 'java.util.Set<cz.studenthub.core.User>'
有什么办法来验证集合,而不必为Set<User>
写新的验证器?
注意:我不想为User
使用@Valid
,因为该实例不需要完全有效,只需要满足由我的RoleValidator
验证的一个条件。
谢谢你,我正在使用Dropwizard堆栈,因此更新到Beta版本是不可能的,但知道在不久的将来可能是足够的。 – TheSprtCZ