diff --git a/CHANGELOG.md b/CHANGELOG.md
index 01595e7d2..bc4cb1a7b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@
### 🐣新特性
* 【core 】 CopyOptions支持以Lambda方式设置忽略属性列表(pr#590@Gitee)
+* 【core 】 增加中文姓名正则及其校验(pr#592@Gitee)
### 🐞Bug修复
* 【core 】 修复UserAgentUtil识别Linux出错(issue#I50YGY@Gitee)
diff --git a/hutool-core/src/main/java/cn/hutool/core/lang/PatternPool.java b/hutool-core/src/main/java/cn/hutool/core/lang/PatternPool.java
index 2a23a6736..c9a58debd 100644
--- a/hutool-core/src/main/java/cn/hutool/core/lang/PatternPool.java
+++ b/hutool-core/src/main/java/cn/hutool/core/lang/PatternPool.java
@@ -164,8 +164,8 @@ public class PatternPool {
*/
public static final Pattern CAR_DRIVING_LICENCE = Pattern.compile(RegexPool.CAR_DRIVING_LICENCE);
/**
- * 中国人姓名
- * 总结中国人姓名:2-60位,只能是中文和新疆人的点.
+ * 中文姓名
+ * 总结中国人姓名:2-60位,只能是中文和 ·
*/
public static final Pattern CHINESE_NAME = Pattern.compile(RegexPool.CHINESE_NAME);
diff --git a/hutool-core/src/main/java/cn/hutool/core/lang/RegexPool.java b/hutool-core/src/main/java/cn/hutool/core/lang/RegexPool.java
index f5c76fa48..fb092d95e 100755
--- a/hutool-core/src/main/java/cn/hutool/core/lang/RegexPool.java
+++ b/hutool-core/src/main/java/cn/hutool/core/lang/RegexPool.java
@@ -177,15 +177,17 @@ public interface RegexPool {
*/
String CAR_DRIVING_LICENCE = "^[0-9]{12}$";
/**
- * 中国人姓名
- * @see PatternPool#CHINESES [\u4E00-\u9FFF]+ 中文字
- * @see PatternPool#GENERAL_WITH_CHINESE "^[\u4E00-\u9FFF\w·]{2,60}$" 中文字、英文字母、数字和下划线
- * 新疆人名里面的点是 · 输入法中文状态下,键盘左上角数字1前面的那个符号;错误字符:..。..
- * 正确新疆人:
+ * 中文姓名
+ * 维吾尔族姓名里面的点是 · 输入法中文状态下,键盘左上角数字1前面的那个符号;
+ * 错误字符:{@code ..。..}
+ * 正确维吾尔族姓名:
+ *
* 霍加阿卜杜拉·麦提喀斯木 * 玛合萨提别克·哈斯木别克 * 阿布都热依木江·艾斯卡尔 * 阿卜杜尼亚孜·毛力尼亚孜 + *+ *
* ---------- * 错误示例:孟 伟 reason: 有空格 * 错误示例:连逍遥0 reason: 数字 @@ -196,7 +198,8 @@ public interface RegexPool { * 错误示例:翟冬:亮 reason: 有特殊符号 * 错误示例:李 reason: 少于2位 * ---------- - * 总结中国人姓名:2-60位,只能是中文和新疆人的点· + *+ * 总结中文姓名:2-60位,只能是中文和维吾尔族的点· */ String CHINESE_NAME = "^[\u4E00-\u9FFF·]{2,60}$"; } diff --git a/hutool-core/src/main/java/cn/hutool/core/lang/Validator.java b/hutool-core/src/main/java/cn/hutool/core/lang/Validator.java index 9534f56a4..9d80f71ba 100644 --- a/hutool-core/src/main/java/cn/hutool/core/lang/Validator.java +++ b/hutool-core/src/main/java/cn/hutool/core/lang/Validator.java @@ -20,7 +20,7 @@ import java.util.regex.Pattern; *
* 主要验证字段非空、是否为满足指定格式等(如是否为Email、电话等)
*
* @author Looly
@@ -105,11 +105,6 @@ public class Validator {
* 驾驶证 别名:驾驶证档案编号、行驶证编号;12位数字字符串;仅限:中国驾驶证档案编号
*/
public final static Pattern CAR_DRIVING_LICENCE = PatternPool.CAR_DRIVING_LICENCE;
- /**
- * 中国人姓名
- * 总结中国人姓名:2-60位,只能是中文和新疆人的点.
- */
- public static final Pattern CHINESE_NAME = PatternPool.CHINESE_NAME;
/**
* 给定值是否为{@code true}
@@ -948,7 +943,7 @@ public class Validator {
* @return 是否为URL
*/
public static boolean isUrl(CharSequence value) {
- if(StrUtil.isBlank(value)){
+ if (StrUtil.isBlank(value)) {
return false;
}
try {
@@ -1148,10 +1143,9 @@ public class Validator {
/**
* 验证是否为车架号;别名:行驶证编号 车辆识别代号 车辆识别码
*
- * @author dazer and ourslook
- *
* @param value 值,17位车架号;形如:LSJA24U62JG269225、LDC613P23A1305189
* @return 是否为车架号
+ * @author dazer and ourslook
* @since 5.6.3
*/
public static boolean isCarVin(CharSequence value) {
@@ -1161,13 +1155,12 @@ public class Validator {
/**
* 验证是否为车架号;别名:行驶证编号 车辆识别代号 车辆识别码
*
- * @author dazer and ourslook
- *
* @param
+ * 错误字符:{@code ..。..}
+ * 正确维吾尔族姓名:
+ *
+ * 霍加阿卜杜拉·麦提喀斯木
+ * 玛合萨提别克·哈斯木别克
+ * 阿布都热依木江·艾斯卡尔
+ * 阿卜杜尼亚孜·毛力尼亚孜
+ *
+ *
+ * ----------
+ * 错误示例:孟 伟 reason: 有空格
+ * 错误示例:连逍遥0 reason: 数字
+ * 错误示例:依帕古丽-艾则孜 reason: 特殊符号
+ * 错误示例:牙力空.买提萨力 reason: 新疆人的点不对
+ * 错误示例:王建鹏2002-3-2 reason: 有数字、特殊符号
+ * 错误示例:雷金默(雷皓添) reason: 有括号
+ * 错误示例:翟冬:亮 reason: 有特殊符号
+ * 错误示例:李 reason: 少于2位
+ * ----------
+ *
+ * 总结中文姓名:2-60位,只能是中文和 ·
*
+ * @param value 中文姓名
+ * @return 是否是正确的中文姓名
* @author dazer
- *
- * @param value 中国人姓名
- * @return 是否是正确的中国人姓名
- * @see 5.8.0.M3
+ * @since 5.8.0.M3
*/
public static boolean isChineseName(CharSequence value) {
- return isMatchRegex(CHINESE_NAME, value);
+ return isMatchRegex(PatternPool.CHINESE_NAME, value);
}
/**
- * 验证是否为驾驶证 别名:驾驶证档案编号、行驶证编号
- *
- * @author dazer and ourslook
+ * 验证是否为驾驶证 别名:驾驶证档案编号、行驶证编号
*
* @param