Looly 5 years ago
parent
commit
7e4889945c

+ 1 - 0
CHANGELOG.md

@@ -10,6 +10,7 @@
 * 【core  】     BeanCopier修改规则,可选bean拷贝空字段报错问题(pr#160@Gitee)
 * 【http  】     HttpUtil增加downloadFileFromUrl(pr#1023@Github)
 * 【core  】     增加toEpochMilli方法
+* 【core  】     Validator修改isCitizenId校验(pr#1032@Github)
 
 ### Bug修复#
 * 【poi   】     修复ExcelBase.isXlsx方法判断问题(issue#I1S502@Gitee)

+ 6 - 0
hutool-core/src/main/java/cn/hutool/core/lang/PatternPool.java

@@ -56,6 +56,12 @@ public class PatternPool {
 	 * 移动电话
 	 */
 	public final static Pattern MOBILE = Pattern.compile("(?:0|86|\\+86)?1[3-9]\\d{9}");
+
+	/**
+	 * 18位身份证号码
+	 */
+	public final static Pattern CITIZEN_ID = Pattern.compile("[1-9]\\d{5}[1-2]\\d{3}((0\\d)|(1[0-2]))(([012]\\d)|3[0-1])\\d{3}(\\d|X|x)");
+
 	/**
 	 * 邮编
 	 */

+ 6 - 0
hutool-core/src/main/java/cn/hutool/core/lang/Validator.java

@@ -52,6 +52,12 @@ public class Validator {
 	 * 移动电话
 	 */
 	public final static Pattern MOBILE = PatternPool.MOBILE;
+
+	/**
+	 * 身份证号码
+	 */
+	public final static Pattern CITIZEN_ID = PatternPool.CITIZEN_ID;
+
 	/**
 	 * 邮编
 	 */