nationid - v2.2.1
    Preparing search index...

    Function extractRegion

    • Returns the administrative region encoded in input, or null if the spec does not encode region or the input fails validation.

      The returned Region carries the raw token plus a kind discriminant (state / province / department / municipality / tax_region). Callers can resolve the token against their own catalog to obtain the human-readable region name.

      Parameters

      • code: CodesSupporting<"region">

        Document type. Must support "region" (see supports).

      • input: string

        Raw user input; will be normalized and validated first.

      Returns Region | null

      A Region on success, null otherwise.

      import { extractRegion } from "nationid/extract";

      extractRegion("MX_CURP", "GOMC850315HDFRRR07");
      // { code: "DF", kind: "state" }
      extractRegion("GT_DPI", "0123456780101");
      // { code: "01", kind: "department" }