Package Data | |
---|---|
Maintainer Username: | russoedu |
Maintainer Contact: | russoedu@gmail.com (Eduardo Russo) |
Package Create Date: | 2015-09-10 |
Package Last Update: | 2018-01-21 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-21 03:00:14 |
Package Statistics | |
---|---|
Total Downloads: | 54 |
Monthly Downloads: | 2 |
Daily Downloads: | 0 |
Total Stars: | 2 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 1 |
Validator for hexadecimal colors for Laravel 5.
![Software License][ico-license]
Install the package through Composer.
composer require "russoedu/colorvalidator:1.0"
Add the following to your providers
array in app/config/app.php
:
'providers' = [
Russoedu\ColorValidator\ColorValidatorServiceProvider::class,
]
The package extends the Illuminate\Validator
via a service provider, so all you have to do is use the hex_color
-rule.
public function store(Request $request) {
$this->validate($request, [
'color' => 'hex_color'
]);
}
Of course, you can roll your own error messages:
$validator = Validator::make($request->all(), [
'color' => 'hex_color'
], [
'color.hex_color' => "Hey! That's not real color!"
]);
if($validator->fails()) {
return $this->returnWithErrorAndInput($validator);
}
If you're using the validation throughout your application, you also might want to put the error message in your lang-files.
The MIT License (MIT). Please see License File for more information.