lochinvarwest/sa-id-validation
Composer 安装命令:
composer require lochinvarwest/sa-id-validation
包简介
A simple validator for South African ID numbers;
README 文档
README
Installation
- Run the following n your project root:
composer require lochinvarwest/sa-id-validation
Instantiation and Usage
To instantiate, use either:
$validator = SAIdValidator::create($id_number);
or:
$validator = new SAIdValidator($id_number);
or use the Request Rule validator
'idno' => ['required', new SAIdNumber()]
Available Methods:
Validate
The validate() method checks the number of digits, that the ID number represents a valid birth date and that the Luhn algorithm checksum digit is correct. It returns 'true' on success or an error message on failure.
$validator->validate(); // or as above
Check String Length
The validateLength() method checks that the ID number has 13 digits
$validator->validateLength();
Check DoB digits
The validateDateOfBirth() method checks that the ID number represents a valid date for the date of birth.
$validator->validateDateOfBirth();
Get DoB
The getDateOfBirth() method returns a Carbon date object of the date of birth denoted in the provided ID number.
$validator->getDateOfBirth();
Check Checksum digit
The validateChecksum() method checks that the Luhn algorith checksum digit is correct for the ID number supplied.
$validator->validateChecksum();
Check Gender
The validateGender($gender) method checks that the gender supplied corresponds to the gender denoted in the ID number. The argument is "Female: or "Male" or "F" or "M" (case insensitive)
$validator->validateGender($gender);
Get Gender
The getGender() method returns the gender denoted in the ID number.
$validator->getGender();
Check Citizenship
The validateCitizen($citizenship) method checks that citizenship or residency denoted in the ID number corresponds to the status provided. The argument is "citizen: or "resident" (case insensitive)
$validator->validateCitizen();
Get Citizenship
The getCitizen() method returns the citizenship status denoted in the ID number.
$validator->getCitizen();
统计信息
- 总下载量: 88
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2020-08-11