PHPackages                             gbielbarbosa/stdnum-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. gbielbarbosa/stdnum-php

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

gbielbarbosa/stdnum-php
=======================

A PHP library to parse, validate and format standard numbers and identifiers.

1.1.0(1mo ago)01MITPHPPHP &gt;=8.1

Since Apr 17Pushed 1mo agoCompare

[ Source](https://github.com/gbielbarbosa/stdnum-php)[ Packagist](https://packagist.org/packages/gbielbarbosa/stdnum-php)[ RSS](/packages/gbielbarbosa-stdnum-php/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

stdnum-php
==========

[](#stdnum-php)

[![Minimum PHP Version](https://camo.githubusercontent.com/183804d09fec16ca7b6209b007250b7d8db1b915042feb093a9f20e6e1f25359/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230382e312d3838393242462e737667)](https://php.net/)[![License](https://camo.githubusercontent.com/b8cadaa967891081f8f165695470689986c028821dd8a040132f6e661795dc0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c7565)](LICENSE.md)

**stdnum-php** is a modern, framework-agnostic PHP 8.1+ library designed for parsing, formatting, and validating standard numbers and alphanumeric identifiers. This project is an architectural port inspired by the robust `python-stdnum` library, featuring an object-oriented and extensible design structure natively built for the PHP ecosystem.

Features
--------

[](#features)

- **Extensive Coverage**: Supports 106 international identification formats spanning across 71 countries.
- **Fluent &amp; Static Resolution**: Simple dot-notation to dynamically map specific validators (e.g. `br.cpf`, `us.ssn`, `cn.uscc`).
- **Laravel Integration Ready**: Includes a native generic rule `StdNumRule` that tightly integrates into Laravel's FormRequests and validators.
- **Standardized Interfaces**: All validators rigorously adhere to a single `DocumentInterface` contract implementing `validate()`, `isValid()`, `format()`, and `compact()`.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require gbielbarbosa/stdnum-php
```

Basic Usage
-----------

[](#basic-usage)

The library acts through a central `StdNum` factory or you can instance the classes independently.

### Pure PHP

[](#pure-php)

You can quickly evaluate identifiers using the dot notation format `[iso-code].[identifier-type]`.

```
use StdNum\StdNum;

// Returns boolean indicating if the identifier is valid
$isValid = StdNum::isValid('br.cpf', '390.533.447-05'); // true

// Returns a rich ValidationResult Object
$result = StdNum::validate('ch.uid', 'CHE-100.155.213');

if (! $result->isValid) {
    echo $result->error; // "Invalid checksum for Swiss UID"
}
```

### Laravel Usage

[](#laravel-usage)

The package comes bundled with `StdNumRule` for seamless Laravel integration:

```
use StdNum\Laravel\Rules\StdNumRule;
use Illuminate\Http\Request;

public function store(Request $request)
{
    $request->validate([
        'cuit' => ['required', new StdNumRule('ar.cuit')],
        'nif'  => ['required', new StdNumRule('es.nif')],
    ]);
}
```

### Formatting Identifiers

[](#formatting-identifiers)

In addition to checks, each format provides natively tailored presentation routines:

```
$validator = StdNum::make('cl.rut');
echo $validator->format('125319092'); // Outputs: "12.531.909-2"
echo $validator->compact('12.531.909-2'); // Outputs: "125319092"
```

Supported Formats
-----------------

[](#supported-formats)

Currently supported and rigorously tested identifier types include:

- 🇦🇩 **Andorra**: NRT
- 🇦🇱 **Albania**: NIPT
- 🇦🇷 **Argentina**: CUIT, DNI, CBU
- 🇦🇹 **Austria**: UID, TIN
- 🇦🇺 **Australia**: ABN, ACN, TFN
- 🇦🇿 **Azerbaijan**: VOEN
- 🇧🇪 **Belgium**: NN, VAT
- 🇧🇬 **Bulgaria**: EGN, PNF, VAT
- 🇧🇾 **Belarus**: UNP
- 🇧🇷 **Brazil**: CPF, CNPJ
- 🇨🇦 **Canada**: SIN, BN
- 🇨🇭 **Switzerland**: SSN, UID, VAT
- 🇨🇱 **Chile**: RUT
- 🇨🇳 **China**: RIC, USCC
- 🇨🇴 **Colombia**: NIT
- 🇨🇷 **Costa Rica**: CPF, CPJ, CR
- 🇨🇺 **Cuba**: NI
- 🇨🇾 **Cyprus**: VAT
- 🇨🇿 **Czech Republic**: DIC, RC
- 🇩🇪 **Germany**: STNR, VAT
- 🇩🇰 **Denmark**: CPR, CVR
- 🇩🇴 **Dominican Republic**: CEDULA, RNC
- 🇪🇨 **Ecuador**: CI, RUC
- 🇪🇪 **Estonia**: IK, KMKR, REGISTRIKOOD
- 🇪🇸 **Spain**: CIF, DNI, NIE, NIF
- 🇫🇮 **Finland**: ALV, HETU, YTUNNUS
- 🇫🇷 **France**: SIREN, SIRET, TVA
- 🇬🇧 **United Kingdom**: NINO, UTR, VAT
- 🇬🇷 **Greece**: AMKA, VAT
- 🇬🇹 **Guatemala**: NIT
- 🇮🇩 **Indonesia**: NIK, NPWP
- 🇮🇪 **Ireland**: PPS, VAT
- 🇮🇱 **Israel**: HP, IDNR
- 🇮🇳 **India**: AADHAAR, EPIC, PAN
- 🇮🇸 **Iceland**: KENNITALA, VSK
- 🇮🇹 **Italy**: CodiceFiscale, IVA
- 🇯🇵 **Japan**: CN
- 🇰🇷 **South Korea**: BRN, RRN
- 🇱🇹 **Lithuania**: ASMENS, PVM
- 🇱🇺 **Luxembourg**: TVA
- 🇱🇻 **Latvia**: PVN
- 🇲🇨 **Monaco**: TVA
- 🇲🇩 **Moldova**: IDNO
- 🇲🇪 **Montenegro**: PIB
- 🇲🇰 **North Macedonia**: EDB
- 🇲🇹 **Malta**: VAT
- 🇲🇺 **Mauritius**: NID
- 🇲🇽 **Mexico**: CURP, RFC
- 🇲🇾 **Malaysia**: NRIC
- 🇳🇱 **Netherlands**: BRIN, BSN, BTW, Identiteitskaartnummer, Onderwijsnummer, Postcode
- 🇳🇴 **Norway**: Fodselsnummer, KontoNr, MVA, OrgNr
- 🇳🇿 **New Zealand**: BankAccount, IRD
- 🇵🇪 **Peru**: CUI, RUC
- 🇵🇱 **Poland**: NIP, PESEL, REGON
- 🇵🇹 **Portugal**: CC, NIF
- 🇵🇾 **Paraguay**: RUC
- 🇷🇴 **Romania**: CF, CNP, CUI, ONRC
- 🇷🇸 **Serbia**: PIB
- 🇷🇺 **Russia**: INN, OGRN
- 🇸🇪 **Sweden**: Orgnr, Personnummer, VAT
- 🇸🇬 **Singapore**: UEN
- 🇸🇮 **Slovenia**: DDV, EMSO
- 🇸🇰 **Slovakia**: DPH, RC
- 🇸🇲 **San Marino**: COE
- 🇸🇻 **El Salvador**: NIT
- 🇹🇷 **Turkey**: TCKimlik, VKN
- 🇺🇦 **Ukraine**: EDRPOU
- 🇺🇸 **United States**: ATIN, EIN, ITIN, PTIN, RTN, SSN
- 🇺🇾 **Uruguay**: RUT
- 🇻🇪 **Venezuela**: RIF
- 🇿🇦 **South Africa**: ID, TIN

Testing
-------

[](#testing)

The project incorporates PHPUnit. All formulas and checksums are deeply tested over boundary conditions spanning hundreds of assertions mirroring their native environments.

```
composer test
```

License
-------

[](#license)

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

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance90

Actively maintained with recent releases

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

53d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7bc037955a0b761fe9053871c458dc72e82c3e37b3844d7d3a3be592ae616c1b?d=identicon)[gbielbarbosa](/maintainers/gbielbarbosa)

---

Top Contributors

[![gbielbarbosa](https://avatars.githubusercontent.com/u/76674028?v=4)](https://github.com/gbielbarbosa "gbielbarbosa (6 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/gbielbarbosa-stdnum-php/health.svg)

```
[![Health](https://phpackages.com/badges/gbielbarbosa-stdnum-php/health.svg)](https://phpackages.com/packages/gbielbarbosa-stdnum-php)
```

###  Alternatives

[ziming/laravel-zxcvbn

Zxcvbn Password validation rule for Laravel

3064.3k](/packages/ziming-laravel-zxcvbn)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
