com.kasinf.framework.rest.web.util.ValidatorUtils Maven / Gradle / Ivy
package com.kasinf.framework.rest.web.util;
import org.hibernate.validator.HibernateValidator;
import org.springframework.util.Assert;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import java.util.Set;
/**
* @author lkhsh
*
* 利用Hibernate Validator进行验证的工具类
*/
public class ValidatorUtils {
public static Validator validator;
public ValidatorUtils(Validator validator) {
ValidatorUtils.validator = validator;
}
public static Set> validate(Object target) {
return validator.validate(target);
}
public static Set> validate(Object target, Class>... groups) {
return validator.validate(target, groups);
}
}