Define a reference object for types and defaults
mainTo use untyped, you must first define a reference object. This object describes the structure of your data, including types, default values, and optional $resolve normalizer methods.
Special keys available within the object:
$resolve: A function used to normalize or transform a value.$default: The default value to use.$schema: Metadata for the field (e.g., atitle).
const defaultPlanet = {
name: "earth",
specs: {
gravity: {
$resolve: (val) => Number.parseFloat(val),
$default: "9.8",
},
moons: {
$resolve: (val = ["moon"]) => [val].flat(),
$schema: {
title: "planet moons",
},
},
},
};