joke2k / joke2k/faker

Add pan() and gstin() generators to en_IN provider

Open
#2,356 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
19.4k
Forks
2.1k
PR merge metrics
No merged PRs in 30d

Description

## Details:

* Faker version: 40.12.0.
* OS: Windows / Linux / macOS.

Add `pan()` and `gstin()` generators to `en_IN`.

`en_IN` already includes `aadhaar_id()`, but PAN and GSTIN generators are missing.

PAN and GSTIN are common in India focused billing, invoicing, ERP, and compliance workflows, so adding these methods would reduce custom generator code in downstream projects.

### Current behavior:

`pan()` and `gstin()` are not available in `en_IN`.

### Expected behavior:

`en_IN` should provide:

1. `pan()` that returns structurally valid PAN values.
2. `gstin()` that returns structurally valid GSTIN values with valid checksum.
3. Tests for format and checksum rules.
4. Documentation examples for both methods.

### Steps to produce:

```python
from faker import Faker

fake = Faker("en_IN")

# Expected after this change:
fake.pan()
fake.gstin()
```

### Proposed implementation:

1. Extend `faker.providers.ssn.en_IN.Provider`.
2. Add formatter methods: `pan()` and `gstin()`.
3. Keep implementation aligned with existing SSN provider conventions.
4. Add tests in `tests/providers/test_ssn.py` (extend `TestEnIn`).

### Format constraints:

PAN:

1. Length: 10.
2. Pattern: `^[A-Z]{5}[0-9]{4}[A-Z]$`.

GSTIN:

1. Length: 15.
2. Pattern: `^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z][0-9A-Z]Z[0-9A-Z]$`.
3. Last character should be checksum from first 14 characters.

### Test expectations:

1. Repeated generation checks (for example 100 samples).
2. Regex and length validation for both methods.
3. Checksum verification for generated GSTIN values.
4. Deterministic output under seeding.

I can work on this in a focused PR if the maintainers are aligned with this scope.

Contributor guide

Open the contributing guide

Research direction

Start by reading faker.providers.ssn.en_IN.Provider and the TestEnIn cases in tests/providers/test_ssn.py. Add the two formatter methods, then run the focused SSN provider tests while checking repeated outputs against the stated PAN regex and GSTIN checksum rules. Done means deterministic seeded generation, format and checksum coverage, and documentation examples for both methods.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, documentation, testing
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.