From b2f694c78e95a6689e62ad3784d569dee48bff51 Mon Sep 17 00:00:00 2001 From: Charlie Root Date: Fri, 4 Oct 2024 23:01:41 +0200 Subject: [PATCH] types/theme.nix: add check regex matching types/theme.nix: fixed regex matching --- lib/types/theme.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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; }; }