mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-12-07 01:28:34 +08:00
修复: org.hibernate.validator.constraints包注解, 校验信息丢失属性名称的情况
This commit is contained in:
parent
f7584b83fc
commit
54021c8796
@ -82,11 +82,8 @@ public class ValidationUtil {
|
|||||||
final Set<ConstraintViolation<Object>> constraintViolations = validate(object, groups);
|
final Set<ConstraintViolation<Object>> constraintViolations = validate(object, groups);
|
||||||
if (CollUtil.isNotEmpty(constraintViolations)) {
|
if (CollUtil.isNotEmpty(constraintViolations)) {
|
||||||
final ConstraintViolation<Object> constraint = constraintViolations.iterator().next();
|
final ConstraintViolation<Object> constraint = constraintViolations.iterator().next();
|
||||||
if (StrUtil.contains(constraint.getMessageTemplate(), "jakarta.validation.constraints")) {
|
// 属性名称和错序信息之间需要有间隔, 否则可能出现粘连的情况, 例如: namemust not be null
|
||||||
throw new ValidationException(constraint.getPropertyPath() + StrPool.SPACE + constraint.getMessage());
|
throw new ValidationException(constraint.getPropertyPath() + StrPool.SPACE + constraint.getMessage());
|
||||||
} else {
|
|
||||||
throw new ValidationException(constraint.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user