serializableValueWith
lib.types.serializableValueWith
Docs pulled from | This Revision | about 1 hour ago
Creates a value type suitable for serialization formats.
Parameters:
- typeName: String describing the format (e.g. "JSON", "YAML", "XML")
- nullable: Whether the structured value type allows
nullvalues.
Returns a type suitable for structured data formats that supports:
- Basic types: boolean, integer, float, string, path
- Complex types: attribute sets and lists
Noogle detected
Implementation
The following is the current implementation of this function.
serializableValueWith =
{
typeName,
nullable ? true,
}:
let
baseType = oneOf [
bool
int
float
str
path
(attrsOf valueType)
(listOf valueType)
];
valueType = (if nullable then nullOr baseType else baseType) // {
description = "${typeName} value";
};
in
valueType;