validateCNIC function

bool validateCNIC(
  1. String cnic
)

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.

Accepts 3520212345671, 35202-1234567-1, 35202 1234567 1 and Urdu digits. Separators must sit between the 5-7-1 digit groups and be used consistently.

NADRA does not publish a check-digit algorithm, so this validates structure only.

Implementation

bool validateCNIC(String cnic) =>
    _cnicPattern.hasMatch(toAsciiDigits(jsTrim(cnic)));