diff options
author | Profpatsch <mail@profpatsch.de> | 2018-08-06 01:36:09 +0200 |
---|---|---|
committer | Profpatsch <mail@profpatsch.de> | 2018-09-06 18:14:27 +0200 |
commit | 3e45b61a9920466a8ea06b8ad9350d56ade435bc (patch) | |
tree | 1913cb4951336a37ed9921a538db5a50c7b62008 /lib/types.nix | |
parent | 320cdecd1697020cb367adc1f8408dbf689ca254 (diff) |
lib/trivial: add a few examples of usage of assertMsg/assertOneOf
Diffstat (limited to 'lib/types.nix')
-rw-r--r-- | lib/types.nix | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/types.nix b/lib/types.nix index 4d6ac51c8988..441af98cb9b6 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -119,7 +119,9 @@ rec { let betweenDesc = lowest: highest: "${toString lowest} and ${toString highest} (both inclusive)"; - between = lowest: highest: assert lowest <= highest; + between = lowest: highest: + assert lib.assertMsg (lowest <= highest) + "ints.between: lowest must be smaller than highest"; addCheck int (x: x >= lowest && x <= highest) // { name = "intBetween"; description = "integer between ${betweenDesc lowest highest}"; @@ -439,7 +441,9 @@ rec { # Either value of type `finalType` or `coercedType`, the latter is # converted to `finalType` using `coerceFunc`. coercedTo = coercedType: coerceFunc: finalType: - assert coercedType.getSubModules == null; + assert assertMsg (coercedType.getSubModules == null) + "coercedTo: coercedType must not have submodules (it’s a ${ + coercedType.description})"; mkOptionType rec { name = "coercedTo"; description = "${finalType.description} or ${coercedType.description} convertible to it"; |