nvf/lib/types/theme.nix
Charlie Root b2f694c78e
types/theme.nix: add check regex matching
types/theme.nix: fixed regex matching
2024-10-04 23:04:14 +02:00

14 lines
439 B
Nix

{lib}: let
inherit (lib.strings) isString;
inherit (lib.types) mkOptionType;
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 to determine wether the provided color is base16-valid
check = x: isString x && (match "#[0-9a-fA-F]{6}" x) != null;
};
}