PHP code example of esponsor / dni-validator

1. Go to this page and download the library: Download esponsor/dni-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/ */

    

esponsor / dni-validator example snippets


use Esponsor\DniValidator\CpfBrazil;
use Esponsor\DniValidator\RutChile;

$rut = new RutChile();
$rut->validate('11.111.111-1'); // true
$rut->clean('11.111.111-1');    // '111111111'
$rut->format('111111111');      // '11.111.111-1'

$cpf = new CpfBrazil();
$cpf->validate('111.444.777-35'); // true
$cpf->format('11144477735');      // '111.444.777-35'

use Esponsor\DniValidator\Rules\CpfBrazilRule;
use Esponsor\DniValidator\Rules\RutChileRule;

$request->validate([
    'rut' => ['

use Esponsor\DniValidator\DocumentValidatorRegistry;

DocumentValidatorRegistry::validate('CL', 'RUT', '11.111.111-1');      // true
DocumentValidatorRegistry::validate('ar', 'cuit/cuil', '20-12345678-6'); // true

$validator = DocumentValidatorRegistry::for('UY', 'RUT');
$validator->format('211003360014'); // '21-100336-001-4'

DocumentValidatorRegistry::for('CL', 'UNKNOWN'); // null