lib.types.lowerBoundedInt: init

This commit is contained in:
tv 2023-02-03 18:10:50 +01:00
parent 7b8f46c398
commit 3b04273d5c

View File

@ -293,15 +293,21 @@ rec {
merge = mergeOneOption; merge = mergeOneOption;
}; };
lowerBoundedInt = min: mkOptionType {
name = "lower bounded integer";
check = x: isInt x && min <= x;
merge = mergeOneOption;
};
positive = mkOptionType { positive = mkOptionType {
inherit (lowerBoundedInt 1) check;
name = "positive integer"; name = "positive integer";
check = x: isInt x && x > 0;
merge = mergeOneOption; merge = mergeOneOption;
}; };
uint = mkOptionType { uint = mkOptionType {
inherit (lowerBoundedInt 0) check;
name = "unsigned integer"; name = "unsigned integer";
check = x: isInt x && x >= 0;
merge = mergeOneOption; merge = mergeOneOption;
}; };