Download the PHP package designbycode/south-african-id-validator without Composer
On this page you can find all versions of the php package designbycode/south-african-id-validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download designbycode/south-african-id-validator
More information about designbycode/south-african-id-validator
Files in designbycode/south-african-id-validator
Package south-african-id-validator
Short Description The South African ID Validator is a PHP class that validates and extracts information from South African ID numbers. It uses the Luhn Algorithm to validate the ID number and provides methods to determine the gender, citizenship, and birthdate of the individual.
License MIT
Homepage https://github.com/designbycode/south-african-id-validator
Informations about the package south-african-id-validator
South African ID Validator
The South African ID Validator is a PHP class that validates and extracts information from South African ID numbers. It uses the Luhn Algorithm to validate the ID number and provides methods to determine the gender, citizenship, and birthdate of the individual.
Installation
You can install the package via composer:
Usage
Instantiation
To use the South African ID Validator, create an instance of the SouthAfricanIdValidator
class:
Validation
To validate an ID number, use the isValid
method:
Parsing
To extract information from a valid ID number, use the parse
method:
Output:
Gender Determination
To determine the gender of the individual, use the isMale
or isFemale
methods:
Citizenship Determination
To determine the citizenship of the individual, use the isSACitizen
or isPermanentResident
methods:
Methods
isValid(mixed $idNumber): bool
Validates the ID number using the Luhn Algorithm and checks if it has a length of 13 digits and is numeric.
isLength13(mixed $idNumber): bool
Checks if the ID number has a length of 13 digits.
isNumber(mixed $idNumber): bool
Checks if the ID number is numeric.
passesLuhnCheck(mixed $idNumber): bool
Validates the ID number using the Luhn Algorithm.
isMale(mixed $idNumber): bool
Determines if the ID number is for a male.
isFemale(mixed $idNumber): bool
Determines if the ID number is for a female.
isSACitizen(mixed $idNumber): bool
Determines if the ID number is for a South African citizen.
isPermanentResident(mixed $idNumber): bool
Determines if the ID number is for a permanent resident.
parse(mixed $idNumber): array
Parses the ID number and returns an array with the following information:
valid
: A boolean indicating if the ID number is valid.birthday
: The birthdate in the formatYYYY/MM/DD
.age
: The age of the individual.gender
: The gender of the individual (Male or Female).citizenship
: The citizenship status of the individual (SA Citizen or Permanent Resident).
Use Cases
Validating ID numbers in a registration form
Use the isValid
method to validate ID numbers in a registration form to ensure that only valid ID numbers are accepted.
Extracting information from ID numbers
Use the parse
method to extract information from ID numbers, such as birthdate, age, gender, and citizenship, to populate user profiles or perform analytics.
Determining gender and citizenship
Use the isMale
, isFemale
, isSACitizen
, and isPermanentResident
methods to determine the gender and
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Claude Myburgh
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of south-african-id-validator with dependencies
designbycode/luhn-algorithm Version ^1.0
nesbot/carbon Version ^3.6