| 274 | // ==================== COMPOSITE TYPE PROCESSORS ==================== |
| 275 | |
| 276 | export const arrayProcessor: Processor<schemas.$ZodArray> = (schema, ctx, _json, params) => { |
| 277 | const json = _json as JSONSchema.ArraySchema; |
| 278 | const def = schema._zod.def as schemas.$ZodArrayDef; |
| 279 | const { minimum, maximum } = schema._zod.bag; |
| 280 | if (typeof minimum === "number") json.minItems = minimum; |
| 281 | if (typeof maximum === "number") json.maxItems = maximum; |
| 282 | |
| 283 | json.type = "array"; |
| 284 | json.items = process(def.element, ctx as any, { |
| 285 | ...params, |
| 286 | path: [...params.path, "items"], |
| 287 | }); |
| 288 | }; |
| 289 | |
| 290 | export const objectProcessor: Processor<schemas.$ZodObject> = (schema, ctx, _json, params) => { |
| 291 | const json = _json as JSONSchema.ObjectSchema; |