Metadata-Version: 2.4
Name: sa-id-validator
Version: 1.0.0
Summary: Validate South African ID numbers: format, date of birth, gender, citizenship and Luhn check digit.
Author: CheckID
License: MIT
Project-URL: Homepage, https://checkid.co.za/sa-id-validator-test-cases
Project-URL: ID Verification API, https://checkid.co.za/business
Project-URL: Source, https://github.com/pietervw/sa-id-validator
Project-URL: Issues, https://github.com/pietervw/sa-id-validator/issues
Keywords: south africa,id number,rsa id,validation,luhn
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# sa-id-validator

Validate South African ID numbers in Python 3.8+. Zero dependencies.

```python
from sa_id_validator import validate_sa_id, is_valid_sa_id

r = validate_sa_id("8001015009087")
r.valid, r.date_of_birth, r.gender, r.citizenship
# (True, datetime.date(1980, 1, 1), "male", "citizen")

validate_sa_id("8001015009088").reason   # "checksum"
is_valid_sa_id("800101 5009 087")         # True (spaces and dashes are ignored)
```

## What it checks

1. 13 digits
2. A real date of birth in the first six digits (leap years included, no future dates)
3. Citizenship digit: 0 citizen, 1 permanent resident, 2 refugee
4. The Luhn check digit

`reason` is `format`, `date_of_birth`, `citizenship` or `checksum` when a number fails.

## What it does not check

A number can pass every check and still not belong to anyone. This library only reads the structure of the number. To confirm that an ID number and name match the Home Affairs record, use a verification service such as the [CheckID ID Verification API](https://checkid.co.za/business).

## Test numbers

[CheckID's SA ID test cases](https://checkid.co.za/sa-id-validator-test-cases) list valid and invalid numbers for your own tests. The same rules are explained step by step in [how the SA ID checksum works](https://checkid.co.za/articles/sa-id-checksum-explained).

## Licence

MIT
