PHPackages                             douglasresendemaciel/brazilian-documents-validator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. douglasresendemaciel/brazilian-documents-validator

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

douglasresendemaciel/brazilian-documents-validator
==================================================

Validator for LARAVEL to validate CPF, CNPJ and CNH

44.8k↓55.6%3PHPCI failing

Since May 13Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/douglasresendemaciel/brazilian-documents-validator)[ Packagist](https://packagist.org/packages/douglasresendemaciel/brazilian-documents-validator)[ RSS](/packages/douglasresendemaciel-brazilian-documents-validator/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Validator for LARAVEL to validate BRAZILIAN DOCUMENTS
=====================================================

[](#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

Installation
------------

[](#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 do not need anymore to register in the service provider, the package will be load automatically.

Usage
-----

[](#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:

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

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

```
use DouglasResende\BrazilianDocumentsValidator\Facade\GenerateRandomDocument;

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

Author
------

[](#author)

Douglas Resende:

License
-------

[](#license)

References
----------

[](#references)

For more information read the official documentation at

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance59

Moderate activity, may be stable

Popularity27

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 67.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/34d28941a36733330db0c19c87dee6d9e6c84c55487398d6a23870fdc98a9651?d=identicon)[douglasresendemaciel](/maintainers/douglasresendemaciel)

---

Top Contributors

[![douglasresendemaciel](https://avatars.githubusercontent.com/u/11336192?v=4)](https://github.com/douglasresendemaciel "douglasresendemaciel (21 commits)")[![nocartorio-douglas-resende](https://avatars.githubusercontent.com/u/204616479?v=4)](https://github.com/nocartorio-douglas-resende "nocartorio-douglas-resende (3 commits)")[![spelcaster](https://avatars.githubusercontent.com/u/3278419?v=4)](https://github.com/spelcaster "spelcaster (3 commits)")[![mayckol](https://avatars.githubusercontent.com/u/43302737?v=4)](https://github.com/mayckol "mayckol (2 commits)")[![samuel-lucas-nocartorio](https://avatars.githubusercontent.com/u/204731754?v=4)](https://github.com/samuel-lucas-nocartorio "samuel-lucas-nocartorio (2 commits)")

### Embed Badge

![Health badge](/badges/douglasresendemaciel-brazilian-documents-validator/health.svg)

```
[![Health](https://phpackages.com/badges/douglasresendemaciel-brazilian-documents-validator/health.svg)](https://phpackages.com/packages/douglasresendemaciel-brazilian-documents-validator)
```

###  Alternatives

[marcosh/php-validation-dsl

A DSL for validating data in a functional fashion

483.9k](/packages/marcosh-php-validation-dsl)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
