All Projects → Edditoria → validid

Edditoria / validid

Licence: MIT license
A Javascript library to validate ID card numbers of China, Taiwan, Hong Kong and South Korea

Programming Languages

javascript
184084 projects - #8 most used programming language
coffeescript
4710 projects
HTML
75241 projects

Projects that are alternatives of or similar to validid

jsdoc-api
A programmatic interface for jsdoc3 with a few extra features
Stars: ✭ 55 (+48.65%)
Mutual labels:  npm-package, javascript-library
ionic-image-upload
Ionic Plugin for Uploading Images to Amazon S3
Stars: ✭ 26 (-29.73%)
Mutual labels:  npm-package, javascript-library
react-circle-flags
🚀 A React component with a collection of 300+ minimal circular SVG country flags. Wrapper of HatScripts/circle-flags
Stars: ✭ 29 (-21.62%)
Mutual labels:  npm-package, javascript-library
validate-polish
Utility library for validation of PESEL, NIP, REGON, identity card etc. Aimed mostly at Polish enviroment. [Polish] Walidacja numerów pesel, nip, regon, dowodu osobistego.
Stars: ✭ 31 (-16.22%)
Mutual labels:  javascript-library, identity-card
Ag Psd
Javascript library for reading and writing PSD files
Stars: ✭ 135 (+264.86%)
Mutual labels:  npm-package, javascript-library
example-typescript-package
Example TypeScript Package ready to be published on npm & Tutorial / Instruction / Workflow for 2021
Stars: ✭ 71 (+91.89%)
Mutual labels:  npm-package, javascript-library
html-to-react
A lightweight library that converts raw HTML to a React DOM structure.
Stars: ✭ 696 (+1781.08%)
Mutual labels:  npm-package, javascript-library
Length.js
📏 JavaScript library for length units conversion.
Stars: ✭ 292 (+689.19%)
Mutual labels:  npm-package, javascript-library
Byte Size
Isomorphic function to convert a bytes value (e.g. 3456) to a human-readable string ('3.5 kB')
Stars: ✭ 33 (-10.81%)
Mutual labels:  npm-package, javascript-library
Rando.js
The world's easiest, most powerful random function.
Stars: ✭ 659 (+1681.08%)
Mutual labels:  npm-package, javascript-library
FilterInputJs
Tiny and Powerful Library for limit an entry (text box,input) as number,string or more...
Stars: ✭ 37 (+0%)
Mutual labels:  javascript-library, validate
Typy
Minimal JavaScript type checking library
Stars: ✭ 215 (+481.08%)
Mutual labels:  npm-package, javascript-library
ansicolor
A JavaScript ANSI color/style management. ANSI parsing. ANSI to CSS. Small, clean, no dependencies.
Stars: ✭ 91 (+145.95%)
Mutual labels:  npm-package, javascript-library
djb2a
DJB2a non-cryptographic hash function
Stars: ✭ 31 (-16.22%)
Mutual labels:  npm-package
SARS2-Stat-KR
중국 우한 바이러스 한국 확진자 통계
Stars: ✭ 25 (-32.43%)
Mutual labels:  korea
twse-captcha-solver-dl4j
A deeplearning based captcha solver for http://bsr.twse.com.tw/bshtm/
Stars: ✭ 29 (-21.62%)
Mutual labels:  taiwan
BitFact
🛡️ Robust data integrity tool. Prove data, text, & files using the Ethereum blockchain.
Stars: ✭ 42 (+13.51%)
Mutual labels:  javascript-library
ts-ci
🚀 A starter for TS projects meant to be published on NPM.
Stars: ✭ 282 (+662.16%)
Mutual labels:  npm-package
space-client
File Upload (encrypted), File Sharing, Filecoin Markets (TBD), and User Controlled Data. You can access same methods from the Space Daemon using our JS client, so you don't need to worry about gRPC calls.
Stars: ✭ 73 (+97.3%)
Mutual labels:  javascript-library
npmlint
[DEPRECATED] Lint your npm package
Stars: ✭ 57 (+54.05%)
Mutual labels:  npm-package

Validid: Validate ID Card Number

Validid is a Javascript library to validate ID Card numbers of China, Taiwan, Hong Kong and South Korea. Available in npm and bower.

(Validid 是一個 Javascript 程式庫,用作校驗身份證號碼是否基本正確,現時支援中國丶台灣丶香港和韓國 :)

What It Excels

  • Deeper validation, more than checksum, e.g. gender, excluding characters in real practice.
  • Same code base and usage in front-end and back-end.
  • Validate multiple card types, or selectively import individual modules (Welcome requests for more!).
  • Supports IE.

Quick Examples

Simply provide cardType and ID. validid will return true or false:

// China ID card
validid.cnid('120103198806018241'); // return true

// Taiwan ID card
validid.twid('A123456789'); // return true

// Taiwan Resident Certificate 2021
validid.twrc('A800000014'); // return true
// while validate old format
validid.twrc('AB12345677'); // return true
// old format "only" (not recommended, though)
validid.twrcLegacy('A800000014'); // return false
validid.twrcLegacy('AB12345677'); // return true

// Hong Kong ID card: supports two leading letters
validid.hkid('AB9876543'); // return true

// Korea ID card
validid.krid('781030-5668081'); // return true

Currently support:

cardType Country / Place Name(s) of Card
cnid China China ID card, Resident Identity Card of the People's Republic of China (PRC), 中华人民共和国居民身份证
hkid Hong Kong Hong Kong ID card, 香港身份證
twid Taiwan Taiwan ID card, National Identification Card of the Republic of China, 中華民國國民身分證, 臺灣身分證
twrc Taiwan Taiwan Resident Certificate (Uniform ID Numbers), 中華民國居留證 (統一證號)
krid South Korea South Korea ID card, Resident Registration Number (RRN), 주민등록번호, 住民登錄番號

Install and Usage

Validid can be installed via npm, Bower, or run in browser directly. You can also consume it using your favorite bundling tools.

npm

npm install validid

Require in node.js:

var validid = require('validid'); // point to validid.umd.min.js
validid.cnid('120103198806018241'); // return true

Or, import module(s) in Node 13+:

// import the whole validid object
import validid from 'validid/esm/index.mjs';
// import individual module function
import krid from 'validid/esm/krid.mjs';
// import utility in your project
import normalize from 'validid/esm/utils/normalize.mjs';

validid.krid('781030-5668081'); // return true
krid('781030-5668081'); // return true
normalize('g123456(a)'); // return 'G123456A'

Bundling Tools 🆕

In v2, validid bundles ESM and UMD formats. You can make use of them in bundling tools such as Webpack, Rollup and more. Please see <package.json>:

{
  "//": "...",
  "main": "bundles/validid.umd.min.js",
  "module": "bundles/validid.esm.mjs",
  "//": "..."
}

In most cases, you may import validid by resolving "module" rather than "main".

Bower

You can download and easily update validid via Bower package manager. In Bower, both bundled UMD <validid.umd.js> and minified UMD <validid.umd.min.js> are provided.

bower install validid

And it is ready to serve in front-end environment:

<html>
	<head>
		<script src="bower_components/validid/bundles/validid.umd.js"></script>
		<script src="test.js"></script>
	</head>
</html>
/* In test.js */
console.log(validid.cnid('120103198806018241')); // true

Direct Download

Nothing can stop you. Download the file validid.umd.js and refer it in your html file:

<html>
	<head>
		<script src="validid.umd.js"></script>
	</head>
</html>

And you are ready to go:

console.log(validid.cnid('120103198806018241')); // true

Help Me Out!

This repo is in stable and ready for you, while here are some aspects need your help:

  • Bugs and new policy that may need an update. However, please do not expose any real ID.
  • Grammar and writing, including code comments.
  • Open an issue if you want more than simple true/false validation.
  • I'm not sure why developers need an ID generator. Please tell me your need.
  • Any suggestion you want to make.

Copyright and License

Copyright (c) 2017-2020 Edditoria. All rights reserved. Code released under the MIT License. Docs released under Creative Commons.

As human-readable summary (but not a substitute for the license):

You 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. 🍕

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].