PHP code example of experteam / indentification-number-validator

1. Go to this page and download the library: Download experteam/indentification-number-validator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

experteam / indentification-number-validator example snippets

 php
use Experteam\IndentificationNumberValidator\ValidatorFactory;

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

$result = $validator->validate([
    'identificationNumber' => 'GODE561231GR8',
    'identificationCode'   => 'RFC'
]);
 php
use Experteam\IndentificationNumberValidator\Contracts\IdentificationValidatorInterface;

class BRValidator implements IdentificationValidatorInterface
{
    public function validate(string $number): array
    {
        return [true, "{$name} is valid."];
    }
}
 php
case 'CO':
    return new COValidator();
 php
use Experteam\IndentificationNumberValidator\Exceptions\UnsupportedCountryException;

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