1.0.0 • Published 5 months ago

smart-id-validator v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Smart ID Validator - NPM Package

Overview

Smart ID Validator is an NPM package that helps validate various document IDs, including phone numbers, CNICs (National Identity Cards), and passports etc. The package currently supports validation for Pakistan (PK) and is designed to be easily extendable for other countries.

Features

  • Validate Pakistani phone numbers (Mobile, Landline, Toll-Free, Emergency, Shortcodes)
  • Identify the network provider for mobile numbers
  • Validate Pakistani CNICs (13-digit format)
  • Validate Pakistani Passports (2-letter prefix followed by 7 digits)
  • Provide formatted output for better readability
  • Designed for scalability, allowing validation rules for other countries to be added

Installation

Install the package via npm:

npm install smart-id-validator

Or using yarn:

yarn add smart-id-validator

Usage

Import the package

const {
  validatePhoneNumber,
  validateCNIC,
  validatePassport,
} = require("smart-id-validator");

Validate Phone Number

const result = validatePhoneNumber("03123456789", "pk");
console.log(result);

Output Example

{
  "isValid": true,
  "type": "mobile",
  "formatted": "03123456789",
  "network": "Jazz",
  "country": "PK"
}

Validate CNIC

const result = validateCNIC("42101-1234567-9", "pk");
console.log(result);

Output Example

{
  "isValid": true,
  "formatted": "42101-1234567-9",
  "country": "PK"
}

Validate Passport

const result = validatePassport("AB1234567", "pk");
console.log(result);

Output Example

{
  "isValid": true,
  "formatted": "AB1234567",
  "country": "PK"
}

Supported Countries

Currently, Pakistan (PK) is supported. Contributions for other countries are welcome!

Contributing

We welcome contributions to improve and extend this package. To contribute:

  1. Fork the repository.
  2. Create a new branch (feature/new-validation).
  3. Add and test your changes.
  4. Submit a pull request.

Repository

Find the source code and contribute on GitHub:
šŸ”— GitHub Repository

License

This package is released under the MIT License.


Feel free to contribute, report issues, or suggest improvements!