UNPKG

smart-id-validator

Version:

A package to validate official document numbers and other IDs format for various countries.

120 lines (84 loc) • 2.39 kB
# 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: ```sh npm install smart-id-validator ``` Or using yarn: ```sh yarn add smart-id-validator ``` ## Usage ### Import the package ```javascript const { validatePhoneNumber, validateCNIC, validatePassport, } = require("smart-id-validator"); ``` ### Validate Phone Number ```javascript const result = validatePhoneNumber("03123456789", "pk"); console.log(result); ``` #### Output Example ```json { "isValid": true, "type": "mobile", "formatted": "03123456789", "network": "Jazz", "country": "PK" } ``` ### Validate CNIC ```javascript const result = validateCNIC("42101-1234567-9", "pk"); console.log(result); ``` #### Output Example ```json { "isValid": true, "formatted": "42101-1234567-9", "country": "PK" } ``` ### Validate Passport ```javascript const result = validatePassport("AB1234567", "pk"); console.log(result); ``` #### Output Example ```json { "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](https://github.com/zahidlatifdev/smart-id-validator) ## License This package is released under the **MIT License**. --- Feel free to contribute, report issues, or suggest improvements!