cnic library
CNIC (Computerized National Identity Card) validation and decoding.
Same as the pakdatakit/cnic entry point of the npm package.
Classes
- CNICInfo
- Information encoded in a CNIC number. See getCNICInfo.
- CNICMatch
- A CNIC found by findCNICs.
- MaskedText
- Result of maskCNICs.
Enums
- Gender
- Gender encoded in the last digit of a CNIC.
Functions
-
findCNICs(
String text) → List< CNICMatch> - Finds CNIC numbers in free text, such as a chat message, a note or an uploaded document, for example to mask them before logging.
-
getCNICInfo(
String cnic) → CNICInfo? - Reads the province of registration and gender encoded in a CNIC.
-
maskCNICs(
String text, {String mask = 'X', String? replacement}) → MaskedText -
Masks every CNIC in free text, as found by findCNICs: each digit
becomes
maskand the separators stay, so35202-1234567-1becomesXXXXX-XXXXXXX-X. The rest of the text is unchanged. -
validateCNIC(
String cnic) → bool - Validates the format of a Pakistani CNIC number: 13 digits, in 5-7-1 groups or together, starting with a province code from 1 to 8.