personal-id-validator
v1.0.1
Published
validator for Thai personal ID
Downloads
8
Maintainers
Readme
personal-id-validator
validator for personal ID
Installation
npm install personal-id-validator
Usage
const isIdValid = require("personal-id-validator");
const TEST_DATA = [
{
id: "1234567890123", // random number
nationality: "THA",
expected: false,
},
{
id: "1213141516177", // GOD number can pass every test
nationality: "THA",
expected: true,
},
{
id: "8348842918639", // random real data number
nationality: "THA",
expected: true,
},
{
id: "7460843776297", // juristic type number
nationality: "THA",
expected: false,
},
];
// console.log(isIdValid('1234567890', 'THA')); // false
TEST_DATA.forEach((data) => {
const result = isIdValid(data.id, data.nationality);
console.log(
`Nationality: ${data.nationality}, ID: ${
data.id
}, Result: ${result}, Test: ${
data.expected === result ? "PASSED" : "FAILED"
}`
);
});
Release notes
| versions | feature(s) | | ------------- |:-------------:| | 1.0.0 | Validation for ONLY Thai personal ( not include juristic number ) |