getPlaceByIranNationalId resolves the leading 3 digits of an Iranian National ID to the registering city and parent province.
Function
Return type
| Return | Meaning |
|---|---|
IPlaceByNationalId | Lookup succeeded |
null | Ran lookup, prefix not in the dataset |
undefined | Falsy input — no lookup attempted |
IProvince and INationalId are also exported.
This function does NOT validate the ID
The leading 3 digits are looked up directly. A nonsense ID like"1234567890" (which fails verifyIranianNationalId) may still return a valid place if "123" is in the dataset. Pair with the validator if you need both:
Pitfalls
- No checksum validation here. Use
verifyIranianNationalIdupstream if validity matters. - No Persian/Arabic digit normalization. Persian-digit input (
"۰۰۸۴۵۷۵۹۴۸") won’t match the English-keyed dataset →null. Pre-convert withautoConvertDigitsToEN. - Input length must be exactly 10. Other lengths short-circuit to
undefined. province === "unknown"is a real return (not an error) — it means the prefix matched a city whose parent code isn’t in the provinces table. Surface gracefully.
Source
src/modules/getPlaceByIranNationalId/index.ts, nationalId.skip.ts, provincesCodes.skip.ts · Tests: test/getPlaceByIranNationalId.spec.ts