Skip to main content

South African (RSA/ZA) ID number validation and easy data extraction Library.

Project description

za_identity_number

ZA / RSA Identity Number Library to validate/check/manipulate and retrieve ID number info for South African IDs

Current version: 0.0.4-3

Poetry & pip compatibility

Python 3.5 or greater for f-strings

Installation:

pip:

pip install za-id-number

poetry:

poetry add za-id-number

ZA 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.png

Easiest ZA ID validation is the length. The length must be exactly 13 integers.

Example:

from za_id_number.za_identity_number import SouthAfricanIdentityValidate

if __name__ == "__main__":
    za_validation = SouthAfricanIdentityValidate("9202204720082")
    valid = za_validation.validate()
    za_identity = za_validation.identity()
    print(f"Valid: {valid}, Identity: {za_identity}")

Classes:

# Validation class, inherits from SouthAfricanIdentityNumber
validate_id = SouthAfricanIdentityValidate("9001245289086")

# SouthAfricanIdentityNumber class
identity_obj = SouthAfricanIdentityNumber("9001245289086")

Class Attributes:

# SouthAfricanIdentityValidate
SouthAfricanIdentityValidate("9202204720082").valid

# SouthAfricanIdentityNumber
SouthAfricanIdentityNumber("9202204720082").id_number
SouthAfricanIdentityNumber("9202204720082").birthdate
SouthAfricanIdentityNumber("9202204720082").year
SouthAfricanIdentityNumber("9202204720082").month
SouthAfricanIdentityNumber("9202204720082").day
SouthAfricanIdentityNumber("9202204720082").gender
SouthAfricanIdentityNumber("9202204720082").citizenship
SouthAfricanIdentityNumber("9202204720082").age

Methods:

# SouthAfricanIdentityValidate class
SouthAfricanIdentityValidate("9202204720082").valid_birth_date()
SouthAfricanIdentityValidate("9202204720082").validate()
SouthAfricanIdentityValidate("9202204720082").identity()
SouthAfricanIdentityValidate("9202204720082").identity_length()

# SouthAfricanIdentityNumber class
SouthAfricanIdentityNumber("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()

Questions/Ideas/Feedback

christogoosen@gmail.com christo@anomaloustech.co.za

Future features:

  • Generating random ID numbers

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

za-id-number-0.0.4.post3.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

za_id_number-0.0.4.post3-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file za-id-number-0.0.4.post3.tar.gz.

File metadata

  • Download URL: za-id-number-0.0.4.post3.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for za-id-number-0.0.4.post3.tar.gz
Algorithm Hash digest
SHA256 fd84c20d0462f60ce0c0db77c755bd7b82b3d12cb065bd2c644b0d5d24aadf17
MD5 53cd19831e365491d5f0ddd38e35027e
BLAKE2b-256 3c6cf994cdb3e1aa7ae8d47ed46fe663034bf8df004cec2e260d3b6809042699

See more details on using hashes here.

File details

Details for the file za_id_number-0.0.4.post3-py3-none-any.whl.

File metadata

  • Download URL: za_id_number-0.0.4.post3-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for za_id_number-0.0.4.post3-py3-none-any.whl
Algorithm Hash digest
SHA256 bef096cbc5485315f803d67aed3c71b8a7ba26ff75af416ca90d7ba6245ee127
MD5 bb82de6954421ec535f5d59703fa1f0d
BLAKE2b-256 241e38f432265296ea26b42eebc650b283261feee71b98052e3d0486da02c8d9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page