zod/lazy_ref
Internal back-reference emitted inside recursive lazy schemas to keep the AST finite
const app = mvfm(prelude, zod);
const prog = app({ value: "object" }, ($) => {
const Category = $.zod.object({
name: $.zod.string(),
subcategories: $.zod.lazy(() => $.zod.array(Category)),
});
return Category.parse($.input.value);
});
await fold(
defaults(app),
injectInput(prog, {
value: {
name: "Root",
subcategories: [{ name: "Leaf", subcategories: [] }],
},
})
); Ctrl+Enter