PIN code
Validates an Indian PIN code: exactly 6 digits, first digit 1–9. Spaces and dashes are ignored.
| Rule | Detail |
|---|---|
| Length | Exactly 6 digits |
| First digit | 1–9 (0 is not used) |
| Characters | Digits only, ignoring spaces and - |
| Checksum | None — PIN codes have no checksum digit |
What the digits mean
Section titled “What the digits mean”| Digits | Meaning |
|---|---|
| 1st | Postal circle (1–9, e.g. 7 = East: West Bengal, Odisha, NE states) |
| 1st–2nd | Postal region / sub-circle |
| 1st–3rd | Sorting district |
| Last 3 | Delivery post office |
import { validatePincode } from 'indycheck';
validatePincode('781001');// { ok: true, code: 'VALID', normalized: '781001',// parsed: { pincode: '781001' } }from indycheck import validate_pincode
validate_pincode("781001").ok # Trueuse indycheck::validate_pincode;
let r = validate_pincode("781001");assert!(r.ok);Examples
Section titled “Examples”| Input | Result | Code |
|---|---|---|
781001 |
Valid (Guwahati area) | VALID |
110001 |
Valid (New Delhi area) | VALID |
400001 |
Valid (Mumbai area) | VALID |
011001 |
Invalid — starts with 0 | INVALID_FIRST_DIGIT |
78100 |
Invalid — 5 digits | INVALID_LENGTH |
78100A |
Invalid — letter inside | INVALID_FORMAT |
| (empty) | Invalid | EMPTY |
Error codes
Section titled “Error codes”| Code | Means |
|---|---|
EMPTY |
Nothing was passed in |
INVALID_FORMAT |
Non-digit characters (other than spaces / -) |
INVALID_LENGTH |
Not exactly 6 digits |
INVALID_FIRST_DIGIT |
First digit is 0 |
Parsed output
Section titled “Parsed output”On success, parsed contains:
{ "pincode": "781001"}