Validate that a certain value is a valid CSS color string in Laravel 5
tylercd100/laravel-validator-color is a Laravel package for validate that a certain value is a valid css color string in laravel 5.
It currently has 15 GitHub stars and 81.292 downloads on Packagist (latest version 3.0.2).
Install it with composer require tylercd100/laravel-validator-color.
Discover more Laravel packages by tylercd100
or browse all Laravel packages to compare alternatives.
Last updated
This package will let you validate that a certain value is a valid CSS color string.
Install via composer - In the terminal:
composer require tylercd100/laravel-validator-color
Now add the following to the providers array in your config/app.php
Tylercd100\Validator\Color\ServiceProvider::class
// 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 css color keyword
Validator::make(['test' => 'gold'], ['test' => 'color_keyword']);