{"id":"b3e2b6de5d31a7cc","repo":"colinhacks/zod","slug":"dependentschemas-and-dependentrequired-are-not-sup","errorCode":null,"errorMessage":"dependentSchemas and dependentRequired are not supported","messagePattern":"dependentSchemas and dependentRequired are not supported","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/zod/src/v4/classic/from-json-schema.ts","lineNumber":165,"sourceCode":"  // Handle unsupported features\n  if (schema.not !== undefined) {\n    // Special case: { not: {} } represents never\n    if (typeof schema.not === \"object\" && Object.keys(schema.not).length === 0) {\n      return z.never();\n    }\n    throw new Error(\"not is not supported in Zod (except { not: {} } for never)\");\n  }\n  if (schema.unevaluatedItems !== undefined) {\n    throw new Error(\"unevaluatedItems is not supported\");\n  }\n  if (schema.unevaluatedProperties !== undefined) {\n    throw new Error(\"unevaluatedProperties is not supported\");\n  }\n  if (schema.if !== undefined || schema.then !== undefined || schema.else !== undefined) {\n    throw new Error(\"Conditional schemas (if/then/else) are not supported\");\n  }\n  if (schema.dependentSchemas !== undefined || schema.dependentRequired !== undefined) {\n    throw new Error(\"dependentSchemas and dependentRequired are not supported\");\n  }\n\n  // Handle $ref\n  if (schema.$ref) {\n    const refPath = schema.$ref;\n    if (ctx.refs.has(refPath)) {\n      return ctx.refs.get(refPath)!;\n    }\n\n    if (ctx.processing.has(refPath)) {\n      // Circular reference - use lazy\n      return z.lazy(() => {\n        if (!ctx.refs.has(refPath)) {\n          throw new Error(`Circular reference not resolved: ${refPath}`);\n        }\n        return ctx.refs.get(refPath)!;\n      });\n    }","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/colinhacks/zod/blob/912f0f51b0ced654d0069741e7160834dca742ee/packages/zod/src/v4/classic/from-json-schema.ts#L147-L183","documentation":"Thrown by convertBaseSchema when the input contains `dependentSchemas` or `dependentRequired`. These conditional-presence keywords have no static Zod representation, so the converter rejects them outright.","triggerScenarios":"Schemas with `dependentRequired: { creditCard: ['billingAddress'] }` or `dependentSchemas: { kind: { ... } }`.","commonSituations":"Form-validation schemas with inter-field dependencies; OpenAPI extensions; importing schemas written for Ajv.","solutions":["Replace the dependency with a `.refine()` / `.superRefine()` that enforces the conditional requirement at runtime.","Model as a discriminated union when the dependency is driven by a tag field.","Strip the keyword from the input and enforce the rule in application code."],"exampleFix":"// before\n{ \"type\": \"object\", \"dependentRequired\": { \"creditCard\": [\"billingAddress\"] } }\n\n// after\nz.object({\n  creditCard: z.string().optional(),\n  billingAddress: z.string().optional(),\n}).refine(\n  (v) => !v.creditCard || v.billingAddress,\n  { message: \"billingAddress required when creditCard is set\", path: [\"billingAddress\"] }\n);","handlingStrategy":"fallback","validationCode":"function hasDependent(schema: any): boolean {\n  return schema?.dependentSchemas !== undefined || schema?.dependentRequired !== undefined;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Model property dependencies in a refine on the converted schema.","Use discriminated unions when dependencies pivot on a tag field.","Strip these keywords before conversion and enforce in code."],"tags":["json-schema","dependent","unsupported","v4","from-json-schema"],"analyzedSha":"912f0f51b0ced654d0069741e7160834dca742ee","analyzedAt":"2026-08-03T17:41:55.908Z","schemaVersion":2}