PHPackages                             mateusjunges/cpf-cnpj-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. mateusjunges/cpf-cnpj-validator

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

mateusjunges/cpf-cnpj-validator
===============================

A simple class to validate CPF and CNPJ numbers

v1.0.0(3y ago)081MITPHPPHP ^8.1

Since Aug 19Pushed 3y ago1 watchersCompare

[ Source](https://github.com/mateusjunges/laravel-cpf-cnpj-validator)[ Packagist](https://packagist.org/packages/mateusjunges/cpf-cnpj-validator)[ RSS](/packages/mateusjunges-cpf-cnpj-validator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

CPF &amp; CNPJ Validator
========================

[](#cpf--cnpj-validator)

[![art/laravel-kafka.png](art/banner-readme.png)](art/banner-readme.png)

This package provide a simple API to validate brazilian CPF and CNPJ document numbers.

Sponsor my work!
================

[](#sponsor-my-work)

If you think this package helped you in any way, you can sponsor me on GitHub!

[![Sponsor Me](art/sponsor.png)](https://github.com/sponsors/mateusjunges)

### Installation

[](#installation)

You can install this package using composer:

```
composer require mateusjunges/cpf-cnpj-validator
```

### Usage

[](#usage)

To validate a document number, you can invoke the `Validator` class passing the `number` and optionally the document `type` as parameters:

```
use Junges\CpfCnpjValidator\Validator;

$v = (new Validator)("360.928.960-01"); // True

$v = (new Validator)("360.928.960-01", \Junges\CpfCnpjValidator\Enums\TaxId::CPF); // True

$v = (new Validator)("360.928.960-01", \Junges\CpfCnpjValidator\Enums\TaxId::CNPJ); // False

$v = (new Validator)("91.881.588/0001-95"); // True

$v = (new Validator)("91.881.588/0001-95", \Junges\CpfCnpjValidator\Enums\TaxId::CNPJ); // True

$v = (new Validator)("91.881.588/0001-95", \Junges\CpfCnpjValidator\Enums\TaxId::CPF); // True
```

### Testing

[](#testing)

Run `composer test` to test this package.

### Credits

[](#credits)

- [Mateus Junges](https://twitter.com/mateusjungess)

### License

[](#license)

This package is open-sourced software licensed under the [MIT License](https://opensource.org/licenses/MIT). Please see the [License file](LICENSE) for more information.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1362d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/83f45321b6bd97953b0c414e70d700f5adfdc031fc1eabae2fe7e8ce2470babf?d=identicon)[mateusjunges](/maintainers/mateusjunges)

---

Top Contributors

[![mateusjunges](https://avatars.githubusercontent.com/u/19756164?v=4)](https://github.com/mateusjunges "mateusjunges (20 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/mateusjunges-cpf-cnpj-validator/health.svg)

```
[![Health](https://phpackages.com/badges/mateusjunges-cpf-cnpj-validator/health.svg)](https://phpackages.com/packages/mateusjunges-cpf-cnpj-validator)
```

###  Alternatives

[propaganistas/laravel-phone

Adds phone number functionality to Laravel based on Google's libphonenumber API.

3.0k35.7M107](/packages/propaganistas-laravel-phone)[spatie/laravel-honeypot

Preventing spam submitted through forms

1.6k6.0M60](/packages/spatie-laravel-honeypot)[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[illuminate/validation

The Illuminate Validation package.

18936.7M1.4k](/packages/illuminate-validation)[axlon/laravel-postal-code-validation

Worldwide postal code validation for Laravel and Lumen

3853.3M1](/packages/axlon-laravel-postal-code-validation)

PHPackages © 2026

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