34 lines
No EOL
789 B
Nix
34 lines
No EOL
789 B
Nix
let
|
|
ensureAttrset = context: value:
|
|
if builtins.isAttrs value then
|
|
value
|
|
else
|
|
throw "${context} must be an attrset.";
|
|
|
|
ensureString = context: value:
|
|
if builtins.isString value then
|
|
value
|
|
else
|
|
throw "${context} must be a string.";
|
|
|
|
ensureNonEmptyString = context: value:
|
|
if builtins.isString value && value != "" then
|
|
value
|
|
else
|
|
throw "${context} must be a non-empty string.";
|
|
|
|
ensureInt = context: value:
|
|
if builtins.isInt value then
|
|
value
|
|
else
|
|
throw "${context} must be an int.";
|
|
|
|
ensureList = context: value:
|
|
if builtins.isList value then
|
|
value
|
|
else
|
|
throw "${context} must be a list.";
|
|
in
|
|
rec {
|
|
inherit ensureAttrset ensureString ensureNonEmptyString ensureInt ensureList;
|
|
} |