PHPackages                             bachilli/laravel-request-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. bachilli/laravel-request-rules

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

bachilli/laravel-request-rules
==============================

Stop duplicating code and validations for FormRequests. This package provides reuse of FormRequest components in a generic way!

1.1.0(6y ago)2101MITPHPPHP ^7.1CI failing

Since Feb 18Pushed 6y ago1 watchersCompare

[ Source](https://github.com/bachilli/laravel-request-rules)[ Packagist](https://packagist.org/packages/bachilli/laravel-request-rules)[ Docs](https://github.com/bachilli/laravel-request-rules)[ RSS](/packages/bachilli-laravel-request-rules/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (3)Versions (3)Used By (0)

Reuse rules and compose FormRequests
====================================

[](#reuse-rules-and-compose-formrequests)

[![Latest Version on Packagist](https://camo.githubusercontent.com/34fc61a8ea32608e7ceb888859d70193647d76a8a116445a8d50187e308f3fb0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62616368696c6c692f6c61726176656c2d726571756573742d72756c65732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bachilli/laravel-request-rules)[![Build Status](https://camo.githubusercontent.com/600d73476a21de913f6180a6b1c3c0f452fe9b73f0ea47e5a77b96058daf7717/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f62616368696c6c692f6c61726176656c2d726571756573742d72756c65732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/bachilli/laravel-request-rules)[![Quality Score](https://camo.githubusercontent.com/fd2f98d975b95e81f1dfe9d4f2e32220b3d1e36eff85da55f6361f3657f2b6db/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f62616368696c6c692f6c61726176656c2d726571756573742d72756c65732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/bachilli/laravel-request-rules)[![Total Downloads](https://camo.githubusercontent.com/15999096d15cf7500c768e4291c3bf5cdc6b407c3c34017e348b3f822cce2449/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f62616368696c6c692f6c61726176656c2d726571756573742d72756c65732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bachilli/laravel-request-rules)

Stop duplicating code and validations for FormRequests. This package provides reuse of FormRequest rules in a generic way!

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

[](#installation)

You can install the package via composer:

```
composer require bachilli/laravel-request-rules
```

Usage
-----

[](#usage)

Create your main FormRequests with all your validation rules. After that, create unique FormRequests for your controller methods. There is an example of a StoreProductRequest:

```
public function rules()
    {
        return RequestRule::resolveRules(
            [
            'name' => 'required',
            ],
            [
                RequestRule::merge(VolumeEntityFormRequest::class, 'volumes.*', 'required|array')->only(['dimensions'])->get(),
                RequestRule::merge(ProductEntityFormRequest::class, 'products.*')->except(['price'])->get(),
            ]);
    }
```

The first array on resolveRules method is exclusive for your FormRequest, the second array is the composed rules, imported from other FormRequests.

Methods
-------

[](#methods)

There some helper methods available to use when you're importing rules. Below the description of all methods.

### merge(SomeFormRequest::class, 'desired\_field\_name', 'optional\_validations")

[](#mergesomeformrequestclass-desired_field_name-optional_validations)

In the `desired_field_name` you can pass with the suffix `.*` to specify an array field.

The `optional_validations` are useful when you need an array field and want some validation, like `required`.

### only(\['field\_name', SomeFormRequest::class\])

[](#onlyfield_name-someformrequestclass)

You can import only rules if you want.

### except(\['field\_name', SomeFormRequest::class\])

[](#exceptfield_name-someformrequestclass)

You can do the opposite, importing all rules, except the specified ones.

### Testing

[](#testing)

Not implemented yet.

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Bachilli](https://github.com/bachilli)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.3% 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 ~13 days

Total

2

Last Release

2260d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fe982ad2cbdb2f016e1a845f388d376d93696ac61f2e35c276426f3cb8c65256?d=identicon)[bachilli](/maintainers/bachilli)

---

Top Contributors

[![bachilli](https://avatars.githubusercontent.com/u/1070049?v=4)](https://github.com/bachilli "bachilli (14 commits)")[![lmtortelli](https://avatars.githubusercontent.com/u/7454674?v=4)](https://github.com/lmtortelli "lmtortelli (1 commits)")

---

Tags

Bachillilaravel-request-rulesrequest-validation-groupsrequest-rule-groupsrequest-rules

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bachilli-laravel-request-rules/health.svg)

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

###  Alternatives

[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)[axlon/laravel-postal-code-validation

Worldwide postal code validation for Laravel and Lumen

3853.3M1](/packages/axlon-laravel-postal-code-validation)[sunspikes/clamav-validator

Custom Laravel 5 anti-virus validator for file uploads.

3651.8M3](/packages/sunspikes-clamav-validator)[laravel-validation-rules/credit-card

Validate credit card number, expiration date, cvc

2412.2M5](/packages/laravel-validation-rules-credit-card)

PHPackages © 2026

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