yyt
2024-06-26 0cceb649e1dc443c2a91d26d81eacb0867c96db3
提交 | 用户 | 时间
0cceb6 1 package com.jcdm.common.utils.bean;
Y 2
3 import java.util.Set;
4 import javax.validation.ConstraintViolation;
5 import javax.validation.ConstraintViolationException;
6 import javax.validation.Validator;
7
8 /**
9  * bean对象属性验证
10  * 
11  * @author jc
12  */
13 public class BeanValidators
14 {
15     public static void validateWithException(Validator validator, Object object, Class<?>... groups)
16             throws ConstraintViolationException
17     {
18         Set<ConstraintViolation<Object>> constraintViolations = validator.validate(object, groups);
19         if (!constraintViolations.isEmpty())
20         {
21             throw new ConstraintViolationException(constraintViolations);
22         }
23     }
24 }