From c53d874277c0eaf88ec71bab9658425535a2252a Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Sat, 8 Jul 2017 14:10:22 +0200 Subject: lib/types: add intBetween An int type that checks the value range. --- lib/types.nix | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib') diff --git a/lib/types.nix b/lib/types.nix index db3bd3815238..e921f7f6d9fc 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -114,6 +114,12 @@ rec { merge = mergeOneOption; }; + intBetween = min: max: + addCheck types.int (x: x >= min && x <= max) // { + name = "intBetween"; + description = "integer between ${toString min} and ${toString max} (both inclusively)"; + }; + str = mkOptionType { name = "str"; description = "string"; -- cgit 1.4.1