2017 © Pedro Peláez
 

library brazilian-documents-validator

Validator for LARAVEL to validate CPF, CNPJ and CNH

image

douglasresendemaciel/brazilian-documents-validator

Validator for LARAVEL to validate CPF, CNPJ and CNH

  • Tuesday, March 28, 2017
  • by douglasresendemaciel
  • Repository
  • 1 Watchers
  • 0 Stars
  • 28 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 8 % Grown

The README.md

Validator for LARAVEL to validate BRAZILIAN DOCUMENTS

This library validate CPF, CNPJ, CNH, TÍTULO DE ELEITOR, NÚMERO DE IDENTIFICAÇÃO SOCIAL, CARTÃO NACIONAL DE SAÚDE, CERTIDÃO (NASCIMENTO/CASAMENTO/ÓBITO) numbers, (*1)

Installation

Run the following command from you terminal:, (*2)

bash composer require "douglasresendemaciel/brazilian-documents-validator:@dev", (*3)

or add this to require section in your composer.json file:, (*4)

"douglasresendemaciel/brazilian-documents-validator", (*5)

then run composer update, (*6)

Once it is installed, you do not need anymore to register in the service provider, the package will be load automatically., (*7)

Usage

  • cnpj - Check if the CNPJ number is valid
$this->validate($request, [
    'field_name' => 'required|cnpj',
]);
  • cpf - Check if the CPF number is valid
$this->validate($request, [
    'field_name' => 'required|cpf',
]);
  • cnh - Check if the CNH number is valid
$this->validate($request, [
    'field_name' => 'required|cnh',
]);
  • título de eleitor - Check if the TÍTULO DE ELEITOR number is valid
$this->validate($request, [
    'field_name' => 'required|titulo_eleitor',
]);
  • número de identificação social - Check if the NÚMERO DE IDENTIFICAÇÃO SOCIAL number is valid
$this->validate($request, [
    'field_name' => 'required|nis',
]);
  • cartão nacional de saúde - Check if the CARTÃO NACIONAL DE SAÚDE number is valid
$this->validate($request, [
    'field_name' => 'required|cns',
]);
  • certidão - Check if the CERTIDÃO number is valid
$this->validate($request, [
    'field_name' => 'required|certidao',
]);

OR you can use on RequestValidator files like this:, (*8)

'rules' => [
...
'field_name' => 'required|cpf',
...

Now is possible create fake document number from this packaged, you just need use the facade GenerateRandomDocument, (*9)

use DouglasResende\BrazilianDocumentsValidator\Facade\GenerateRandomDocument;

$cpf = GenerateRandomDocument::generateCPF();
$cnpj = GenerateRandomDocument::generateCNPJ();
$cnh = GenerateRandomDocument::generateCNH();

Author

Douglas Resende: http://www.douglasresende.com/, (*10)

License

References

For more information read the official documentation at https://laravel.com/docs/, (*11)

The Versions

28/03 2017

dev-master

9999999-dev

Validator for LARAVEL to validate CPF, CNPJ and CNH

  Sources   Download

MIT

The Requires

 

by Douglas Resende Maciel