alexeevdv / yii2-kz-personalid
Installs: 3 347
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: ^2.0
Requires (Dev)
README
Yii2 extension to deal with Kazakhstan personal identification number
It contains:
- Both server-side and client-side validators
- Helper to fetch data from identification number
Installation
The preferred way to install this extension is through composer.
Either run
$ php composer.phar require alexeevdv/yii2-kz-personalid "~1.0"
or add
"alexeevdv/yii2-kz-personalid": "~1.0"
to the require
section of your composer.json
file.
Usage
Validation
As standalone validator
use alexeevdv\kz\PersonalidValidator; //... $validator = new PersonalidValidator; $result = $validator->validateValue('123456789012'); //...
In model
use alexeevdv\kz\PersonalidValidator; public function rules() { //... ['personalid', PersonalidValidator::class, 'message' => 'Wrong personalid value!'], //... }
Helper
use alexeevdv\kz\PersonalidHelper; $personalid = '850407301166'; /** @var \DateTime $birtdate = 1985-04-07 */ $birtdate = PersonalidHelper::getBirthDate($personalid); /** @var int $sex = PersonalidHelper::SEX_MALE */ $sex = PersonalidHelper::getSex($personalid); /** @var string $serialNumber = 0116 */ $serialNumber = PersonalidHelper::getSerialNumber($personalid);