Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Colour Laravel Package

laravel-validation-rules/colour

Laravel validation rules for colour values. Validate CSS colour formats such as hex, RGB, RGBA, HSL and HSLA, plus named colours, using simple rule objects you can drop straight into form requests and validators.

View on GitHub
Deep Wiki
Context7

Validate colours

Frequently asked questions about Colour
How do I install laravel-validation-rules/colour?
Install it with Composer using composer require laravel-validation-rules/colour. The package is a dependency-light Laravel utility that provides Rule objects, so there is no service provider bootstrapping or config publishing step described. You can then reference the rule classes directly in your form requests or validator calls.
Which colour formats does laravel-validation-rules/colour validate?
It provides rules for CSS colour formats including hex, RGB, RGBA, HSL and HSLA, plus named-colour variants. Each format is exposed as a simple rule object you can drop into Laravel's validation pipeline. Check the package source or tagged release for the exact grammar accepted by each rule, especially if you need modern space-separated syntax or percentage alpha values.
How do I use a colour validation rule in a Laravel FormRequest?
Instantiate the relevant rule class, such as the hex or RGB rule, and add it to the rules array for the colour field in your FormRequest. The rule implements Laravel's validation Rule contract, so it runs inside the normal validator without extra wiring. Apply it at the request boundary and keep any colour value object or domain model independent of the third-party rule class.
Does laravel-validation-rules/colour support Laravel 11 and Laravel 12?
The technical assessment found no evidence of declared support for Laravel 11/12 or PHP 8.3+, and the last release was 2023-02-15. Check the tagged release's Composer constraints against your upgrade matrix before adopting it. Because the package is small and regex-backed, a fork or in-house replacement is a realistic fallback if constraints do not match.
Can I validate CSS named colours with this package?
Yes. The package includes named-colour variants alongside its hex, RGB, RGBA, HSL and HSLA rules. That makes it usable for fields where users may enter values like colour keywords rather than only functional or hex notation. Confirm the exact accepted named-colour list in the source if your product contract depends on a specific CSS colour keyword set.
Does laravel-validation-rules/colour normalise colours to a canonical value?
No. The package validates whether a value matches a colour format; it does not canonicalise input to a single stored representation. If your application needs one canonical format, add a normalisation step after validation and decide whether you store the raw validated string or the normalised value. Keep that ownership explicit in your domain or application layer.
Is it safe to use these colour rules for user-supplied CSS values?
Treat the rule as a security boundary, not just a UX check, because colour strings can end up in inline CSS or style blocks. Escape output regardless of validation, and verify that the accepted grammar is no looser than your intended CSS context. Also test regex behaviour with pathological inputs such as very long hex-like strings or unbalanced parentheses in rgb forms.
Is laravel-validation-rules/colour still maintained?
The assessment flags maintenance risk: last release 2023-02-15, about 33 stars and a single-maintainer pattern. There is low community scrutiny, so edge cases in colour parsing may not be fixed upstream quickly. Mitigate by assigning an internal owner and keeping a fork or a small in-house rule ready, since the package's value is a handful of anchored regular expressions.
Can I use the colour rules with an inline Laravel validator instead of a FormRequest?
Yes. The rules are Rule objects implementing Illuminate\Contracts\Validation\Rule, so they can be used anywhere Laravel's validator accepts rule instances, including inline validator calls. You do not need a service provider or package configuration to use them. Keep them in the HTTP or validation layer so shared domain packages are not coupled to the third-party class.
What are the alternatives to laravel-validation-rules/colour?
The main alternative is an in-house Laravel Rule or a small fork containing the needed colour regexes, which is a same-day replacement given the package's narrow scope. Check whether a first-party or more broadly maintained validation package already exists in your dependency set. If you keep this package, consolidate existing ad-hoc colour regex and allowlists behind tests with a shared accept/reject corpus.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console