experteam/indentification-number-validator

PHP library for validating identification documents from multiple countries

Installs: 20

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/experteam/indentification-number-validator

1.0.2 2025-12-12 01:59 UTC

This package is auto-updated.

Last update: 2025-12-12 02:01:23 UTC


README

A PHP library for validating identification numbers from multiple countries.
Provides a simple and unified interface for validating official national documents.

Install

composer require experteam/indentification-number-validator

Update

composer update experteam/indentification-number-validator

Usage

Basic Example

use Experteam\IndentificationNumberValidator\ValidatorFactory;

$validator = ValidatorFactory::make('MX'); // Mexico example

$result = $validator->validate([
    'identificationNumber' => 'GODE561231GR8',
    'identificationCode'   => 'RFC'
]);

Supported Countries

Supported Countries

Country Code Validator Class
Brasil BR BRValidator
GUATEMALA GT GTValidator

More countries can be added easily.

Adding a New Country

  1. Create a new validator inside src/Validators/.
use Experteam\IndentificationNumberValidator\Contracts\IdentificationValidatorInterface;

class BRValidator implements IdentificationValidatorInterface
{
    public function validate(string $number): array
    {
        return [true, "{$name} is valid."];
    }
}
  1. Register the validator in ValidatorFactory.php:
case 'CO':
    return new COValidator();

Error Handling

use Experteam\IndentificationNumberValidator\Exceptions\UnsupportedCountryException;

try {
    ValidatorFactory::make('XX');
} catch (UnsupportedCountryException $e) {
    echo $e->getMessage();
}