@unikue/ts-lang-utils
    Preparing search index...

    Function maskChineseIdCard

    • Returns a masked Chinese ID card number, which keeps the first 3 and last 4 characters

      Note that only the format is verified, the checksum character is not validated here, so that malformed data stored in the database can still be masked

      Parameters

      • Optionaltext: string | null

        The text to mask

      Returns string | undefined

      a masked Chinese ID card number, or undefined if the given text is invalid

      David Hsing

      maskChineseIdCard(undefined);    // undefined
      maskChineseIdCard('11010519491231002X'); // '110***********002X'
      maskChineseIdCard('11010519491231'); // undefined