Package: za-id-number
za_identity_numberZA / RSA Identity Number
Library to validate/check/manipulate and retrieve ID number info for South African IDsCurrent version: 0.0.9Downloads total:Poetry & pip compatibilityPython 3.5 or greater for f-strings.
Officially only support from py 3.7 >=Python3.12 support added in CIInstallation:pip:pipinstallza-id-numberpoetry:poetryaddza-id-numberZA ID Numbers / RSA ID numbers / South African ID numbers:ZA id numbers are validated by the luhn algorithm, with the last number validating that the entire number is correct.ZA ID number is broken up into  2 digits birth year, 2 digits birth month, 2 digits birth date, 4 digits for gender, 1 digit for citizenship (za/other), 1 digit race (phased out after 1980) 1 digit for validation.For more info:https://www.westerncape.gov.za/sites/www.westerncape.gov.za/files/sa-id-number-new.pngEasiest ZA ID validation is the length. The length must be exactly 13 integers.Example:fromza_id_number.za_id_numberimportSouthAfricanIdentityValidateif__name__=="__main__":za_validation=SouthAfricanIdentityValidate("9202204720082")valid=za_validation.validate()za_identity=za_validation.identity()print(f"Valid:{valid}, Identity:{za_identity}")LoggingAs its a library logging is off by default.
To get a logger for the library you can use the following example:logger=SouthAfricanIdentityValidate.get_logger(level=logging.DEBUG)# logger = logging.getLogger("za_id_number")# logger.removeHandler(logging.NullHandler())# logger.addHandler(logging.StreamHandler())za_validation=SouthAfricanIdentityValidate("9202204720082")valid=za_validation.validate()za_identity=za_validation.identity()logger.info(f"Valid:{valid}, Identity:{za_identity}")print(SouthAfricanIdentityValidate("99").identity_length())Classes:# Validation class, inherits from SouthAfricanIdentityNumbervalidate_id_obj=SouthAfricanIdentityValidate("9001245289086")# SouthAfricanIdentityNumber classidentity_obj=SouthAfricanIdentityNumber("9001245289086")# SouthAfricanIdentityGenerate classgenerated_id_obj=SouthAfricanIdentityGenerate()Class Attributes:# SouthAfricanIdentityValidateSouthAfricanIdentityValidate("9202204720082").valid# SouthAfricanIdentityNumberSouthAfricanIdentityNumber("9202204720082").id_numberSouthAfricanIdentityNumber("9202204720082").birthdateSouthAfricanIdentityNumber("9202204720082").yearSouthAfricanIdentityNumber("9202204720082").monthSouthAfricanIdentityNumber("9202204720082").daySouthAfricanIdentityNumber("9202204720082").genderSouthAfricanIdentityNumber("9202204720082").citizenshipSouthAfricanIdentityNumber("9202204720082").ageMethods:# SouthAfricanIdentityNumber classSouthAfricanIdentityNumber("9202204720082").get_age()SouthAfricanIdentityNumber("9202204720082").get_citizenship()SouthAfricanIdentityNumber("9202204720082").get_gender()SouthAfricanIdentityNumber("9202204720082").calculate_birthday()SouthAfricanIdentityNumber("9202204720082").get_month()SouthAfricanIdentityNumber("9202204720082").get_year()SouthAfricanIdentityNumber("9202204720082").get_day()# SouthAfricanIdentityValidate class# Inherits from SouthAfricanIdentityNumber# All attributes and methods availableSouthAfricanIdentityValidate("9202204720082").valid_birth_date()SouthAfricanIdentityValidate("9202204720082").validate()SouthAfricanIdentityValidate("9202204720082").identity()SouthAfricanIdentityValidate("9202204720082").identity_length()# SouthAfricanIdentityGenerate class# Inherits from SouthAfricanIdentityValidate# All attributes and methods available# gender and citizenship can be specified for specific random# id numbersSouthAfricanIdentityGenerate()# orSouthAfricanIdentityGenerate(gender="male",citizenship='citizen')# orfromza_id_number.constantsimportGender,CitizenshipClassSouthAfricanIdentityGenerate(gender=Gender.FEMALE,citizenship=CitizenshipClass.CITIZEN_BORN)# generate random ID number without using class objgenerate_random_id()Questions/Ideas/Feedbackchristogoosen@gmail.comchristo@anomaloustech.co.zaFuture features:Ask for some pleaseCI/CDCovers python:3.63.73.83.93.10
Check CI:https://github.com/c-goosen/za_identity_number/actionsReleases:0.0.7Upgrade packages idenitified by github security scanningRemove loguruDisable loggin in library by defaultFixed some exceptionsRemoved luhn library for fast-luhnfast-luhn adds generate and complete functionsGenerate Random ID numbersGenerate random luhn numbers of length n0.0.8Removed fast-luhn library as pyo3 rust implementation not building for Mac or python greater than 3.8Simplified library.Security issues in dependencies updated0.0.9Add python 3.12 to CISecurity updates in dependencies