Skip to content

A toolkit for handling Hong Kong ID card number 🪪

License

Notifications You must be signed in to change notification settings

VardyNg/hkid-utils-js

Repository files navigation

npm version NPM

hkid-utils

A JavaScript toolkit to handle Hong Kong Identity Card (HKID) numbers, validate and generate random HKID numbers.

Features 🤖

  • Validate HKID number
    • Supports brackets! ()
    • No matter what case aAbC
  • Generate Random HKID

Installation 📦

npm install hkid-utils

or

yarn add hkid-utils

Usage

const hkidUtils = require('hkid-utils');

// Validate HKID number
hkidUtils.validate('G123456(A)'); // true
hkidUtils.validate('aB987654(3)'); // true
hkidUtils.validate('X3459387'); // true

hkidUtils.validate('123(A)4') // false

// Generate random HKID number
hkidUtils.random(); // 'A123456(7)'

Todo ✅

  • Main Features

    • Validate HKID number
    • Generate random HKID number
      • with "includeBrackets" option
  • DevOps

    • GitHub Actions pipeline to release package to NPM
  • Compatibility

    • ES5 (NodeJS)
    • ES6 (Browser)

Contribution guidelines 📝

Your contributions are always welcome! Even if it's just a typo or a missing comma, we'll appreciate it.

  • Fork the repository 🍴
  • Create a branch with your feature or bug fix 🎋
  • Commit your changes 💽
  • Create a pull request 🧰