mirror of
https://gitee.com/dromara/hutool.git
synced 2026-02-09 09:16:26 +08:00
Compare commits
5 Commits
10671aa580
...
0a36707d48
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a36707d48 | ||
|
|
cd1dc20f6d | ||
|
|
3d39f11a05 | ||
|
|
2ba14191f3 | ||
|
|
f58d25dd8d |
@@ -196,4 +196,13 @@ public class SystemUtil {
|
||||
public static String getTmpDirPath() {
|
||||
return get("java.io.tmpdir");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取工作目录路径(绝对路径)
|
||||
*
|
||||
* @return 工作目录路径
|
||||
*/
|
||||
public static String getUserDirPath() {
|
||||
return get("user.dir");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.dromara.hutool.extra.validation;
|
||||
import org.dromara.hutool.core.collection.CollUtil;
|
||||
|
||||
import jakarta.validation.*;
|
||||
import org.dromara.hutool.core.text.StrUtil;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -78,9 +79,13 @@ 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() + constraint.getMessage());
|
||||
} else {
|
||||
throw new ValidationException(constraint.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验bean的某一个属性
|
||||
|
||||
Reference in New Issue
Block a user