diff --git a/lib/types/theme.nix b/lib/types/theme.nix index 98c0f0fd..3ba2f489 100644 --- a/lib/types/theme.nix +++ b/lib/types/theme.nix @@ -1,13 +1,14 @@ {lib}: let - inherit (lib.strings) isString hasPrefix; + inherit (lib.strings) isString; inherit (lib.types) mkOptionType; - inherit (builtins) stringLength; + inherit (builtins) match; # This was almost entirely taken from raf himself. in { hexColorType = mkOptionType { name = "hex-color"; descriptionClass = "noun"; description = "RGB color in hex format"; - check = x: isString x && hasPrefix "#" x && stringLength x == 7; + # Check to determine wether the provided color is base16-valid + check = x: isString x && (match "#[0-9a-fA-F]{6}" x) != null; }; }