idnumbers
    Preparing search index...

    Class ValidatorRegistry

    Central registry for country ID validators.

    Keys are stored uppercase. Only the ASCII letters are case-folded, so a non-ASCII lookalike (long s, dotless i, ...) never matches an ASCII code (#298). Aliases resolve to primary keys only (no chaining). Qualified keys use colon separator, e.g. "USA:SSN".

    Implements

    Index
    • Create an alias that resolves to an existing primary key.

      Parameters

      • alias: string
      • key: string

      Returns void

      Error if the target key is not a registered primary key.

      Error if the alias conflicts with an existing primary key.

      Error if the alias is already registered as an alias.

    • Register a country definition: its validator under country.key, plus its aliases.

      Atomic: every conflict is checked before anything is registered, so a failed call leaves the registry unchanged. Idempotent for a definition that is already fully registered (e.g. by the root idnumbers entry), which makes it a no-op.

      Parameters

      Returns void

      Error if the key or an alias is already taken, an alias names a primary key, the definition repeats an alias, or the same validator is already registered without one of the (otherwise free) aliases.

    • Return the primary key (alpha-3) for a given key or alias. Matching is case-insensitive for ASCII letters only, so a non-ASCII lookalike never resolves to a built-in code (#298), like Python's resolve_country. Returns undefined when the key is unknown or not a string (an untyped JavaScript caller may pass undefined, null or a number), as the Python library does (#295).

      Parameters

      • key: string

      Returns string | undefined