douglasresendemaciel / brazilian-documents-validator by douglasresendemaciel

Validator for LARAVEL to validate CPF, CNPJ and CNH
3,222
4
2
Package Data
Maintainer Username: douglasresendemaciel
Maintainer Contact: eu@douglasresende.com (Douglas Resende Maciel)
Package Create Date: 2017-03-28
Package Last Update: 2024-10-10
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2025-02-09 15:00:22
Package Statistics
Total Downloads: 3,222
Monthly Downloads: 157
Daily Downloads: 0
Total Stars: 4
Total Watchers: 2
Total Forks: 2
Total Open Issues: 0

Validator for LARAVEL to validate CPF, CNPJ and CNH

This library validate CPF, CNPJ and CNH numbers

Installation

Run the following command from you terminal:

composer require "douglasresendemaciel/brazilian-documents-validator:@dev"

or add this to require section in your composer.json file:

"douglasresendemaciel/brazilian-documents-validator"

then run composer update

Once it is installed, you need to register the service provider. Open up config/app.php and add the following to the providers key.

'providers' => [
...
DouglasResende\BrazilianDocumentsValidator\BrazilianDocumentsProvider::class
...

Usage

  • cnpj - Check if the CNPJ number is valid
$this->validate($request, [
    'cnpj' => 'required|cnpj',
]);
  • cpf - Check if the CPF number is valid
$this->validate($request, [
    'cpf' => 'required|cpf',
]);
  • cnh - Check if the CNH number is valid
$this->validate($request, [
    'cnh' => 'required|cnh',
]);

OR you can use on RequestValidator files like this:

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

Author

Douglas Resende: http://www.douglasresende.com/

License

References

For more information read the official documentation at https://laravel.com/docs/5.4/