A simpler way to validate Thai Citizen Card ID. πΉπ
This package requires Node.js version 16 or later.
- Go Language Implementation Example
- .NET Language Implementation Example
- Thai Passport Number Validation
Building Thai Citizen ID Input Validation with WCAG Standard
Works with npm, jsr, yarn, pnpm, bun or deno
$ npm install thai-id-validator
# or
$ yarn add thai-id-validator
# or
$ pnpm add thai-id-validator
# or
$ bun add thai-id-validator
# or
$ pnpm dlx jsr add @jukbot/thai-id-validator
# or
$ deno add jsr:@luca/flag
Input | Output |
---|---|
String | boolean |
In Javascript, Typescript file, you can use import, export modules
import isValidThaiID from 'thai-id-validator';
let result = isValidThaiID(β1101700207030β);
console.log(result);
// true
To run all test cases run the following command
bun run test
You can edit validator.test.js too add your custom test case.
Test Cases | Result |
---|---|
'1112034563562' | β |
'0113200420331' | β |
'1101700230705' | β |
'110170023073' | β |
'11017002070d3' | β |
'rytege54fsfsf' | β |
0 | β |
'-' | β |
'' | β |
null | β |
undefined | β |
'blablabla' | β |
(Tested with Bun)
export CODACY_PROJECT_TOKEN=xxxxxxxxx
bun run coverage
bash <(curl -Ls https://coverage.codacy.com/get.sh)
Tested on all modern browsers β
If you found any π or feedback, please report the issue here
π©π»βπ» Contribute are always welcome.
Code with love π¦