Skip to content

Sqrcz/numerik

Numerik

Tests PHPStan Latest Version PHP Version License

Modern PHP 8.3+ library for validating and parsing Polish identification numbers — PESEL, NIP, REGON, and KRS. Rich value objects, detailed error reasons, zero production dependencies.

Installation

composer require slashlab/numerik

Quick Start

use SlashLab\Numerik\Numerik;

// Simple boolean check
Numerik::pesel()->isValid('92060512186');  // true
Numerik::nip()->isValid('5260250274');     // true

// Rich validation result with failure reasons
$result = Numerik::pesel()->validate('92060512186');
$result->isValid;                          // true

$result = Numerik::pesel()->validate('00000000000');
$result->isFailed();                       // true
$result->getFirstFailure()->reason;        // ValidationFailureReason::AllZeros

// Parse to value object
$pesel = Numerik::pesel()->parse('92060512186');
$pesel->getBirthDate()->format('Y-m-d');  // '1992-06-05'
$pesel->getGender();                      // Gender::Female

Documentation

Full documentation at numerik.slashlab.pl

Laravel Integration

composer require slashlab/numerik-laravel
// In a Form Request
public function rules(): array
{
    return [
        'pesel' => ['required', new PeselRule()],
        'nip'   => ['required', new NipRule()],
    ];
}

Changelog

See CHANGELOG.md.

Contributing

See CONTRIBUTING.md.

License

MIT — see LICENSE.


If this saved you time → ☕ Buy me a coffee

About

Modern PHP 8.2+ library for validating and parsing Polish identification numbers (PESEL, NIP, REGON, KRS)

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages