mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
IdcardUtil
验证10位身份证兼容中英文括号(issue#IBP6T1@Gitee)
This commit is contained in:
parent
1aec0973f8
commit
bd94c09e91
@ -2,11 +2,12 @@
|
|||||||
# 🚀Changelog
|
# 🚀Changelog
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
# 5.8.37(2025-02-24)
|
# 5.8.37(2025-02-27)
|
||||||
|
|
||||||
### 🐣新特性
|
### 🐣新特性
|
||||||
* 【json 】 ObjectMapper删除重复trim(pr#3859@Github)
|
* 【json 】 ObjectMapper删除重复trim(pr#3859@Github)
|
||||||
* 【core 】 `FileWriter`增加方法,可选是否追加换行符(issue#3858@Github)
|
* 【core 】 `FileWriter`增加方法,可选是否追加换行符(issue#3858@Github)
|
||||||
|
* 【core 】 `IdcardUtil`验证10位身份证兼容中英文括号(issue#IBP6T1@Gitee)
|
||||||
|
|
||||||
### 🐞Bug修复
|
### 🐞Bug修复
|
||||||
* 【setting】 修复`SettingLoader`load未抛出异常导致配置文件无法正常遍历的问题(pr#3868@Github)
|
* 【setting】 修复`SettingLoader`load未抛出异常导致配置文件无法正常遍历的问题(pr#3868@Github)
|
||||||
|
@ -340,6 +340,11 @@ public class IdcardUtil {
|
|||||||
if (StrUtil.isBlank(idcard)) {
|
if (StrUtil.isBlank(idcard)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// issue#IBP6T1 中文空格替换为英文
|
||||||
|
idcard = StrUtil.replace(idcard, "(", "(");
|
||||||
|
idcard = StrUtil.replace(idcard, ")", ")");
|
||||||
|
|
||||||
String[] info = new String[3];
|
String[] info = new String[3];
|
||||||
String card = idcard.replaceAll("[()]", "");
|
String card = idcard.replaceAll("[()]", "");
|
||||||
if (card.length() != 8 && card.length() != 9 && idcard.length() != 10) {
|
if (card.length() != 8 && card.length() != 9 && idcard.length() != 10) {
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package cn.hutool.core.util;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
public class IssueIBP6T1Test {
|
||||||
|
@SuppressWarnings("DataFlowIssue")
|
||||||
|
@Test
|
||||||
|
void isValidCard10Test(){
|
||||||
|
Assertions.assertEquals("true", IdcardUtil.isValidCard10("1608214(1)")[2]);
|
||||||
|
Assertions.assertEquals("true", IdcardUtil.isValidCard10("1608214(1)")[2]);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user