indiaid 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- indiaid-0.1.0/.github/workflows/publish.yml +42 -0
- indiaid-0.1.0/.github/workflows/tests.yml +47 -0
- indiaid-0.1.0/.gitignore +61 -0
- indiaid-0.1.0/CHANGELOG.md +26 -0
- indiaid-0.1.0/CONTRIBUTING.md +57 -0
- indiaid-0.1.0/LICENSE +21 -0
- indiaid-0.1.0/PKG-INFO +194 -0
- indiaid-0.1.0/README.md +150 -0
- indiaid-0.1.0/demo.py +209 -0
- indiaid-0.1.0/docs/supported_documents.md +112 -0
- indiaid-0.1.0/examples/django_example.py +25 -0
- indiaid-0.1.0/examples/fastapi_example.py +23 -0
- indiaid-0.1.0/pyproject.toml +95 -0
- indiaid-0.1.0/src/indiaid/__init__.py +146 -0
- indiaid-0.1.0/src/indiaid/base.py +84 -0
- indiaid-0.1.0/src/indiaid/exceptions.py +23 -0
- indiaid-0.1.0/src/indiaid/integrations/__init__.py +5 -0
- indiaid-0.1.0/src/indiaid/integrations/django.py +51 -0
- indiaid-0.1.0/src/indiaid/integrations/drf.py +40 -0
- indiaid-0.1.0/src/indiaid/integrations/pydantic.py +63 -0
- indiaid-0.1.0/src/indiaid/py.typed +1 -0
- indiaid-0.1.0/src/indiaid/registry.py +70 -0
- indiaid-0.1.0/src/indiaid/utils.py +194 -0
- indiaid-0.1.0/src/indiaid/validators/__init__.py +25 -0
- indiaid-0.1.0/src/indiaid/validators/aadhaar.py +69 -0
- indiaid-0.1.0/src/indiaid/validators/driving_licence.py +89 -0
- indiaid-0.1.0/src/indiaid/validators/gstin.py +74 -0
- indiaid-0.1.0/src/indiaid/validators/ifsc.py +48 -0
- indiaid-0.1.0/src/indiaid/validators/pan.py +62 -0
- indiaid-0.1.0/src/indiaid/validators/passport.py +63 -0
- indiaid-0.1.0/src/indiaid/validators/phone.py +72 -0
- indiaid-0.1.0/src/indiaid/validators/pincode.py +68 -0
- indiaid-0.1.0/src/indiaid/validators/vehicle.py +117 -0
- indiaid-0.1.0/src/indiaid/validators/voter_id.py +67 -0
- indiaid-0.1.0/test_runner.py +84 -0
- indiaid-0.1.0/tests/conftest.py +9 -0
- indiaid-0.1.0/tests/integrations/test_django.py +22 -0
- indiaid-0.1.0/tests/integrations/test_pydantic.py +38 -0
- indiaid-0.1.0/tests/test_aadhaar.py +66 -0
- indiaid-0.1.0/tests/test_driving_licence.py +39 -0
- indiaid-0.1.0/tests/test_gstin.py +52 -0
- indiaid-0.1.0/tests/test_ifsc.py +34 -0
- indiaid-0.1.0/tests/test_pan.py +45 -0
- indiaid-0.1.0/tests/test_passport.py +33 -0
- indiaid-0.1.0/tests/test_phone.py +34 -0
- indiaid-0.1.0/tests/test_pincode.py +35 -0
- indiaid-0.1.0/tests/test_registry.py +91 -0
- indiaid-0.1.0/tests/test_vehicle.py +109 -0
- indiaid-0.1.0/tests/test_voter_id.py +32 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build-and-publish:
|
|
10
|
+
name: Build distribution and publish to PyPI
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
environment:
|
|
13
|
+
name: pypi
|
|
14
|
+
url: https://pypi.org/p/indiaid
|
|
15
|
+
permissions:
|
|
16
|
+
id-token: write # Mandatory for PyPI Trusted Publishing via OIDC
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Set up Python
|
|
22
|
+
uses: actions/setup-python@v5
|
|
23
|
+
with:
|
|
24
|
+
python-version: "3.12"
|
|
25
|
+
|
|
26
|
+
- name: Install build tools
|
|
27
|
+
run: |
|
|
28
|
+
python -m pip install --upgrade pip
|
|
29
|
+
pip install build twine
|
|
30
|
+
|
|
31
|
+
- name: Build sdist and wheel
|
|
32
|
+
run: |
|
|
33
|
+
python -m build
|
|
34
|
+
|
|
35
|
+
- name: Check package distribution
|
|
36
|
+
run: |
|
|
37
|
+
twine check dist/*
|
|
38
|
+
|
|
39
|
+
- name: Publish to PyPI
|
|
40
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
41
|
+
with:
|
|
42
|
+
skip-existing: true
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
fail-fast: false
|
|
14
|
+
matrix:
|
|
15
|
+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
|
|
20
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
21
|
+
uses: actions/setup-python@v5
|
|
22
|
+
with:
|
|
23
|
+
python-version: ${{ matrix.python-version }}
|
|
24
|
+
|
|
25
|
+
- name: Install dependencies
|
|
26
|
+
run: |
|
|
27
|
+
python -m pip install --upgrade pip
|
|
28
|
+
pip install -e ".[dev,all]"
|
|
29
|
+
|
|
30
|
+
- name: Run linting
|
|
31
|
+
run: |
|
|
32
|
+
ruff check .
|
|
33
|
+
|
|
34
|
+
- name: Run type checking
|
|
35
|
+
run: |
|
|
36
|
+
mypy src
|
|
37
|
+
|
|
38
|
+
- name: Run tests with coverage
|
|
39
|
+
run: |
|
|
40
|
+
pytest --cov=indiaid --cov-report=xml
|
|
41
|
+
|
|
42
|
+
- name: Upload coverage to Codecov
|
|
43
|
+
uses: codecov/codecov-action@v4
|
|
44
|
+
if: matrix.python-version == '3.12'
|
|
45
|
+
continue-on-error: true
|
|
46
|
+
with:
|
|
47
|
+
file: ./coverage.xml
|
indiaid-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# Virtual environments
|
|
30
|
+
venv/
|
|
31
|
+
.venv/
|
|
32
|
+
ENV/
|
|
33
|
+
env/
|
|
34
|
+
|
|
35
|
+
# IDE & editors
|
|
36
|
+
.vscode/
|
|
37
|
+
.idea/
|
|
38
|
+
*.swp
|
|
39
|
+
*.swo
|
|
40
|
+
|
|
41
|
+
# Testing & coverage
|
|
42
|
+
.tox/
|
|
43
|
+
.nox/
|
|
44
|
+
.coverage
|
|
45
|
+
.coverage.*
|
|
46
|
+
.cache
|
|
47
|
+
nosetests.xml
|
|
48
|
+
coverage.xml
|
|
49
|
+
*.cover
|
|
50
|
+
*.py,cover
|
|
51
|
+
.hypothesis/
|
|
52
|
+
.pytest_cache/
|
|
53
|
+
cover/
|
|
54
|
+
|
|
55
|
+
# Type checking
|
|
56
|
+
.mypy_cache/
|
|
57
|
+
.dmypy.json
|
|
58
|
+
dmypy.json
|
|
59
|
+
|
|
60
|
+
# Ruff / Linters
|
|
61
|
+
.ruff_cache/
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.0] - Unreleased
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Initial project structure with `src/` layout and PEP 561 typing support (`py.typed`).
|
|
12
|
+
- Core registry architecture with string-based and direct validator access.
|
|
13
|
+
- Validators for:
|
|
14
|
+
- Aadhaar (Verhoeff checksum, starting digit rules, UIDAI compliant masking)
|
|
15
|
+
- PAN (Structure check, entity type parsing, last name initial check)
|
|
16
|
+
- GSTIN (15-character check, state code, PAN embedded verification, Luhn mod-36 checksum)
|
|
17
|
+
- Passport (8-character Indian passport format)
|
|
18
|
+
- Driving Licence (State RTO code, year validation)
|
|
19
|
+
- Voter ID / EPIC (Standard & legacy formats)
|
|
20
|
+
- Vehicle Registration Number (State RTO formats & Bharat Series)
|
|
21
|
+
- Bank IFSC (RBI structure check)
|
|
22
|
+
- Mobile Phone (Indian 10-digit formats with prefixes)
|
|
23
|
+
- Pincode (6-digit postal code & postal circle validation)
|
|
24
|
+
- Integrations:
|
|
25
|
+
- Pydantic v2 custom types
|
|
26
|
+
- Django & Django REST Framework validators
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Contributing to IndiaID
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to `indiaid`! We welcome contributions for adding new document types, improving validation rules, writing tests, or adding framework integrations.
|
|
4
|
+
|
|
5
|
+
## Development Setup
|
|
6
|
+
|
|
7
|
+
1. Clone the repository:
|
|
8
|
+
```bash
|
|
9
|
+
git clone https://github.com/username/indiaid.git
|
|
10
|
+
cd indiaid
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
2. Create and activate a virtual environment:
|
|
14
|
+
```bash
|
|
15
|
+
python -m venv .venv
|
|
16
|
+
# Windows:
|
|
17
|
+
.venv\Scripts\activate
|
|
18
|
+
# Linux/macOS:
|
|
19
|
+
source .venv/bin/activate
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
3. Install in editable mode with development dependencies:
|
|
23
|
+
```bash
|
|
24
|
+
pip install -e ".[dev]"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Adding a New Document Type
|
|
28
|
+
|
|
29
|
+
To add support for a new Indian document:
|
|
30
|
+
|
|
31
|
+
1. Create a validator file in `src/indiaid/validators/<doc_name>.py`.
|
|
32
|
+
2. Inherit from `BaseValidator` in `src/indiaid/base.py`.
|
|
33
|
+
3. Use the `@register("<doc_name>", "<alias>")` decorator.
|
|
34
|
+
4. Implement:
|
|
35
|
+
- `validate(self, value: str) -> ValidationResult`
|
|
36
|
+
- `mask(self, value: str) -> str` (if applicable)
|
|
37
|
+
5. Export the validator in `src/indiaid/validators/__init__.py`.
|
|
38
|
+
6. Add comprehensive unit tests in `tests/test_<doc_name>.py`.
|
|
39
|
+
7. Document the validation rules in `docs/supported_documents.md`.
|
|
40
|
+
|
|
41
|
+
## Running Tests and Linting
|
|
42
|
+
|
|
43
|
+
Run tests:
|
|
44
|
+
```bash
|
|
45
|
+
pytest
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Run code formatting and linting:
|
|
49
|
+
```bash
|
|
50
|
+
ruff check .
|
|
51
|
+
ruff format .
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Run static type checking:
|
|
55
|
+
```bash
|
|
56
|
+
mypy src
|
|
57
|
+
```
|
indiaid-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 IndiaID Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
indiaid-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: indiaid
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Comprehensive, zero-dependency validation and masking library for Indian IDs and documents.
|
|
5
|
+
Project-URL: Homepage, https://github.com/username/indiaid
|
|
6
|
+
Project-URL: Documentation, https://github.com/username/indiaid#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/username/indiaid
|
|
8
|
+
Project-URL: Issues, https://github.com/username/indiaid/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/username/indiaid/blob/main/CHANGELOG.md
|
|
10
|
+
Author: IndiaID Contributors
|
|
11
|
+
License: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: aadhaar,driving-licence,fintech,gstin,ifsc,india,kyc,pan,passport,pincode,validation,voter-id
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
25
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
26
|
+
Classifier: Typing :: Typed
|
|
27
|
+
Requires-Python: >=3.9
|
|
28
|
+
Provides-Extra: all
|
|
29
|
+
Requires-Dist: django>=4.2; extra == 'all'
|
|
30
|
+
Requires-Dist: pydantic>=2.0; extra == 'all'
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: build>=1.2.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: mypy>=1.9.0; extra == 'dev'
|
|
34
|
+
Requires-Dist: pydantic>=2.0; extra == 'dev'
|
|
35
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
|
|
36
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
37
|
+
Requires-Dist: ruff>=0.4.0; extra == 'dev'
|
|
38
|
+
Requires-Dist: twine>=5.0.0; extra == 'dev'
|
|
39
|
+
Provides-Extra: django
|
|
40
|
+
Requires-Dist: django>=4.2; extra == 'django'
|
|
41
|
+
Provides-Extra: pydantic
|
|
42
|
+
Requires-Dist: pydantic>=2.0; extra == 'pydantic'
|
|
43
|
+
Description-Content-Type: text/markdown
|
|
44
|
+
|
|
45
|
+
# IndiaID 🇮🇳
|
|
46
|
+
|
|
47
|
+
[](https://pypi.org/project/indiaid/)
|
|
48
|
+
[](https://pypi.org/project/indiaid/)
|
|
49
|
+
[](https://opensource.org/licenses/MIT)
|
|
50
|
+
|
|
51
|
+
**IndiaID** is a lightweight, zero-dependency Python library for validating, parsing, and masking Indian government IDs, identity numbers, and document codes.
|
|
52
|
+
|
|
53
|
+
Designed for FinTechs, KYC onboarding pipelines, HRMS, and modern web applications.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## ✨ Features
|
|
58
|
+
|
|
59
|
+
- ⚡ **Zero Runtime Dependencies**: Pure Python 3.9+ standard library.
|
|
60
|
+
- 🧮 **Algorithmic Validation**: Verhoeff algorithm for Aadhaar, Luhn mod-36 for GSTIN.
|
|
61
|
+
- 🎭 **Privacy & Masking**: UIDAI-compliant Aadhaar masking (`XXXXXXXX1234`).
|
|
62
|
+
- 🧩 **Metadata Extraction**: Parse state, entity type (PAN), issue year (DL), and circle.
|
|
63
|
+
- 🔌 **Framework Integrations**: First-class support for **Pydantic v2**, **Django**, and **DRF**.
|
|
64
|
+
- 🛡️ **Fully Type-Hinted**: PEP 561 compliant (`py.typed`) with strict typing.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## 📦 Installation
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pip install indiaid
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
With optional integrations:
|
|
75
|
+
```bash
|
|
76
|
+
# With Pydantic v2 support
|
|
77
|
+
pip install "indiaid[pydantic]"
|
|
78
|
+
|
|
79
|
+
# With Django support
|
|
80
|
+
pip install "indiaid[django]"
|
|
81
|
+
|
|
82
|
+
# With all integrations
|
|
83
|
+
pip install "indiaid[all]"
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## 🚀 Quickstart
|
|
89
|
+
|
|
90
|
+
### 1. Direct Document Imports (Most Popular)
|
|
91
|
+
|
|
92
|
+
Import document validators directly:
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
from indiaid import pan, aadhaar, gstin
|
|
96
|
+
|
|
97
|
+
# Validate directly (returns True / False)
|
|
98
|
+
pan.is_valid("ABCPE1234F") # True
|
|
99
|
+
aadhaar.is_valid("3675 9834 6215") # True (checks Verhoeff checksum)
|
|
100
|
+
|
|
101
|
+
# Or use callable shortcut
|
|
102
|
+
if pan("ABCPE1234F"):
|
|
103
|
+
print("Valid PAN!")
|
|
104
|
+
|
|
105
|
+
# Mask for privacy / compliance
|
|
106
|
+
pan.mask("ABCPE1234F") # "ABXXXXXX4F"
|
|
107
|
+
aadhaar.mask("3675 9834 6215") # "XXXXXXXX6215"
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### 2. Rich Validation & Metadata Extraction
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
from indiaid import validate
|
|
114
|
+
|
|
115
|
+
# Parse PAN details
|
|
116
|
+
result = validate("pan", "ABCPE1234F")
|
|
117
|
+
if result.is_valid:
|
|
118
|
+
print(result.cleaned_value) # "ABCPE1234F"
|
|
119
|
+
print(result.metadata["entity_type"]) # "Individual"
|
|
120
|
+
print(result.metadata["surname_initial"]) # "E"
|
|
121
|
+
|
|
122
|
+
# Parse GSTIN details
|
|
123
|
+
result = validate("gstin", "27ABCPE1234F1Z5")
|
|
124
|
+
if result.is_valid:
|
|
125
|
+
print(result.metadata["state_code"]) # "27"
|
|
126
|
+
print(result.metadata["state_name"]) # "Maharashtra"
|
|
127
|
+
print(result.metadata["pan"]) # "ABCPE1234F"
|
|
128
|
+
|
|
129
|
+
# Vehicle State Lookup
|
|
130
|
+
from indiaid import vehicle
|
|
131
|
+
print(vehicle.state("MH01A2925")) # "Maharashtra"
|
|
132
|
+
print(vehicle.state("MH")) # "Maharashtra"
|
|
133
|
+
print(vehicle.state("22BH1234AA")) # "Bharat Series (All India)"
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### 3. Masking for Privacy Compliance
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
import indiaid
|
|
140
|
+
|
|
141
|
+
# Mask Aadhaar for UIDAI/RBI compliance
|
|
142
|
+
masked = indiaid.mask("aadhaar", "3675 9834 6215")
|
|
143
|
+
print(masked) # "XXXXXXXX6215"
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## 📑 Supported Documents
|
|
149
|
+
|
|
150
|
+
| Document | Type Key | Algorithm / Checks | Masking |
|
|
151
|
+
| :--- | :--- | :--- | :---: |
|
|
152
|
+
| **Aadhaar** | `aadhaar` | Verhoeff checksum, starting digit rules | ✅ |
|
|
153
|
+
| **PAN Card** | `pan` | Entity type, surname initial, sequence | ✅ |
|
|
154
|
+
| **GSTIN** | `gstin` | State code, embedded PAN, Luhn mod-36 | ✅ |
|
|
155
|
+
| **Passport** | `passport` | 8-character Indian passport format | ✅ |
|
|
156
|
+
| **Driving Licence** | `driving_licence`, `dl` | State RTO code, year validation | ❌ |
|
|
157
|
+
| **Voter ID (EPIC)** | `voter_id`, `epic` | 10-char standard + legacy formats | ✅ |
|
|
158
|
+
| **Vehicle RC** | `vehicle`, `rc` | State RTO codes + Bharat (BH) series | ❌ |
|
|
159
|
+
| **Bank IFSC** | `ifsc` | RBI 11-char alphanumeric format | ❌ |
|
|
160
|
+
| **Mobile Phone** | `phone` | Indian 10-digit mobile series | ✅ |
|
|
161
|
+
| **Pincode** | `pincode` | 6-digit postal circle validation | ❌ |
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## 🛠️ Framework Integrations
|
|
166
|
+
|
|
167
|
+
### Pydantic v2
|
|
168
|
+
|
|
169
|
+
```python
|
|
170
|
+
from pydantic import BaseModel
|
|
171
|
+
from indiaid.integrations.pydantic import AadhaarStr, PanStr, GstinStr
|
|
172
|
+
|
|
173
|
+
class UserKYC(BaseModel):
|
|
174
|
+
pan: PanStr
|
|
175
|
+
aadhaar: AadhaarStr
|
|
176
|
+
gstin: GstinStr
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Django Models & Forms
|
|
180
|
+
|
|
181
|
+
```python
|
|
182
|
+
from django.db import models
|
|
183
|
+
from indiaid.integrations.django import validate_pan, validate_aadhaar
|
|
184
|
+
|
|
185
|
+
class Profile(models.Model):
|
|
186
|
+
pan = models.CharField(max_length=10, validators=[validate_pan])
|
|
187
|
+
aadhaar = models.CharField(max_length=12, validators=[validate_aadhaar])
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## 📄 License
|
|
193
|
+
|
|
194
|
+
MIT © IndiaID Contributors
|
indiaid-0.1.0/README.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# IndiaID 🇮🇳
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/indiaid/)
|
|
4
|
+
[](https://pypi.org/project/indiaid/)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
**IndiaID** is a lightweight, zero-dependency Python library for validating, parsing, and masking Indian government IDs, identity numbers, and document codes.
|
|
8
|
+
|
|
9
|
+
Designed for FinTechs, KYC onboarding pipelines, HRMS, and modern web applications.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## ✨ Features
|
|
14
|
+
|
|
15
|
+
- ⚡ **Zero Runtime Dependencies**: Pure Python 3.9+ standard library.
|
|
16
|
+
- 🧮 **Algorithmic Validation**: Verhoeff algorithm for Aadhaar, Luhn mod-36 for GSTIN.
|
|
17
|
+
- 🎭 **Privacy & Masking**: UIDAI-compliant Aadhaar masking (`XXXXXXXX1234`).
|
|
18
|
+
- 🧩 **Metadata Extraction**: Parse state, entity type (PAN), issue year (DL), and circle.
|
|
19
|
+
- 🔌 **Framework Integrations**: First-class support for **Pydantic v2**, **Django**, and **DRF**.
|
|
20
|
+
- 🛡️ **Fully Type-Hinted**: PEP 561 compliant (`py.typed`) with strict typing.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 📦 Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install indiaid
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
With optional integrations:
|
|
31
|
+
```bash
|
|
32
|
+
# With Pydantic v2 support
|
|
33
|
+
pip install "indiaid[pydantic]"
|
|
34
|
+
|
|
35
|
+
# With Django support
|
|
36
|
+
pip install "indiaid[django]"
|
|
37
|
+
|
|
38
|
+
# With all integrations
|
|
39
|
+
pip install "indiaid[all]"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 🚀 Quickstart
|
|
45
|
+
|
|
46
|
+
### 1. Direct Document Imports (Most Popular)
|
|
47
|
+
|
|
48
|
+
Import document validators directly:
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from indiaid import pan, aadhaar, gstin
|
|
52
|
+
|
|
53
|
+
# Validate directly (returns True / False)
|
|
54
|
+
pan.is_valid("ABCPE1234F") # True
|
|
55
|
+
aadhaar.is_valid("3675 9834 6215") # True (checks Verhoeff checksum)
|
|
56
|
+
|
|
57
|
+
# Or use callable shortcut
|
|
58
|
+
if pan("ABCPE1234F"):
|
|
59
|
+
print("Valid PAN!")
|
|
60
|
+
|
|
61
|
+
# Mask for privacy / compliance
|
|
62
|
+
pan.mask("ABCPE1234F") # "ABXXXXXX4F"
|
|
63
|
+
aadhaar.mask("3675 9834 6215") # "XXXXXXXX6215"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 2. Rich Validation & Metadata Extraction
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
from indiaid import validate
|
|
70
|
+
|
|
71
|
+
# Parse PAN details
|
|
72
|
+
result = validate("pan", "ABCPE1234F")
|
|
73
|
+
if result.is_valid:
|
|
74
|
+
print(result.cleaned_value) # "ABCPE1234F"
|
|
75
|
+
print(result.metadata["entity_type"]) # "Individual"
|
|
76
|
+
print(result.metadata["surname_initial"]) # "E"
|
|
77
|
+
|
|
78
|
+
# Parse GSTIN details
|
|
79
|
+
result = validate("gstin", "27ABCPE1234F1Z5")
|
|
80
|
+
if result.is_valid:
|
|
81
|
+
print(result.metadata["state_code"]) # "27"
|
|
82
|
+
print(result.metadata["state_name"]) # "Maharashtra"
|
|
83
|
+
print(result.metadata["pan"]) # "ABCPE1234F"
|
|
84
|
+
|
|
85
|
+
# Vehicle State Lookup
|
|
86
|
+
from indiaid import vehicle
|
|
87
|
+
print(vehicle.state("MH01A2925")) # "Maharashtra"
|
|
88
|
+
print(vehicle.state("MH")) # "Maharashtra"
|
|
89
|
+
print(vehicle.state("22BH1234AA")) # "Bharat Series (All India)"
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 3. Masking for Privacy Compliance
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
import indiaid
|
|
96
|
+
|
|
97
|
+
# Mask Aadhaar for UIDAI/RBI compliance
|
|
98
|
+
masked = indiaid.mask("aadhaar", "3675 9834 6215")
|
|
99
|
+
print(masked) # "XXXXXXXX6215"
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## 📑 Supported Documents
|
|
105
|
+
|
|
106
|
+
| Document | Type Key | Algorithm / Checks | Masking |
|
|
107
|
+
| :--- | :--- | :--- | :---: |
|
|
108
|
+
| **Aadhaar** | `aadhaar` | Verhoeff checksum, starting digit rules | ✅ |
|
|
109
|
+
| **PAN Card** | `pan` | Entity type, surname initial, sequence | ✅ |
|
|
110
|
+
| **GSTIN** | `gstin` | State code, embedded PAN, Luhn mod-36 | ✅ |
|
|
111
|
+
| **Passport** | `passport` | 8-character Indian passport format | ✅ |
|
|
112
|
+
| **Driving Licence** | `driving_licence`, `dl` | State RTO code, year validation | ❌ |
|
|
113
|
+
| **Voter ID (EPIC)** | `voter_id`, `epic` | 10-char standard + legacy formats | ✅ |
|
|
114
|
+
| **Vehicle RC** | `vehicle`, `rc` | State RTO codes + Bharat (BH) series | ❌ |
|
|
115
|
+
| **Bank IFSC** | `ifsc` | RBI 11-char alphanumeric format | ❌ |
|
|
116
|
+
| **Mobile Phone** | `phone` | Indian 10-digit mobile series | ✅ |
|
|
117
|
+
| **Pincode** | `pincode` | 6-digit postal circle validation | ❌ |
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## 🛠️ Framework Integrations
|
|
122
|
+
|
|
123
|
+
### Pydantic v2
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
from pydantic import BaseModel
|
|
127
|
+
from indiaid.integrations.pydantic import AadhaarStr, PanStr, GstinStr
|
|
128
|
+
|
|
129
|
+
class UserKYC(BaseModel):
|
|
130
|
+
pan: PanStr
|
|
131
|
+
aadhaar: AadhaarStr
|
|
132
|
+
gstin: GstinStr
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Django Models & Forms
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
from django.db import models
|
|
139
|
+
from indiaid.integrations.django import validate_pan, validate_aadhaar
|
|
140
|
+
|
|
141
|
+
class Profile(models.Model):
|
|
142
|
+
pan = models.CharField(max_length=10, validators=[validate_pan])
|
|
143
|
+
aadhaar = models.CharField(max_length=12, validators=[validate_aadhaar])
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## 📄 License
|
|
149
|
+
|
|
150
|
+
MIT © IndiaID Contributors
|