PHPackages                             wemersonrv/laravel-custom-rules - 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. wemersonrv/laravel-custom-rules

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

wemersonrv/laravel-custom-rules
===============================

Custom validator rules to laravel 5.5+

v0.6.2(6y ago)32571GPL-3.0-or-laterPHPPHP &gt;=7.0.0

Since May 17Pushed 6y ago2 watchersCompare

[ Source](https://github.com/wemersonrv/laravel-custom-rules)[ Packagist](https://packagist.org/packages/wemersonrv/laravel-custom-rules)[ RSS](/packages/wemersonrv-laravel-custom-rules/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)DependenciesVersions (12)Used By (0)

Custom validator rules
======================

[](#custom-validator-rules)

> Custom validator rules for Laravel 5.5+.

[![Latest Version on Packagist](https://camo.githubusercontent.com/a1963d3251446abcf15eaaf9c9dba00d8c5902def5a8f229ee99cb20bafffa83/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f77656d6572736f6e72762f6c61726176656c2d637573746f6d2d72756c65732e7376673f7374796c653d666c6174)](https://packagist.org/packages/wemersonrv/laravel-custom-rules)[![Total Downloads](https://camo.githubusercontent.com/8db9753b76c8a13ac40b8f9a5b5d13ed68041a05dfd0e10d5d9c8b455f565a80/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f77656d6572736f6e72762f6c61726176656c2d637573746f6d2d72756c65732e7376673f7374796c653d666c6174)](https://packagist.org/packages/wemersonrv/laravel-custom-rules)

This package contains custom validator rules for laravel 5.5+, made first for my personal use; so it's grwoing damn slowly 😫! If you don't find anything useful, please tell me or make a PR.

**Important: This project was made thinking in package autodiscover, so it needs at least version 5.5+ of Laravel Framework**

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

[](#installation)

```
composer require wemersonrv/laravel-custom-rules
```

Usage
-----

[](#usage)

Use it with laravel validator rules in the way you most like: Custom Request, `\Validator` facade, etc.

```
$rules = [
    'cpf' => 'required,cpf',
    'cnpj' => 'required,cnpj',
    'cellphone' => 'mobile_br',
    'landline' => 'landline_br',
    'postal_code' => 'cep',
    'mac' => 'required|mac_address',
];

$errorMsgs = [
    'cpf' => 'The :attribute must be a valid Brazilian CPF.',
    'cnpj' => 'The :attribute must be a valid Brazilian CNPJ.',
    'mobile_br' => 'Invalid mobile number.', // The show is yours, do as you want!
    'landline_br' => 'Invalid landline number.',
    'cep' => 'The :attribute must be a valid Brazilian ZIP Code (CEP).',
    'mac_address' => 'The :attribute must be a valid MAC address',
];

$validator = \Validator::make($request->all(), $rules, $errorMsgs);
if($validator->fails()){
    return response($validator->errors(), 400);
}
```

To-do List
----------

[](#to-do-list)

- Brazilian CPF
- Brazilian CNPJ
- Brazilian Mobile phone with 9 digit
- Brazilian ZIP code (CEP)
- Brazilian Landline phone
- Brazilian states (UF)
- Mac Address

Release History
---------------

[](#release-history)

- 0.6.2
    - BUGFIX: Fix CNPJ digits check
    - CHANGE: Fix digit calculation, force 0 when rest result is 10
- 0.6.1
    - BUGFIX: Fix CPF digits check
    - CHANGE: Fix digit calculation, force 0 when rest result is 10
- 0.6.0
    - Macc Address
    - ADD: Mac Address rule (`mac_address`)
- 0.5.0
    - Brazilian Landline number
    - ADD: Brazilian Landline rule (`landline_br`)
- 0.4.0
    - Brazilian ZIP Code (CEP)
    - ADD: Brazilian Postal Code (`cep`)
- 0.3.1
    - Sanitize value before validation
    - CHANGE: Extract only digits (without mask chars) to validate
- 0.3.0
    - Brazilian CNPJ
    - ADD: Brazilian CNPJ rule (`cnpj`)
- 0.2.0
    - Brazilian Mobile (with 9 digit check)
    - ADD: Brazilian Mobile rule (`mobile_br`)
- 0.1.1
    - BUGFIX: Just Service provider requires, bu changing namespace
    - CHANGE: From `use Rules\Cpf` to `use Wemersonrv\CustomRules\Rules\Cpf`
- 0.1.0
    - The first proper release
    - ADD: Brazilian CPF rule (`cpf`)
- 0.0.1
    - Work in progress

References
----------

[](#references)

- Laravel Framework
    -

Meta
----

[](#meta)

Wemerson Guimarães – [@WemersonCG](https://twitter.com/WemersonCG) –

Distributed under the GPLv3 license. See [LICENSE.md](LICENSE.md) for more information.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

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

Every ~1 days

Total

11

Last Release

2539d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/04ac2c1e617785db3b326f05f60b2ee19e9b1748fba10b10c1700b6567ef09fa?d=identicon)[wemersonrv](/maintainers/wemersonrv)

---

Top Contributors

[![wemersonrv](https://avatars.githubusercontent.com/u/2028673?v=4)](https://github.com/wemersonrv "wemersonrv (11 commits)")

---

Tags

laravelvalidatorrules

### Embed Badge

![Health badge](/badges/wemersonrv-laravel-custom-rules/health.svg)

```
[![Health](https://phpackages.com/badges/wemersonrv-laravel-custom-rules/health.svg)](https://phpackages.com/packages/wemersonrv-laravel-custom-rules)
```

###  Alternatives

[illuminatech/validation-composite

Allows uniting several validation rules into a single one for easy re-usage

184485.5k](/packages/illuminatech-validation-composite)[iutrace/laravel-cuit-validator

Argentinian CUIT and CUIL Validator

1013.3k](/packages/iutrace-laravel-cuit-validator)[stuyam/laravel-phone-validator

A phone validator for Laravel using the free Twilio phone lookup service.

2861.3k](/packages/stuyam-laravel-phone-validator)[laravel-validation-rules/us-state

Validate US States and Canada Provinces

16172.7k](/packages/laravel-validation-rules-us-state)[laravel-validation-rules/timezone

Validate that a given timezone is valid.

2119.0k](/packages/laravel-validation-rules-timezone)

PHPackages © 2026

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