kaishiyoku / laravel-color-validation
Laravel color validation rules
Installs: 106 445
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 4
Forks: 23
Open Issues: 0
Requires
- php: ^8.1
- illuminate/support: ^10.0|^11.0
- illuminate/validation: ^10.0|^11.0
- spatie/regex: ^3.1
Requires (Dev)
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.34
- pestphp/pest-plugin-laravel: ^2.3
- phpunit/phpunit: ^10.5
README
About
This package will let you validate that a certain value is a valid CSS color string using Laravel >= 10.
Minimum requirements
- PHP 8.1
- Laravel 10
Installation
Install via composer - In the terminal:
composer require kaishiyoku/laravel-color-validation
If you're not using package auto-discovery add the following to the providers
array in your config/app.php
Kaishiyoku\Validation\Color\ServiceProvider::class,
Usage
// Test any color type Validator::make(['test' => '#454ACF'], ['test' => 'color']); // Test for rgb Validator::make(['test' => 'rgb(0, 200, 150)'], ['test' => 'color_rgb']); // Test for rgba Validator::make(['test' => 'rgba(0, 200, 150, 0.52)'], ['test' => 'color_rgba']); // Test for hex Validator::make(['test' => '#333'], ['test' => 'color_hex']); // Test for color name Validator::make(['test' => 'DeepSkyBlue'], ['test' => 'color_name']); Validator::make(['test' => 'transparent'], ['test' => 'color_name']);
Using other locales
By default English, German and French locales can be used. If you're using a different locale you will have to add a validation.php
file and a custom folder named after the locale code (e.g. ja
for Japanese) to the /resources/lang/vendor/color_validation/
folder.
Example folder structure:
.
└── resources
└── lang
└── vendor
└── color_validation
├── de
├── en
└── ja
Adjusting existing locales
If you want to change any of the existing translations, you can publish the locale files with:
php artisan vendor:publish --provider="Kaishiyoku\Validation\Color\ServiceProvider"
License
MIT (https://github.com/Kaishiyoku/laravel-color-validation/blob/master/LICENSE)
Author
Website: andreas-wiedel.de