npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

indian-kyc-validator

v0.1.0

Published

Validate Indian KYC identifiers — PAN, GSTIN, IFSC, phone, and Aadhaar — with checksum-level validation, not just regex.

Readme

Indian-kyc-validator

Validate Indian KYC identifiers — PAN, GSTIN, IFSC, phone numbers, and Aadhaar — with real checksum logic, not just regex pattern matching.

npm version License: MIT

Why this exists

Most "Indian ID validators" on npm only check format with a regex. That catches typos but not fake or fabricated IDs. This package implements the actual checksum algorithms where they're public:

  • GSTIN — verified against the real modulo-36 check-digit algorithm, plus validates the embedded PAN
  • PAN — structure and entity-type validation (4th character maps to Individual, Company, Trust, etc.)
  • IFSC — RBI bank/branch code structure validation
  • Phone — Indian mobile number rules (10 digits, starts with 6–9)
  • Aadhaar — format validation only (see note below on why)

Install

npm install indian-kyc-validator

Quick start

import { isValidPAN, isValidGSTIN, isValidIFSC, isValidPhone, isValidAadhaarFormat } from 'indian-kyc-validator';

isValidPAN('ABCPD1234E');
// { valid: true, entityType: 'Individual' }

isValidGSTIN('27AAACT2727Q1ZW');
// { valid: true, panPortion: 'AAACT2727Q', stateCode: '27' }

isValidIFSC('SBIN0001234');
// { valid: true, bankCode: 'SBIN', branchCode: '001234' }

isValidPhone('+91 98765-43210');
// { valid: true }

isValidAadhaarFormat('234567890123');
// { valid: true }

Every validator returns { valid: boolean, reason?: string } so you can surface a clear error message to users on failure:

isValidGSTIN('27AAACT2727Q1ZX');
// { valid: false, reason: "Checksum mismatch: expected 'W', got 'X'" }

API reference

isValidPAN(pan: string): PANValidationResult

Validates structure (AAAAA9999A) and resolves the entity type from the 4th character.

| Field | Type | Description | |---|---|---| | valid | boolean | Whether the PAN passed validation | | entityType | string? | Individual, Company, HUF, Trust, Partnership Firm, AOP, BOI, Local Authority, Artificial Judicial Person, or Government | | reason | string? | Present only when valid is false |

isValidGSTIN(gstin: string): GSTINValidationResult

Validates structure, state code, embedded PAN, and the modulo-36 check digit.

| Field | Type | Description | |---|---|---| | valid | boolean | Whether the GSTIN passed all checks | | stateCode | string? | 2-digit state code (e.g. '27' = Maharashtra) | | panPortion | string? | The PAN embedded in characters 3–12 | | reason | string? | Present only when valid is false |

isValidIFSC(ifsc: string): IFSCValidationResult

Validates the 11-character RBI bank branch code structure.

| Field | Type | Description | |---|---|---| | valid | boolean | Whether the IFSC passed validation | | bankCode | string? | First 4 characters | | branchCode | string? | Last 6 characters |

isValidPhone(phone: string): ValidationResult

Validates Indian mobile numbers. Accepts optional +91, 91, or 0 prefix, and strips spaces/hyphens automatically.

isValidAadhaarFormat(aadhaar: string): ValidationResult

Validates the 12-digit structure (first digit cannot be 0 or 1).

Note on Aadhaar: this is format validation only, not real verification. Aadhaar numbers use a Verhoeff checksum, but UIDAI hasn't publicly documented the implementation for third-party use, and actual Aadhaar verification is legally restricted to UIDAI-authorized entities under the Aadhaar Act, 2016. Use this to catch obviously malformed input before submitting to an authorized verification service — not as proof the number is real.

Edge cases handled

| Case | Behavior | |---|---| | Lowercase input | Normalized to uppercase before validation | | Extra whitespace | Trimmed automatically | | Phone with +91/0 prefix | Prefix stripped, remaining 10 digits validated | | GSTIN with valid format but wrong checksum | Rejected with the expected vs. actual check digit in reason | | GSTIN with invalid embedded PAN | Rejected, even if the GSTIN's own structure looks correct | | Non-string input (null, number, etc.) | Returns { valid: false } instead of throwing |

Disclaimer

This package validates the structure and checksum of these identifiers. It does not confirm that an ID belongs to a real, registered person or entity, and is not a substitute for official KYC verification through UIDAI, the Income Tax Department, GSTN, or RBI systems. Always verify with the relevant government API for anything compliance-critical.

License

MIT