idnumbers
    Preparing search index...

    Function normalizeId

    • The compact form of an ID (#128): ASCII letters uppercased, without whitespace and without the separators . - / ( ). Other letters, such as the sharp s or a Greek letter, are kept as written, as in the Python library (#301); toUpperCase() would turn some of them into ASCII letters. For an ID written without separators, those characters stay when the ID without whitespace already has an allowed length, so Finland's century sign in 131052-308T is kept. Sweden's + for people aged 100 or over always stays.

      validateNationalId() accepts the compact form for every country except USA and KOR, whose validators require the separators: validate formatId()'s output there.

      Returns null for an unsupported country code (including a non-string one from untyped JavaScript) or a non-string ID.

      Parameters

      • countryCode: FormatCountryCode
      • idNumber: string

      Returns string | null

      import { normalizeId } from 'idnumbers';

      normalizeId('BRA', '111.444.777-35'); // '11144477735'
      normalizeId('TWN', 'a123456789'); // 'A123456789'
      normalizeId('XX', '1'); // null, unsupported country