indpy is a comprehensive Python library for validating and generating Indian government documents and financial identifiers. It uses official checksum algorithms (GSTIN Mod-36, Aadhaar Verhoeff) where applicable and provides regex-based structural validation for all document types.
- PAN: Permanent Account Number (5 letters + 4 digits + 1 letter)
- TAN: Tax Deduction and Collection Account Number (4 letters + 5 digits + 1 letter)
- Driving License (DL): State + RTO + Year + serial number (15 characters)
- UAN: EPFO Universal Account Number (12 digits, no leading zero)
- ABHA ID: Ayushman Bharat Health Account Number (14 digits)
- GSTIN: GST Identification Number (with Mod-36 checksum verification)
- Aadhaar: 12-digit unique identity (with Verhoeff checksum algorithm)
- Voter ID (EPIC): Electoral ID (3 letters + 7 digits)
- Passport: Passport number (1 letter + 7 digits)
- Mobile: Indian 10-digit format (starts with 6–9)
- IFSC: Bank branch code (4 letters + 0 + 6 alphanumeric)
- Vehicle (RC): Registration certificate (state code + regional code + registration)
- UPI: Unified Payments Interface handle
- CIN: Corporate Identification Number (21-character corporate format)
- Pincode: Indian postal code (6 digits, no leading zero)
- Credit Card: 13–19 digit card numbers (with Luhn Mod-10 checksum)
- Generate valid PAN numbers with realistic format
- Generate valid TAN numbers
- Generate valid Driving License numbers
- Generate valid UAN numbers
- Generate valid ABHA IDs (formatted and raw)
- Generate valid mobile numbers (6–9 prefix)
- Generate valid Aadhaar numbers with mathematically correct Verhoeff checksum
- Generate Voter ID numbers
- Generate Passport numbers
- Generate Vehicle registration numbers
- Generate CIN numbers
- Generate Pincode numbers
- Generate valid Visa-format credit card numbers (Luhn checksum)
Install from PyPI:
pip install indpy_coreNote: The package name on PyPI is indpy_core, but you import it in Python as indpy.
Install for local development:
# Clone the repository
git clone https://github.com/harshgupta2125/Indpy.git
cd Indpy
pip install -e .from indpy import (
is_pan, is_gstin, is_vehicle, is_aadhaar, is_voterid,
is_passport, is_mobile, is_ifsc, is_upi, is_cin, is_pincode,
is_credit_card, is_tan, is_dl, is_uan, is_abha
)
# Validate PAN (Permanent Account Number)
print(is_pan("ABCDE1234F")) # True
# Validate TAN
print(is_tan("DELM12345L")) # True
# Validate Driving License
print(is_dl("MH1220140001234")) # True
# Validate UAN
print(is_uan("100012345678")) # True
# Validate ABHA ID
print(is_abha("91-1234-5678-9012")) # True
# Validate GSTIN (includes official Mod-36 checksum)
print(is_gstin("29ABCDE1234F1Z5")) # True/False based on checksum
# Validate Aadhaar (12-digit with Verhoeff checksum algorithm)
print(is_aadhaar("379980670385")) # True/False based on Verhoeff
# Validate Voter ID (EPIC format)
print(is_voterid("ABC1234567")) # True
# Validate Passport
print(is_passport("A1234567")) # True
# Validate Mobile number (Indian format, 6-9 prefix)
print(is_mobile("9876543210")) # True
# Validate IFSC code (Bank branch)
print(is_ifsc("SBIN0004321")) # True
# Optional: enforce known bank codes
known_banks = {"SBIN", "HDFC", "ICIC"}
print(is_ifsc("SBIN0004321", valid_bank_codes=known_banks)) # True
# Validate Vehicle registration number
print(is_vehicle("DL01CA1234")) # True
# Validate UPI handle
print(is_upi("user@paytm")) # True
# Validate CIN (Corporate Identification Number)
print(is_cin("L99999MH2014PLC241895")) # True
# Validate Pincode (6 digits, no leading zero)
print(is_pincode("560034")) # True
# Validate Credit/Debit Card (Luhn Mod-10)
print(is_credit_card("4111 1111 1111 1111")) # Truefrom indpy import Generate
# Generate random PAN
print(Generate.pan()) # e.g. "BPLPZ5821K"
# Generate random TAN
print(Generate.tan()) # e.g. "DELM12345L"
# Generate random Driving License
print(Generate.dl()) # e.g. "MH1220140001234"
# Generate random UAN
print(Generate.uan()) # e.g. "100123456789"
# Generate random ABHA ID
print(Generate.abha()) # e.g. "91-1234-5678-9012"
# Generate random mobile number
print(Generate.mobile()) # e.g. "9876123450"
# Generate random Aadhaar (with mathematically valid Verhoeff checksum)
print(Generate.aadhaar()) # e.g. "379980670385"
# Generate random Voter ID
print(Generate.voterid()) # e.g. "ABC1234567"
# Generate random Passport
print(Generate.passport()) # e.g. "A1234567"
# Generate random Vehicle registration
print(Generate.vehicle()) # e.g. "DL04CA9921"
# Generate random CIN
print(Generate.cin()) # e.g. "L12345AB2024PLC123456"
# Generate random Pincode
print(Generate.pincode()) # e.g. "560034"
# Generate random Credit Card (Visa-like, Luhn-valid)
print(Generate.credit_card()) # e.g. "4532123456781234"Check version:
indpy --version
# Output: 0.1.8Validate a document:
# Validate PAN
indpy check pan ABCDE1234F
# Output: ✅ PAN Validation Result: True
# Validate TAN
indpy check tan DELM12345L
# Output: ✅ TAN Validation Result: True
# Validate Driving License
indpy check dl MH1220140001234
# Output: ✅ DL Validation Result: True
# Validate UAN
indpy check uan 100012345678
# Output: ✅ UAN Validation Result: True
# Validate ABHA ID
indpy check abha 91-1234-5678-9012
# Output: ✅ ABHA Validation Result: True
# Validate Aadhaar
indpy check aadhaar 379980670385
# Output: ✅ AADHAAR Validation Result: True
# Validate Voter ID
indpy check voterid ABC1234567
# Output: ✅ VOTERID Validation Result: True
# Validate Passport
indpy check passport A1234567
# Output: ✅ PASSPORT Validation Result: True
# Validate CIN
indpy check cin L99999MH2014PLC241895
# Output: ✅ CIN Validation Result: True
# Validate Pincode
indpy check pincode 560034
# Output: ✅ PINCODE Validation Result: True
# Validate Credit Card
indpy check credit_card 4111111111111111
# Output: ✅ CREDIT_CARD Validation Result: TrueGenerate mock data:
# Generate PAN
indpy gen pan
# Output: ABCDE1234F
# Generate TAN
indpy gen tan
# Output: ABCD12345E
# Generate Driving License
indpy gen dl
# Output: MH1220140001234
# Generate UAN
indpy gen uan
# Output: 100123456789
# Generate ABHA ID
indpy gen abha
# Output: 91-1234-5678-9012
# Generate Aadhaar
indpy gen aadhaar
# Output: 379980670385
# Generate Vehicle
indpy gen vehicle
# Output: DL04CA9921
# Generate Voter ID
indpy gen voterid
# Output: ABC1234567
# Generate Passport
indpy gen passport
# Output: A1234567
# Generate CIN
indpy gen cin
# Output: L12345AB2024PLC123456
# Generate Pincode
indpy gen pincode
# Output: 560034
# Generate Credit Card
indpy gen credit_card
# Output: 4XXXXXXXXXXXXXXX| Document | Regex Pattern | Checksum | Notes |
|---|---|---|---|
| PAN | ^[A-Z]{5}[0-9]{4}[A-Z]$ |
Structure only | 10-character format |
| TAN | ^[A-Z]{4}[0-9]{5}[A-Z]$ |
Structure only | TDS/TCS account number |
| Driving License | ^[A-Z]{2}[0-9]{2}[0-9]{4}[0-9]{7}$ |
N/A | Sarathi-style 15-character format |
| UAN | ^[1-9]\d{11}$ |
N/A | EPFO 12-digit employment ID |
| ABHA ID | ^[1-9]\d{13}$ |
N/A | Ayushman Bharat 14-digit health ID |
| GSTIN | ^[0-9]{2}[A-Z]{5}[0-9A-Z]{9}[0-9]$ |
Mod-36 | 15-character GST ID |
| Aadhaar | ^[2-9]\d{11}$ |
Verhoeff | 12-digit unique ID |
| Voter ID | ^[A-Z]{3}[0-9]{7}$ |
N/A | EPIC format |
| Passport | ^[A-Z][0-9]{7}$ |
N/A | 8-character format |
| Mobile | ^[6-9]\d{9}$ |
N/A | 10-digit Indian number |
| IFSC | ^[A-Z]{4}0[A-Z0-9]{6}$ |
N/A | Bank branch code |
| Vehicle | ^[A-Z]{2}\d{1,2}[A-Z]{1,2}\d{1,4}$ |
N/A | State code + registration |
| UPI | ^[a-zA-Z0-9.\-_]+@[a-zA-Z]+$ |
N/A | Payment handle |
| CIN | ^[A-Z][0-9]{5}[A-Z]{2}[0-9]{4}[A-Z]{3}[0-9]{6}$ |
N/A | Corporate ID (21-char) |
| Pincode | ^[1-9]\d{5}$ |
N/A | 6-digit postal code |
| Credit Card | ^\d{13,19}$ |
Luhn (Mod-10) | Global card checksum standard |
| � Testing |
Run the comprehensive test suite:
# Run all tests
python3 -m pytest tests/
# Run specific test file
python3 -m pytest tests/test_lib.py -v
# Run with coverage
python3 -m pytest tests/ --cov=indpyTest files include:
- test_lib.py: Comprehensive tests for all 16 validators and 13 generators
- Coverage includes structural validation, checksum algorithms, and edge cases
Contributions are welcome! Typical workflow:
- Fork the repository
- Create a feature branch:
git checkout -b feature/NewValidator
- Add your validator to indpy/validators.py
- Add corresponding generator to indpy/generators.py
- Update indpy/init.py to export new functions
- Add tests to tests/test_lib.py
- Commit with clear message:
git commit -m "Add new validator for [document type]" - Push and open a pull request
Code Style:
- Follow PEP 8 standards
- Add comprehensive docstrings with regex patterns
- Include usage examples in docstrings
- Test coverage for all new validators
All validators return a boolean (True/False). All generators return a string.
is_pan(pan: str) -> bool
is_tan(tan: str) -> bool
is_dl(dl: str) -> bool
is_uan(uan: str) -> bool
is_abha(abha: str) -> bool
is_gstin(gstin: str) -> bool
is_aadhaar(aadhaar: str) -> bool
is_voterid(voterid: str) -> bool
is_passport(passport: str) -> bool
is_mobile(mobile: str) -> bool
is_ifsc(ifsc: str) -> bool
is_vehicle(vehicle: str) -> bool
is_upi(upi: str) -> bool
is_cin(cin: str) -> bool
is_pincode(pincode: str) -> bool
is_credit_card(card_number: str) -> boolGenerate.pan() -> str
Generate.tan() -> str
Generate.dl() -> str
Generate.uan() -> str
Generate.abha(formatted: bool = True) -> str
Generate.gstin() -> str # Note: Does not generate checksum
Generate.aadhaar() -> str # With valid Verhoeff checksum
Generate.voterid() -> str
Generate.passport() -> str
Generate.mobile() -> str
Generate.vehicle() -> str
Generate.cin() -> str
Generate.pincode() -> str
Generate.credit_card() -> strDistributed under the MIT License. See LICENSE for details.
Version: 0.1.8
- Added UAN validator:
is_uan(...) - Added ABHA validator:
is_abha(...) - Added generators:
Generate.uan()andGenerate.abha(formatted=True) - Added CLI support:
indpy check uan <number>indpy check abha <id>indpy gen uanindpy gen abha
- Updated tests and documentation for both features
- Added TAN validator:
is_tan(...) - Added Driving License validator:
is_dl(...) - Added generators:
Generate.tan()andGenerate.dl() - Added CLI support:
indpy check tan <number>indpy check dl <number>indpy gen tanindpy gen dl
- Updated tests and documentation for both features
- Added credit/debit card validation via Luhn (Mod-10):
is_credit_card(...) - Added valid Visa-style test card generation:
Generate.credit_card() - Added CLI support:
indpy check credit_card <number>indpy gen credit_card
- Updated tests and documentation for new validator and generator
Features:
- ✅ 16 document validators (all functional)
- ✅ 13 mock data generators (production-ready)
- ✅ Official checksum algorithms (Verhoeff, Mod-36, Luhn)
- ✅ Comprehensive documentation with regex patterns
- ✅ CLI support for validation and generation
- ✅ PEP 8 compliant codebase
- ✅ Full test coverage
Roadmap:
- Add Enrollment ID (UID) validator
- Add GST Certificate validator
- Add international passport format support