feat: try rework
This commit is contained in:
parent
1ddbd3b8b6
commit
ecf10628c3
51 changed files with 1941 additions and 445 deletions
34
validation/service/common.nix
Normal file
34
validation/service/common.nix
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue