Download the PHP package wessama/laravel-pretty-validation-messages without Composer
On this page you can find all versions of the php package wessama/laravel-pretty-validation-messages. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wessama/laravel-pretty-validation-messages
More information about wessama/laravel-pretty-validation-messages
Files in wessama/laravel-pretty-validation-messages
Package laravel-pretty-validation-messages
Short Description Simple trait to dynamically set up validation messages for Laravel form requests
License MIT
Informations about the package laravel-pretty-validation-messages
Laravel Pretty Validation Messages
Laravel Pretty Validation Messages is a Laravel package providing a trait for FormRequests to use translation strings for validation messages.
Installation
You can install the package via composer:
Or you can just add it to your composer.json
file:
Otherwise, you can clone the repo and include the trait in your FormRequests manually.
Usage
After installation, use the HasPrettyValidationMessages
trait in your FormRequest classes:
Set up your localization strings with keys that match the expected pattern.
The whole point is to not have to write message()
methods over and over again for every FormRequest
you have
in your project. Instead, you can plug this trait into any FormRequest
and have it automatically use the
translation strings you've already defined.
The trait will look for a translation string with the following pattern:
Where {fqcn}
is the fully qualified class name of the FormRequest
, {field}
is the name of the FormRequest
being validated, and {rule}
is the name of the validation rule.
For instance, take the following FormRequest
:
Your translation strings would look like this:
Testing
You can run the tests with:
Credits
- Wessam Ahmed
License
The MIT License (MIT). Please see License File for more information.