# stdnum.pk.cnic

CNIC number (Pakistani Computerised National Identity Card number).

The CNIC (Computerised National Identity Card, قومی شناختی کارڈ) or SNIC (Smart National Identity Card) is issued by by Pakistan’s NADRA (National Database and Registration Authority) to citizens of 18 years or older.

The number consists of 13 digits and encodes the person’s locality (5 digits), followed by 7 digit serial number an a single digit indicating gender.

More Information:

- https://en.wikipedia.org/wiki/CNIC_(Pakistan)

- https://www.nadra.gov.pk/identity/identity-cnic/

    >>> validate('34201-0891231-8')
    '3420108912318'
    >>> validate('42201-0397640-8')
    '4220103976408'
    >>> get_gender('42201-0397640-8')
    'F'
    >>> get_province('42201-0397640-8')
    'Sindh'
    >>> format('3420108912318')
    '34201-0891231-8'

stdnum.pk.cnic.compact(number: str) → str

  Convert the number to the minimal representation. This strips the number of any valid separators and removes surrounding whitespace.

stdnum.pk.cnic.format(number: str) → str

  Reformat the number to the standard presentation format.

stdnum.pk.cnic.get_gender(number: str) → str | None

  Get the person’s birth gender (‘M’ or ‘F’).

stdnum.pk.cnic.get_province(number: str) → str | None

  Get the person’s province.

stdnum.pk.cnic.is_valid(number: str) → bool

  Check if the number is a valid CNIC.

stdnum.pk.cnic.validate(number: str) → str

  Check if the number is a valid CNIC. This checks the length, formatting and some digits.