{"id":17053658,"url":"https://github.com/edditoria/validid","last_synced_at":"2025-04-05T15:07:33.861Z","repository":{"id":55905934,"uuid":"81186241","full_name":"Edditoria/validid","owner":"Edditoria","description":"A Javascript library to validate ID card numbers of Hong Kong, Taiwan, South Korea and China.","archived":false,"fork":false,"pushed_at":"2024-11-15T17:44:45.000Z","size":471,"stargazers_count":40,"open_issues_count":1,"forks_count":19,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-29T14:09:24.730Z","etag":null,"topics":["china","hacktoberfest","hkid","hongkong","korea","npm-package","taiwan","validate","validation","verify"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Edditoria.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-07T08:44:01.000Z","updated_at":"2025-02-21T03:17:24.000Z","dependencies_parsed_at":"2024-08-09T13:32:43.088Z","dependency_job_id":"beb6276d-a860-45c9-9719-5b44fbf37e41","html_url":"https://github.com/Edditoria/validid","commit_stats":{"total_commits":121,"total_committers":5,"mean_commits":24.2,"dds":0.1322314049586777,"last_synced_commit":"9f5a4b6c2e15b96cd463e431a30958862b1c4085"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Edditoria%2Fvalidid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Edditoria%2Fvalidid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Edditoria%2Fvalidid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Edditoria%2Fvalidid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Edditoria","download_url":"https://codeload.github.com/Edditoria/validid/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247353745,"owners_count":20925329,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["china","hacktoberfest","hkid","hongkong","korea","npm-package","taiwan","validate","validation","verify"],"created_at":"2024-10-14T10:12:53.119Z","updated_at":"2025-04-05T15:07:33.836Z","avatar_url":"https://github.com/Edditoria.png","language":"JavaScript","readme":"# Validid: Validate ID Card Number\n\nValidid is a Javascript library to validate ID card number of Hong Kong, Taiwan, South Korea and China. Available in npm and bower.\n\n\\(Validid 是一個 Javascript 程式庫，用作校驗身份證號碼是否基本正確，現時支援香港丶台灣丶韓國和中國 :\\)\n\n## What It Excels\n\n- **Deeper validation**, such as gender, invalid characters in real practice.\n- **Return reason of failure**. Not only true or false. Fit for front-end development.\n- **No dependency** to consume this library.\n- Vanilla Javascript with **JSDoc and Typescript-typing** for your editors and IDE.\n- Come with bundled files to support browsers, including **IE**.\n\n## Quick Examples\n\nMost likely you would import function starting with a word \"validate\":\n\n```js\n// Hong Kong ID card (Supports two leading letters):\nimport { validateHkid } from 'validid/hkid';\nvalidateHkid('AB987654(3)'); // returns { id: 'AB9876543', ok: true, ... }\n\n// Taiwan ID card (including National Identification Card and Resident Certificate):\nimport { validateTwid, identifyTwidType, identifyTwrcVersion } from 'validid/twid';\nvalidateTwid('A123456789'); // returns { ok: true, ... }\n// Some services still need to identify NIC and RC:\nidentifyTwidType('A123456789'); // returns \"NIC\"\nidentifyTwidType('A800000014'); // returns \"RC\"\n// And even to identify old and new RC:\nidentifyTwrcVersion('A800000014'); // returns \"RC_2021\"\nidentifyTwrcVersion('AB12345677'); // returns \"RC_LEGACY\"\n\n// Korea ID card:\nimport { validateKrid } from 'validid/krid';\nvalidateKrid('781030-5668081'); // returns { id: \"7810305668081\", ok: true, ... }\n// No checksum is required according to latest system:\nvalidateKrid('7810305668082'); // returns { id: \"7810305668082\", ok: true, ... }\n\n// China ID card:\nimport { validateCnid } from 'validid/cnid';\nvalidateCnid('120103198806018241'); // returns { ok: true, ... }\n```\n\nCurrently support:\n\n| Module   | Country / Place | Name(s) of Card |\n| -------- | --------------- | --------------- |\n| hkid     | Hong Kong       | Hong Kong ID card, 香港身份證 |\n| twid     | Taiwan          | National Identification Card of the Republic of China, 中華民國國民身分證, 臺灣身分證 |\n| twid     | Taiwan          | Resident Certificate (Uniform ID Numbers), 中華民國居留證 (統一證號) |\n| krid     | South Korea     | South Korea ID card, Resident Registration Number (RRN), 주민등록번호, 住民登錄番號 |\n| cnid     | China           | China ID card, Resident Identity Card of the People's Republic of China (PRC), 中华人民共和国居民身份证 |\n\nThere are vary of exported utilities in this package. They might help your UI.\n\n## Install and Usage\n\nValidid can be installed via npm, Bower, or run in browser directly. You can also consume it using your favorite bundling tools.\n\n### npm and Node.js\n\n```shell\nnpm install validid\n```\n\nImport ES module that you need:\n\n```js\nimport { validateTwid } from 'validid/twid';\n```\n\nRequire in old fashion. No module. All-in-one named export:\n\n```js\nconst { validateTwid } = require('validid'); // point to validid.umd.js\n```\n\n### Bower\n\nYou can download and easily update `validid` via [Bower package manager](https://bower.io/). In Bower, both bundled UMD `\u003cvalidid.umd.js\u003e` and minified UMD `\u003cvalidid.umd.min.js\u003e` are provided.\n\n```shell\nbower install validid\n```\n\nAnd it is ready to serve:\n\n```html\n\u003chtml\u003e\n\t\u003cbody\u003e\n\t\t\u003cscript src=\"bower_components/validid/bundles/validid.umd.js\"\u003e\u003c/script\u003e\n\t\t\u003cscript src=\"your-scripts.js\"\u003e\u003c/script\u003e\n\t\u003c/body\u003e\n\u003c/html\u003e\n```\n\n```js\n/* In your-scripts.js */\nconst result = validid.validateHkid('A9876543');\nconsole.log(result.ok); // false\nconsole.log(result.status.text) // \"INVALID_CHECKSUM\"\n```\n\n### Direct Download\n\nNothing can stop you. Download the UMD file, then use the global name `validid` in your page:\n\n```html\n\u003chtml\u003e\n\t\u003cbody\u003e\n\t\t\u003cscript src=\"validid.umd.js\"\u003e\u003c/script\u003e\n\t\t\u003cscript\u003e\n\t\t\tconst result = validid.validateHkid('A9876543');\n\t\t\tconsole.log(result.ok); // false\n\t\t\tconsole.log(result.status.text) // \"INVALID_CHECKSUM\"\n\t\t\u003c/script\u003e\n\t\u003c/body\u003e\n\u003c/html\u003e\n```\n\n## From v2 to v3\n\nPlease check out [release page on Github](https://github.com/Edditoria/validid/releases) and [migration guide](https://github.com/Edditoria/validid/blob/main/docs/migrate-from-v2.md).\n\n## Help Me Out!\n\nThis repo is in stable and ready for you, while here are some aspects need your help:\n\n- Bugs and new policy that may need an update. However, please do not expose any real ID.\n- Your experience related to LSP, JSDoc, Typescript, etc. Suppose it should work out of the box.\n- Existing code using Validid v2 should not break.\n- Grammar and writing, including code comments.\n- Feature request that might help in server code and UI.\n\n## Copyright and License\n\nCopyright (c) Edditoria. All rights reserved. Code released under the [MIT License](LICENSE.txt). Docs released under [Creative Commons](https://creativecommons.org/licenses/by/4.0/).\n\nAs human-readable summary (but not a substitute for the license):\n\nYou can use it, share it, modify the code and distribute your work for private and commercial uses. If you like, please share your work with me. :pizza:\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedditoria%2Fvalidid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedditoria%2Fvalidid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedditoria%2Fvalidid/lists"}