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

    Function isChineseIdCard

    • Returns whether the given text is a valid Chinese mainland ID card number

      Parameters

      • Optionaltext: string | null

        The text to check

      • checksum: boolean = true

        Whether to validate the checksum character, which is the 18th character

      Returns boolean

      whether the given text is a valid Chinese mainland ID card number

      David Hsing

      isChineseIdCard(undefined);                              // false
      isChineseIdCard('11010519491231002X'); // true
      isChineseIdCard('110105194912310021'); // false, 校验位错误
      isChineseIdCard('110105194912310021', false); // true, 仅校验格式
      isChineseIdCard('110101199002301234'); // false, 日期不存在