credy/yii2-kz-personalid

1.0.0 2023-05-04 09:08 UTC

This package is auto-updated.

Last update: 2024-11-04 12:23:34 UTC


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

Usage

Validation

As standalone validator

use credy\kz\PersonalidValidator;

//...
$validator = new PersonalidValidator;
$result = $validator->validateValue('123456789012');
//...

In model

use credy\kz\PersonalidValidator;

public function rules()
{
    //...
    ['personalid', PersonalidValidator::class, 'message' => 'Wrong personalid value!'],
    //...
}

Helper

use credy\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);