nikhilbhatia22/laravel-validator-color

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

Maintainers

Package info

github.com/nikhilbhatia22/laravel-validator-color

pkg:composer/nikhilbhatia22/laravel-validator-color

Statistics

Installs: 31 212

Dependents: 0

Suggesters: 0

Stars: 1

v11.0.0 2024-09-30 04:49 UTC

This package is auto-updated.

Last update: 2026-03-29 00:48:58 UTC


README

Latest Version Software License For Laravel 5

This package will let you validate that a certain value is a valid CSS color string.

Installation

Install via composer - In the terminal:

composer require nikhilbhatia22/laravel-validator-color

For Laravel version below 5.5, add the following to the providers array in your config/app.php

Nikhilbhatia22\Validator\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 css color keyword 
Validator::make(['test' => 'gold'], ['test' => 'color_keyword']);