anper/russian-id-laravel

A set of useful Laravel validation rules for identifiers of Russian individuals and legal entities

v0.4.0 2022-02-28 11:07 UTC

This package is auto-updated.

Last update: 2024-10-28 16:54:52 UTC


README

Software License Latest Version on Packagist Build Status

A set of useful Laravel validation rules for identifiers of Russian individuals and legal entities.

Install

$ composer require anper/russian-id-laravel

The package will automatically register itself.

Translations

If you wish to edit the package translations, you can run the following command to publish them into your resources/lang folder

$ php artisan vendor:publish --provider="Anper\RussianId\Laravel\RussianIdServiceProvider"

Available rules

  • Anper\RussianId\Laravel\Rules\BikRule
  • Anper\RussianId\Laravel\Rules\InnRule
  • Anper\RussianId\Laravel\Rules\KppRule
  • Anper\RussianId\Laravel\Rules\KsRule
  • Anper\RussianId\Laravel\Rules\LegalInnRule
  • Anper\RussianId\Laravel\Rules\OgrnipRule
  • Anper\RussianId\Laravel\Rules\OgrnOrOgrnipRule
  • Anper\RussianId\Laravel\Rules\OgrnRule
  • Anper\RussianId\Laravel\Rules\OmsRule
  • Anper\RussianId\Laravel\Rules\PersonInnRule
  • Anper\RussianId\Laravel\Rules\RsRule
  • Anper\RussianId\Laravel\Rules\SnilsRule

The KsRule and RsRule require the BIK attribute in the validated data. You must provide the attribute name in them constructors.

<?php

use Anper\RussianId\Laravel\Rules\BikRule;
use Anper\RussianId\Laravel\Rules\KsRule;
use Anper\RussianId\Laravel\Rules\RsRule;
use Illuminate\Support\Facades\Validator;

$validator = Validator::make([
    'bik_field'=> '...',
    'ks_field' => '...',
    'rs_field' => '...',
], [
    'bik_field'=> new BikRule(),
    'ks_field' => new KsRule('bik_field'),
    'rs_field' => new RsRule('bik_field'),
]);

Tests

Unit testing

The package is tested with PHPUnit. To run tests:

$ composer test

Static analysis

The code is statically analyzed with PHPStan. To run static analysis:

$ composer stan

License

The MIT License (MIT). Please see License File for more information.