1. Go to this page and download the library: Download br-validation/docs 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/ */
use Validation\BrDocs\BrDocs;
// CPF
BrDocs::validateCpf('123.456.789-09');
BrDocs::formatCpf('12345678909');
BrDocs::generateCpf(true);
// CNPJ
BrDocs::validateCnpj('11.222.333/0001-81');
BrDocs::formatCnpj('11222333000181');
BrDocs::generateCnpj(true);
// CPF/CNPJ automático
BrDocs::validateCpfCnpj('123.456.789-09'); // Detecta CPF e valida
BrDocs::validateCpfCnpj('11.222.333/0001-81'); // Detecta CNPJ e valida
BrDocs::detectCpfCnpj('12345678909'); // 'cpf'
BrDocs::detectCpfCnpj('11222333000181'); // 'cnpj'
// CEP
BrDocs::validateCep('01001-000');
BrDocs::formatCep('01001000');
BrDocs::getCepRegion('01001000'); // 'Grande São Paulo'
// Telefone
BrDocs::validateTelefone('(11) 99988-7766');
BrDocs::formatTelefone('11999887766');
BrDocs::isCellphone('11999887766'); // true
BrDocs::isLandline('1133334444'); // true
// Outros
BrDocs::validateCnh('04965101679');
BrDocs::validatePis('123.45678.90-1');
BrDocs::validateTituloEleitor('123456780612');
BrDocs::validateRenavam('63abortar905');
BrDocs::validateInscricaoEstadual('123456789');
BrDocs::validateInscricaoEstadualByUf('110042490114', 'SP');
BrDocs::validateCertidao('10452601552014100032003000000012');
use Validation\BrDocs\Validators\Cpf;
use Validation\BrDocs\Validators\Cnpj;
use Validation\BrDocs\Validators\Cep;
Cpf::validate('123.456.789-09');
Cpf::format('12345678909');
Cpf::sanitize('123.456.789-09');
Cpf::generate(true);
Cnpj::validate('11.222.333/0001-81');
Cep::getRegion('01001-000');
// Listar tipos suportados
BrDocs::supportedTypes();
// ['cpf', 'cnpj', 'cpf_cnpj', 'cpfcnpj', 'cep', 'cnh', 'pis', ...]
// Verificar se um tipo é suportado
BrDocs::isSupported('cpf'); // true
BrDocs::isSupported('xyz'); // false
use Validation\BrDocs\BrDocs;
use Validation\BrDocs\Exceptions\DocumentException;
try {
BrDocs::validateOrFail('cpf', '000.000.000-00');
} catch (DocumentException $e) {
echo $e->getMessage(); // 'O CPF informado "000.000.000-00" é inválido.'
}
try {
BrDocs::validate('xyz', '12345');
} catch (DocumentException $e) {
echo $e->getMessage(); // 'O tipo de documento "xyz" não é suportado.'
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.