是否可以验证JSR 303中的对象集合 - Jave Bean Validation,其中集合本身没有任何注释,但包含的元素是什么?
例如,由于第二个人的名称为空,是否可能导致约束违规:
List<Person> people = new ArrayList<Person>();
people.add(new Person("dave"));
people.add(new Person(null));
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
Set<ConstraintViolation<List<Person>>> validation = validator.validate(people);
Run Code Online (Sandbox Code Playgroud)