Skip to main content
getPlaceByIranNationalId resolves the leading 3 digits of an Iranian National ID to the registering city and parent province.

Function

Return type

Triple-state return: Related types 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 verifyIranianNationalId upstream if validity matters.
  • No Persian/Arabic digit normalization. Persian-digit input ("۰۰۸۴۵۷۵۹۴۸") won’t match the English-keyed dataset → null. Pre-convert with autoConvertDigitsToEN.
  • 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