mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-02-24 04:18:03 +00:00
types/theme.nix: add check regex matching
types/theme.nix: fixed regex matching
This commit is contained in:
parent
7ba06fd77c
commit
b2f694c78e
1 changed files with 4 additions and 3 deletions
|
@ -1,13 +1,14 @@
|
||||||
{lib}: let
|
{lib}: let
|
||||||
inherit (lib.strings) isString hasPrefix;
|
inherit (lib.strings) isString;
|
||||||
inherit (lib.types) mkOptionType;
|
inherit (lib.types) mkOptionType;
|
||||||
inherit (builtins) stringLength;
|
inherit (builtins) match;
|
||||||
# This was almost entirely taken from raf himself.
|
# This was almost entirely taken from raf himself.
|
||||||
in {
|
in {
|
||||||
hexColorType = mkOptionType {
|
hexColorType = mkOptionType {
|
||||||
name = "hex-color";
|
name = "hex-color";
|
||||||
descriptionClass = "noun";
|
descriptionClass = "noun";
|
||||||
description = "RGB color in hex format";
|
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;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue