A simpler way to validate Thai Citizen Card ID. 🇹🇭
- Go Language Implementation Example
- Thai Passport Number Validation
Building Thai Citizen ID Input Validation with WCAG Standard
$ npm install thai-id-validator
# or
$ yarn add thai-id-validator
# or
$ pnpm add thai-id-validator
# or
$ bun add thai-id-validator
Input | Output |
---|---|
String | boolean |
Just import script with commonjs
var validateThaiID = require('thai-id-validator') // for ES5
var result = validateThaiID(‘1101700207030’);
console.log(result);
// return true
In Javascript file, you can use import, export modules
'use strict';
import validateThaiID from 'thai-id-validator';
let result = validateThaiID(‘1101700207030’);
console.log(result);
// return true
To run all test cases run the following command
npm 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 🦉