za-id-number


Nameza-id-number JSON
Version 0.0.9 PyPI version JSON
download
home_pagehttps://github.com/c-goosen/za_identity_number
SummarySouth African (RSA/ZA) ID number validation and easy data extraction Library.
upload_time2024-01-29 09:34:52
maintainer
docs_urlNone
authorChristo Goosen
requires_python>=3.5.0
licenseMIT
keywords south africa id number
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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.9

Downloads total:  [![Downloads](https://static.pepy.tech/personalized-badge/za-id-number?period=total&units=international_system&left_color=black&right_color=orange&left_text=Downloads)](https://pepy.tech/project/za-id-number)

Poetry & pip compatibility

Python 3.5 or greater for f-strings.
Officially only support from py 3.7 >=

Python3.12 support added in CI

# Installation:

pip:
```bash

pip install za-id-number

```

poetry:

```bash

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:
```python
from za_id_number.za_id_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}")
```
# Logging
As its a library logging is off by default.
To get a logger for the library you can use the following example:
```python
    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:
```python
# Validation class, inherits from SouthAfricanIdentityNumber
validate_id_obj = SouthAfricanIdentityValidate("9001245289086")

# SouthAfricanIdentityNumber class
identity_obj = SouthAfricanIdentityNumber("9001245289086")

# SouthAfricanIdentityGenerate class
generated_id_obj = SouthAfricanIdentityGenerate()
```

# Class Attributes:
```python
# 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:
```python
# 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()


# SouthAfricanIdentityValidate class
# Inherits from SouthAfricanIdentityNumber
# All attributes and methods available
SouthAfricanIdentityValidate("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 numbers
SouthAfricanIdentityGenerate()
# or
SouthAfricanIdentityGenerate(gender="male", citizenship='citizen')
# or
from za_id_number.constants import Gender, CitizenshipClass
SouthAfricanIdentityGenerate(gender=Gender.FEMALE, citizenship=CitizenshipClass.CITIZEN_BORN)
# generate random ID number without using class obj
generate_random_id()

```

Questions/Ideas/Feedback

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

## Future features:
* Ask for some please

## CI/CD
Covers python:
* 3.6
* 3.7
* 3.8
* 3.9
* 3.10
Check CI: https://github.com/c-goosen/za_identity_number/actions

# Releases:
* 0.0.7
  * Upgrade packages idenitified by github security scanning
  * Remove loguru
  * Disable loggin in library by default
  * Fixed some exceptions
  * Removed luhn library for fast-luhn
  * fast-luhn adds generate and complete functions
  * Generate Random ID numbers
  * Generate random luhn numbers of length n
* 0.0.8
  * Removed fast-luhn library as pyo3 rust implementation not building for Mac or python greater than 3.8
  * Simplified library.
  * Security issues in dependencies updated
* 0.0.9
  * Add python 3.12 to CI
  * Security updates in dependencies

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/c-goosen/za_identity_number",
    "name": "za-id-number",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.5.0",
    "maintainer_email": "",
    "keywords": "South Africa ID Number",
    "author": "Christo Goosen",
    "author_email": "christogoosen@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/95/9f/19f37050c4e5d7b3cb24965df13c1fd964b0890d24842d09f7495827ccfc/za-id-number-0.0.9.tar.gz",
    "platform": null,
    "description": "# za_identity_number\n\nZA / RSA Identity Number \nLibrary to validate/check/manipulate and retrieve ID number info for South African IDs\n\nCurrent version: 0.0.9\n\nDownloads total:  [![Downloads](https://static.pepy.tech/personalized-badge/za-id-number?period=total&units=international_system&left_color=black&right_color=orange&left_text=Downloads)](https://pepy.tech/project/za-id-number)\n\nPoetry & pip compatibility\n\nPython 3.5 or greater for f-strings.\nOfficially only support from py 3.7 >=\n\nPython3.12 support added in CI\n\n# Installation:\n\npip:\n```bash\n\npip install za-id-number\n\n```\n\npoetry:\n\n```bash\n\npoetry add za-id-number\n\n```\n\nZA ID Numbers / RSA ID numbers / South African ID numbers:\n\nZA id numbers are validated by the luhn algorithm, with the last number validating that the entire number is correct.\n\nZA 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.\n\nFor more info: https://www.westerncape.gov.za/sites/www.westerncape.gov.za/files/sa-id-number-new.png\n\nEasiest ZA ID validation is the length. The length must be exactly 13 integers.\n\n# Example:\n```python\nfrom za_id_number.za_id_number import SouthAfricanIdentityValidate\n\nif __name__ == \"__main__\":\n    za_validation = SouthAfricanIdentityValidate(\"9202204720082\")\n    valid = za_validation.validate()\n    za_identity = za_validation.identity()\n    print(f\"Valid: {valid}, Identity: {za_identity}\")\n```\n# Logging\nAs its a library logging is off by default.\nTo get a logger for the library you can use the following example:\n```python\n    logger = SouthAfricanIdentityValidate.get_logger(level=logging.DEBUG)\n    # logger = logging.getLogger(\"za_id_number\")\n    # logger.removeHandler(logging.NullHandler())\n    # logger.addHandler(logging.StreamHandler())\n    za_validation = SouthAfricanIdentityValidate(\"9202204720082\")\n    valid = za_validation.validate()\n    za_identity = za_validation.identity()\n    logger.info(f\"Valid: {valid}, Identity: {za_identity}\")\n    print(SouthAfricanIdentityValidate(\"99\").identity_length())\n```\n\n# Classes:\n```python\n# Validation class, inherits from SouthAfricanIdentityNumber\nvalidate_id_obj = SouthAfricanIdentityValidate(\"9001245289086\")\n\n# SouthAfricanIdentityNumber class\nidentity_obj = SouthAfricanIdentityNumber(\"9001245289086\")\n\n# SouthAfricanIdentityGenerate class\ngenerated_id_obj = SouthAfricanIdentityGenerate()\n```\n\n# Class Attributes:\n```python\n# SouthAfricanIdentityValidate\nSouthAfricanIdentityValidate(\"9202204720082\").valid\n\n# SouthAfricanIdentityNumber\nSouthAfricanIdentityNumber(\"9202204720082\").id_number\nSouthAfricanIdentityNumber(\"9202204720082\").birthdate\nSouthAfricanIdentityNumber(\"9202204720082\").year\nSouthAfricanIdentityNumber(\"9202204720082\").month\nSouthAfricanIdentityNumber(\"9202204720082\").day\nSouthAfricanIdentityNumber(\"9202204720082\").gender\nSouthAfricanIdentityNumber(\"9202204720082\").citizenship\nSouthAfricanIdentityNumber(\"9202204720082\").age\n\n```\n\n# Methods:\n```python\n# SouthAfricanIdentityNumber class\nSouthAfricanIdentityNumber(\"9202204720082\").get_age()\nSouthAfricanIdentityNumber(\"9202204720082\").get_citizenship()\nSouthAfricanIdentityNumber(\"9202204720082\").get_gender()\nSouthAfricanIdentityNumber(\"9202204720082\").calculate_birthday()\nSouthAfricanIdentityNumber(\"9202204720082\").get_month()\nSouthAfricanIdentityNumber(\"9202204720082\").get_year()\nSouthAfricanIdentityNumber(\"9202204720082\").get_day()\n\n\n# SouthAfricanIdentityValidate class\n# Inherits from SouthAfricanIdentityNumber\n# All attributes and methods available\nSouthAfricanIdentityValidate(\"9202204720082\").valid_birth_date()\nSouthAfricanIdentityValidate(\"9202204720082\").validate()\nSouthAfricanIdentityValidate(\"9202204720082\").identity()\nSouthAfricanIdentityValidate(\"9202204720082\").identity_length()\n\n# SouthAfricanIdentityGenerate class\n# Inherits from SouthAfricanIdentityValidate\n# All attributes and methods available\n# gender and citizenship can be specified for specific random\n# id numbers\nSouthAfricanIdentityGenerate()\n# or\nSouthAfricanIdentityGenerate(gender=\"male\", citizenship='citizen')\n# or\nfrom za_id_number.constants import Gender, CitizenshipClass\nSouthAfricanIdentityGenerate(gender=Gender.FEMALE, citizenship=CitizenshipClass.CITIZEN_BORN)\n# generate random ID number without using class obj\ngenerate_random_id()\n\n```\n\nQuestions/Ideas/Feedback\n\nchristogoosen@gmail.com\nchristo@anomaloustech.co.za\n\n## Future features:\n* Ask for some please\n\n## CI/CD\nCovers python:\n* 3.6\n* 3.7\n* 3.8\n* 3.9\n* 3.10\nCheck CI: https://github.com/c-goosen/za_identity_number/actions\n\n# Releases:\n* 0.0.7\n  * Upgrade packages idenitified by github security scanning\n  * Remove loguru\n  * Disable loggin in library by default\n  * Fixed some exceptions\n  * Removed luhn library for fast-luhn\n  * fast-luhn adds generate and complete functions\n  * Generate Random ID numbers\n  * Generate random luhn numbers of length n\n* 0.0.8\n  * Removed fast-luhn library as pyo3 rust implementation not building for Mac or python greater than 3.8\n  * Simplified library.\n  * Security issues in dependencies updated\n* 0.0.9\n  * Add python 3.12 to CI\n  * Security updates in dependencies\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "South African (RSA/ZA) ID number validation and easy data extraction Library.",
    "version": "0.0.9",
    "project_urls": {
        "Homepage": "https://github.com/c-goosen/za_identity_number"
    },
    "split_keywords": [
        "south",
        "africa",
        "id",
        "number"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "959f19f37050c4e5d7b3cb24965df13c1fd964b0890d24842d09f7495827ccfc",
                "md5": "055f88a3f438d15d59aad9032b7f36ab",
                "sha256": "1ba93d2ecf7b1012486a42235b4ca2d7ece2655c1e6db2d6faa8425ecdb6c74e"
            },
            "downloads": -1,
            "filename": "za-id-number-0.0.9.tar.gz",
            "has_sig": false,
            "md5_digest": "055f88a3f438d15d59aad9032b7f36ab",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.5.0",
            "size": 10988,
            "upload_time": "2024-01-29T09:34:52",
            "upload_time_iso_8601": "2024-01-29T09:34:52.858816Z",
            "url": "https://files.pythonhosted.org/packages/95/9f/19f37050c4e5d7b3cb24965df13c1fd964b0890d24842d09f7495827ccfc/za-id-number-0.0.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-29 09:34:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "c-goosen",
    "github_project": "za_identity_number",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "za-id-number"
}
        
Elapsed time: 0.23269s