Skip to content

Commit

Permalink
Merge pull request #25 from White-Dews/master
Browse files Browse the repository at this point in the history
🚀v1.4.4 修复身份证号码X结尾报错
  • Loading branch information
linyisonger authored Dec 15, 2023
2 parents 6d3376a + 289d607 commit 43542ef
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 🚀v1.4.4 修复身份证号码X结尾报错
🔧: 修复身份证号码X结尾报错

### 🚀v1.4.3 在可及的范围内
➕: inRange 在可及的范围内

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@3r/tool",
"version": "1.4.3",
"version": "1.4.4",
"description": "🏃‍包含一些常用方法例如对象深克隆、递归调用、一一对比/数组交集、并集、差集/二维向量点乘、叉乘/股票KDJ、MACD、RSI、BOLL/验证为空、车牌号、邮箱、身份证、统一社会信用代码、手机号、版本对比/转换日期、星座、身份证解析、字节...持续更新整合",
"main": "index.js",
"type": "module",
Expand Down
5 changes: 4 additions & 1 deletion src/lib/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,10 @@ export class Verify {
sum += (c * Math.pow(2, 17 - i)) % 11
}
sum %= 11
if (Number(num[17]) !== vc[sum]) return false
// 最后一个字符
let lastChar: string | number = num[17]
if (lastChar === 'X') lastChar = 10
if (Number(lastChar) !== vc[sum]) return false
return true
}

Expand Down
4 changes: 2 additions & 2 deletions test/verify.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ let run = function () {
// 这个验证校验码是否正确
console.log('是否是统一社会信用代码', Verify.isUnifiedSocialCreditIdentifier('92230900EUFUTJY536'))
console.log('是否是车牌号', Verify.isVehicleNumber('青G04444'))
console.log('像身份证号', Verify.likeIDCardNumber('622924198810193427'));
console.log('是否是身份证号码', Verify.isCitizenIdentificationNumber('622924198810193427'));
console.log('像身份证号', Verify.likeIDCardNumber('37062219890704584X'));
console.log('是否是身份证号码', Verify.isCitizenIdentificationNumber('37062219890704584X'));
console.log('密码规则校验', Verify.passwordRules('abc123', PasswordRuleEnum.SmallNumber, 6, 20));
// 字符串拓展使用
console.log('是否是null或者""', ''.isNullOrEmpty);
Expand Down

0 comments on commit 43542ef

Please sign in to comment.