public class ValidationUtil extends Object
在实际使用中,用户需引入validation-api的实现,如:hibernate-validator
注意:hibernate-validator还依赖了javax.el,需自行引入。
Constructor and Description |
---|
ValidationUtil() |
Modifier and Type | Method and Description |
---|---|
static jakarta.validation.Validator |
getValidator()
获取原生
Validator 对象 |
static <T> Set<jakarta.validation.ConstraintViolation<T>> |
validate(T bean,
Class<?>... groups)
校验对象
|
static <T> Set<jakarta.validation.ConstraintViolation<T>> |
validateProperty(T bean,
String propertyName,
Class<?>... groups)
校验bean的某一个属性
|
static <T> BeanValidationResult |
warpValidate(T bean,
Class<?>... groups)
校验对象
|
static <T> BeanValidationResult |
warpValidateProperty(T bean,
String propertyName,
Class<?>... groups)
校验bean的某一个属性
|
public static jakarta.validation.Validator getValidator()
Validator
对象Validator
对象public static <T> Set<jakarta.validation.ConstraintViolation<T>> validate(T bean, Class<?>... groups)
T
- Bean类型bean
- beangroups
- 校验组Set
public static <T> Set<jakarta.validation.ConstraintViolation<T>> validateProperty(T bean, String propertyName, Class<?>... groups)
T
- Bean类型bean
- beanpropertyName
- 属性名称groups
- 验证分组Set
public static <T> BeanValidationResult warpValidate(T bean, Class<?>... groups)
T
- Bean类型bean
- beangroups
- 校验组BeanValidationResult
public static <T> BeanValidationResult warpValidateProperty(T bean, String propertyName, Class<?>... groups)
T
- bean类型bean
- beanpropertyName
- 属性名称groups
- 验证分组BeanValidationResult
Copyright © 2024. All rights reserved.