UNPKG

json-schema-to-zod

Version:

Converts JSON schema objects or files into Zod schemas

8 lines (7 loc) 305 B
import { parseSchema } from "./parseSchema.js"; export const parseNot = (schema, refs) => { return `z.any().refine((value) => !${parseSchema(schema.not, { ...refs, path: [...refs.path, "not"], })}.safeParse(value).success, "Invalid input: Should NOT be valid against schema")`; };