Skip to main content
Module

x/valita/mod.ts>lazy

A typesafe validation & parsing library for TypeScript.
Go to Latest
function lazy
import { lazy } from "https://deno.land/x/valita@v0.3.6/mod.ts";

Create a validator that can reference itself, directly or indirectly.

In most cases an explicit type annotation is also needed, as TypeScript cannot infer return types of recursive functions.

Examples

Example 1

import * as v from "@badrap/valita";

type T = string | T[];
const type: v.Type<T> = v.lazy(() => v.union(v.string(), v.array(type)));

Parameters

definer: () => Type<T>