Download the PHP package bachilli/laravel-request-rules without Composer
On this page you can find all versions of the php package bachilli/laravel-request-rules. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bachilli/laravel-request-rules
More information about bachilli/laravel-request-rules
Files in bachilli/laravel-request-rules
Package laravel-request-rules
Short Description Stop duplicating code and validations for FormRequests. This package provides reuse of FormRequest components in a generic way!
License MIT
Homepage https://github.com/bachilli/laravel-request-rules
Informations about the package laravel-request-rules
Reuse rules and compose FormRequests
Stop duplicating code and validations for FormRequests. This package provides reuse of FormRequest rules in a generic way!
Installation
You can install the package via composer:
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:
The first array on resolveRules method is exclusive for your FormRequest, the second array is the composed rules, imported from other FormRequests.
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")
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])
You can import only rules if you want.
except(['field_name', SomeFormRequest::class])
You can do the opposite, importing all rules, except the specified ones.
Testing
Not implemented yet.
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Bachilli
- All Contributors
License
The MIT License (MIT). Please see License File for more information.