GeoLeaf Core API - v3.0.0
    Preparing search index...
    • Validates a CSS colour.

      Three literal forms are recognised without help — #RGB/#RRGGBB, rgb() and rgba(). Everything else (named colours, hsl(), modern syntaxes) is delegated to CSS.supports("color", …).

      ⚠️ That fallback is browser-only. Where CSS is undefined — Node, SSR, a bare test runner — "red" and "hsl(120, 100%, 50%)" are reported invalid, while the three literal forms keep working. A colour validated server-side is therefore not validated by the same rule as one validated in the page.

      Parameters

      Returns { valid: boolean; error: string | null }

      { valid, error }; error is null when valid.

      GeoLeafError A ValidationError when invalid and throwOnError is set.

      GeoLeaf.Validators.validateColor("#ff0000"); // valide
      GeoLeaf.Validators.validateColor("rgb(255, 0, 0)"); // valide
      GeoLeaf.Validators.validateColor("rgba(0,0,0,0.5)"); // valide
      GeoLeaf.Validators.validateColor("red"); // valide en navigateur (CSS.supports)
      GeoLeaf.Validators.validateColor("hsl(120, 100%, 50%)"); // valide en navigateur
      GeoLeaf.Validators.validateColor("#gggggg"); // invalide