kaishiyoku/laravel-color-validation

Laravel color validation rules
233,732 5
Install
composer require kaishiyoku/laravel-color-validation
Latest Version:4.0.0
PHP:^8.2
License:MIT
Last Updated:Mar 6, 2026
Links: GitHub  ·  Packagist
Maintainer: Kaishiyoku

Tests Latest Stable Version Total Downloads License PHP Version Require

About

This package will let you validate that a certain value is a valid CSS color string using Laravel >= 10.

Minimum requirements

  • PHP 8.2
  • Laravel 11

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

Related Packages

nikhilbhatia22/laravel-validator-color

Validate that a certain value is a valid CSS color string in Laravel 5 and above

32,813 1
scybulski/laravel-validator-color

Validate that a certain value is a valid CSS color string in Laravel

2,223 0
tylercd100/laravel-validator-color

Validate that a certain value is a valid CSS color string in Laravel 5

81,613 15
russoedu/colorvalidator

Custom Laravel 5 Validator for hexadecimal color

55 2
tylercd100/laravel-validator-phone

Validate that a phone number is in the correct format

4,377 3

Version History

Version Released PHP Laravel License
4.0.0 ^8.2 ^11.0|^12.0|^13.0 MIT
3.2.0 ^8.1 ^10.0|^11.0|^12.0 MIT
3.1.0 ^8.1 ^10.0|^11.0 MIT
3.0.0 ^8.1 ^10.0 MIT
2.1.1 ^7.4|^8.0 ^6.0|^7.0|^8.0|^9.0|^10.0 MIT