yrp20260575
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "yrp20260575" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-35616fc21534d06c18e9d85ec4bbf5bf0d968dabcd22d55d2c30f1809f48c43f. Verify the upstream source and version against https://skillhub.cn/skills/user_f1b049da/yrp20260575 before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skillhub.cn
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Validate and parse mainland China 18-digit ID cards: verify the checksum digit and extract date of birth, gender, and age from the ID number. Intended for ID validation, GB11643 conformity checks, and ID number parsing; not for identity authentication.
Introduction source: third_party · user_f1b049da · 1.0.0 Reference
SkillPi interpretation
- Tasks
- Translation pending; see source documentation.
- Testing
- Not tested
Browse files
Frontmatter
name: yrp20260575
slug: yrp20260575
displayName: 身份证校验解析
version: 1.0.0
summary: 中国大陆18位身份证校验位、生日与性别本地解析(GB11643 思路)。
license: MIT
description: 本地校验中国大陆18位身份证校验位,并解析生日、性别与年龄。当用户要身份证校验、GB11643、证件号解析时使用。不做实名核验。身份证校验解析(GB11643 思路)
灵感:能力工具箱 id-validator(自研 GB11643)。
小四原创:浏览器本地验格式与校验位,解析生日/性别;不等于公安实名认证。
何时使用
- 客户/员工表单证件号失焦校验
- 导入名单前批量筛格式错误
- 需要从证件号取生日、性别展示
硬约束
- 仅支持大陆 18 位(末位可为 X);15 位旧证可提示升级,不做静默猜。
- 本地算法:加权校验位 + 出生日期合法性;不请求外部实名接口。
- 输出勿默认展示完整证件号日志;UI 可脱敏中间位。
- 实现要点注释标 小四原创。
- 明确文案:「格式校验通过 ≠ 证件真实有效」。
推荐实现
const WEIGHTS = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
const CHECKS = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2']
export type IdParse = {
valid: boolean
message: string
birth?: string
gender?: '男' | '女'
age?: number
}
// 小四原创:18 位身份证校验+解析
export function parseIdCard(id: string): IdParse {
const raw = String(id || '').trim().toUpperCase()
if (!/^\d{17}[\dX]$/.test(raw)) {
return { valid: false, message: '需18位,末位可为X' }
}
let sum = 0
for (let i = 0; i < 17; i++) sum += Number(raw[i]) * WEIGHTS[i]
const expect = CHECKS[sum % 11]
if (expect !== raw[17]) {
return { valid: false, message: `校验位错误,期望 ${expect}` }
}
const y = Number(raw.slice(6, 10))
const m = Number(raw.slice(10, 12))
const d = Number(raw.slice(12, 14))
const dt = new Date(y, m - 1, d)
if (dt.getFullYear() !== y || dt.getMonth() !== m - 1 || dt.getDate() !== d) {
return { valid: false, message: '出生日期无效' }
}
const gender = Number(raw[16]) % 2 === 0 ? '女' : '男'
const now = new Date()
let age = now.getFullYear() - y
if (now.getMonth() + 1 < m || (now.getMonth() + 1 === m && now.getDate() < d)) age -= 1
return {
valid: true,
message: '校验通过',
birth: `${y}-${String(m).padStart(2, '0')}-${String(d).padStart(2, '0')}`,
gender,
age,
}
}
Agent 步骤
- 实现
parseIdCard;表单失焦调用。 - 成功可回填生日/性别(需用户确认覆盖)。
- 批量导入:只收集
valid===false行号。 - 自测:合法样例、改校验位、非法日期。
不要做
- 声称可替代公安/银行实名核验。
- 把完整证件号上传到不明第三方。
附加
Current listing version
1.0.0
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供中国大陆18位身份证本地校验与解析功能,适用于表单校验、批量导入等高频场景
- 明确区分格式校验与实名核验,符合合规要求
Highlights
- 触发词精准覆盖'身份证校验'、'GB11643'、'证件号解析'等用户常见表达
Areas to improve
-
文档略长且缺少端到端交互示例 Reported severity: Minor
文档约120行,略超理想长度;虽有代码示例但缺少完整的用户交互流程示例
Recommendation: 可适当精简文档,并补充一个完整的用户交互示例(如:用户输入身份证号 -> 校验结果展示 -> 生日性别回填确认)
Highlights
- 结构清晰,包含何时使用、硬约束、实现步骤等完整章节
- frontmatter 完整,版本信息与许可证明确
Highlights
- 提供完整的 TypeScript 实现,覆盖加权校验、日期合法性、年龄计算等核心逻辑
- 明确安全约束,不请求外部实名接口,符合本地处理要求
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.