zod
Version:
TypeScript-first schema declaration and validation library with static type inference
15 lines (11 loc) • 401 B
text/typescript
import { expect, test } from "vitest";
import * as z from "zod/mini";
test("z.function", () => {
expect(true).toEqual(true);
});
test("implement exposes the function schema at runtime", () => {
const schema = z.function({ input: [z.string()], output: z.number() });
const fn = schema.implement((s) => s.length);
expect((fn as any)._zod).toBe(schema._zod);
expect(fn("asdf")).toBe(4);
});