jbafford/css-color-validator-bundle
A Symfony bundle that validates CSS color values, checking strings against supported color formats and specifications. Useful for form constraints and sanitizing user-supplied color input before it reaches your stylesheets.
#rgb/#rrggbbaa, legacy comma and modern space/slash rgb()/rgba(), hsl(), hwb(), lab(), oklch(), color(), named colors, currentColor, transparent. A hand-rolled pattern will silently reject valid input or accept garbage. The package's value is the encoded spec knowledge, not the code volume.#FFF → #ffffff, no converting hsl() to hex, no contrast ratios, no WCAG accessibility scoring. If the roadmap is "pick a brand color and we derive a compliant palette," this is roughly 5% of that feature.ValidationRule? That is hours of work, not an integration project — and it decouples the feature from the package's maintenance posture.Consider it when:
*Bundle naming and the era of the author's other work point at Symfony 3/4-era code. Run a throwaway composer require before any planning.Look elsewhere when:
lab(), lch(), oklch(), color(display-p3 …), color-mix(), relative color syntax). An older validator almost certainly predates these, and false rejections of valid user input are the worst failure mode for a validation rule — they surface as bugs against your product.#rrggbb, a short regex beats any dependency and can never block you.To executives: This is a small, MIT-licensed validation utility that closes one specific gap — malformed color values reaching our UI, our generated CSS, or customer-facing emails. It is not a strategic dependency and not a platform bet; it's a few hours of work that makes a theming or white-label feature safe to ship. The material caveat: it arrives as a Symfony bundle with essentially no community adoption, so the plan is to own a thin wrapper rather than lean on it as an ecosystem dependency — which also means the risk is contained and reversible at near-zero cost. If instead we need brand-palette derivation or accessibility scoring, that is a separate feature with a separate estimate and should not be bundled into this decision.
To engineering: The package validates CSS color specifications through a Symfony validator constraint. It is not Laravel-native — a bundle gives us no kernel, form, or container integration in Laravel — so the plan is to vendor the underlying validation logic and expose it as a single Laravel ValidationRule, plus a form-request rule where relevant. Please verify, in this order: (1) whether it even installs against our PHP and framework versions, timeboxed to an hour — the resolution failure is itself the cheapest proof; (2) which CSS color syntaxes it actually accepts, specifically modern space/slash rgb() and oklch()/color(), since an outdated grammar gives us false rejections; (3) that it fails closed on empty, null, and garbage input. Pin the version, fork into our namespace with MIT attribution, and add our own fixtures for every syntax we intend to accept. Do not expect upstream fixes.
Framing to avoid: don't describe this as "we adopted a color library." We adopted a spec table and a validation predicate. The maintenance burden — and the color roadmap beyond validation (normalization, contrast, palettes, accessibility) — remain ours.
How can I help you explore Laravel packages today?