pi/validation/service/common.nix
Katharina Heidenreich ecf10628c3 feat: try rework
2026-04-04 16:34:02 +02:00

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;
}