1.1.6 ⢠Published 10 months ago
thai-id-validator v1.1.6
Thai Citizen ID Validator
A simpler way to validate Thai Citizen Card ID. š¹š
Minimum Node.js Version ā ļø
This package requires Node.js version 16 or later.
Future Roadmap
- Go Language Implementation Example
- .NET Language Implementation Example
- Thai Passport Number Validation
Read the article
Building Thai Citizen ID Input Validation with WCAG Standard
Installation
$ npm install thai-id-validator
# or
$ yarn add thai-id-validator
# or
$ pnpm add thai-id-validator
# or
$ bun add thai-id-validator
Data Type
Input | Output |
---|---|
String | boolean |
Usage
Javascript / Typescript
In Javascript, Typescript file, you can use import, export modules
import isValidThaiID from 'thai-id-validator';
let result = isValidThaiID(ā1101700207030ā);
console.log(result);
// true
Test
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)
Test Result Screenshot
How to upload test coverage report to codacy
export CODACY_PROJECT_TOKEN=xxxxxxxxx
bun run coverage
bash <(curl -Ls https://coverage.codacy.com/get.sh)
Compatibility
Tested on all modern browsers ā
Issues
If you found any š or feedback, please report the issue here
Contribution
š©š»āš» Contribute are always welcome.
License
Code with love š¦