Skip to content

takorn47/thai-citizen-id-validator

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

76 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Thai Citizen ID Validator

Build Status javascript style guide npm

A simpler way to validate Thai Citizen Card ID. πŸ‡ΉπŸ‡­

Further Plans

  • Go 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

Data Type

Input Output
String boolean

Usage

Javascipt ES5

Just import script with commonjs

var validThaiID = require('thai-id-validator') // for ES5

var result = validThaiID(β€˜1101700207030’);
// return true

Javascript ES6 Module

In Javascript file, you can use import, export modules

'use strict';
import validThaiID from 'thai-id-validator';

let result = validThaiID(β€˜1101700207030’);
// return true

Test

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 βœ…
1101700230705 ❌
110170023073 ❌
11017002070d3 ❌
rytege54fsfsf ❌
0 ❌
'-' ❌
'' ❌
null ❌
'blablabla' ❌

(Tested with Jest)

Test Result Screenshot

Compatibility

Supports all major browsers and IE11+

IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
Opera
Opera
11+ 44+ 45+ 11+ 32+

Issues

If you found any 🐞 or feedback, please report the issue here

Contribution

πŸ‘©πŸ»β€πŸ’» Contribute are always welcome.

License

Apache2.0

Code with love πŸ¦‰

About

πŸ¦‰ Validate Thai Citizen ID with 0 dependencies πŸ‡ΉπŸ‡­

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%