ctnx.validation module

class ctnx.validation.CccdResult(id: str, is_male: bool, birth_year: int, birth_country: str, birth_province: str = '')[source]

Bases: tuple

Contain information of a parsed Vietnamese Citizen Identity Card (Căn cước công dân) number.

birth_country: str

Alias for field number 3

birth_province: str

Alias for field number 4

birth_year: int

Alias for field number 2

id: str

Alias for field number 0

is_male: bool

Alias for field number 1

exception ctnx.validation.ParseError(message, pos: int, *args)[source]

Bases: ValueError

ctnx.validation.is_valid_cccd(raw: int | str) bool[source]

Check whether a Vietnamese Citizen Identity Card (Căn cước công dân) number is vaild or not.

Parameters:

raw (str or int) – The ID number to be validated

Returns:

Whether the ID is vaild or not

Return type:

bool

ctnx.validation.parse_cccd(raw: int | str) CccdResult[source]

Extract information from a Vietnamese Citizen Identity Card (Căn cước công dân) number.

Parameters:

raw (str or int) – The ID number to be parsed

Returns:

A named tuple contains the extracted information, consist of gender, date of birth, register place and the incremental ID

Return type:

CccdResult

Raises:

ParseError – If the ID is invalid