Skip to content

Commit 94be72d

Browse files
committed
types/theme.nix: add check regex matching
1 parent 7ba06fd commit 94be72d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/types/theme.nix

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{lib}: let
2-
inherit (lib.strings) isString hasPrefix;
2+
inherit (lib.strings) isString;
33
inherit (lib.types) mkOptionType;
4-
inherit (builtins) stringLength;
4+
inherit (builtins) match;
55
# This was almost entirely taken from raf himself.
66
in {
77
hexColorType = mkOptionType {
88
name = "hex-color";
99
descriptionClass = "noun";
1010
description = "RGB color in hex format";
11-
check = x: isString x && hasPrefix "#" x && stringLength x == 7;
11+
# Check to determine wether the provided color is base16-valid
12+
check = x: isString x && match "#[0-9a-fA-F]{6}" x;
1213
};
1314
}

0 commit comments

Comments
 (0)