Merge pull request #4099 from toint-admin/v7-dev

修复: org.hibernate.validator.constraints包注解, 校验信息丢失属性名称的情况
This commit is contained in:
Golden Looly
2025-10-13 10:23:43 +08:00
committed by GitHub

View File

@@ -82,11 +82,8 @@ public class ValidationUtil {
final Set<ConstraintViolation<Object>> constraintViolations = validate(object, groups);
if (CollUtil.isNotEmpty(constraintViolations)) {
final ConstraintViolation<Object> constraint = constraintViolations.iterator().next();
if (StrUtil.contains(constraint.getMessageTemplate(), "jakarta.validation.constraints")) {
throw new ValidationException(constraint.getPropertyPath() + StrPool.SPACE + constraint.getMessage());
} else {
throw new ValidationException(constraint.getMessage());
}
// 属性名称和错序信息之间需要有间隔, 否则可能出现粘连的情况, 例如: namemust not be null
throw new ValidationException(constraint.getPropertyPath() + StrPool.SPACE + constraint.getMessage());
}
}