tylercd100 / laravel-validator-color
在 Laravel 5 中验证某个值是否为有效的 CSS 颜色字符串
3.0.2
2017-04-20 17:26 UTC
Requires
- php: ^5.5.9|^7.0
- illuminate/support: ^5.0
- illuminate/validation: ^5.0
Requires (Dev)
- orchestra/testbench: ^3.2
- phpunit/phpunit: ^4.8|^5.0
README
此包将允许您验证某个值是否为有效的 CSS 颜色字符串。
安装
通过 composer 安装 - 在终端中
composer require tylercd100/laravel-validator-color
现在,将以下内容添加到您的 config/app.php
文件中的 providers
数组中
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']);