10 lines
358 B
TypeScript
10 lines
358 B
TypeScript
import { z } from "zod";
|
|
|
|
// Helper schema for JSON fields
|
|
type Literal = boolean | number | string;
|
|
type Json = Literal | { [key: string]: Json } | Json[];
|
|
const literalSchema = z.union([z.string(), z.number(), z.boolean()]);
|
|
export const jsonSchema: z.ZodSchema<Json> = z.lazy(() =>
|
|
z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)])
|
|
);
|