( schema: z.ZodTypeAny )
| 258 | } |
| 259 | |
| 260 | function unwrapToObject( |
| 261 | schema: z.ZodTypeAny |
| 262 | ): z.ZodObject<any, any> | null { |
| 263 | let current = schema; |
| 264 | |
| 265 | while (true) { |
| 266 | const def = (current as any)._def as ZodDef | undefined; |
| 267 | const typeName = getDefType(def); |
| 268 | |
| 269 | if (!def) { |
| 270 | return null; |
| 271 | } |
| 272 | |
| 273 | if (typeName === 'object') { |
| 274 | return current as z.ZodObject<any, any>; |
| 275 | } |
| 276 | |
| 277 | if (typeName === 'optional' || typeName === 'nullable' || typeName === 'default') { |
| 278 | current = def.innerType; |
| 279 | continue; |
| 280 | } |
| 281 | |
| 282 | if (typeName === 'effects') { |
| 283 | current = def.schema; |
| 284 | continue; |
| 285 | } |
| 286 | |
| 287 | if (typeName === 'pipe') { |
| 288 | current = def.out ?? def.schema ?? def.innerType ?? def.in ?? current; |
| 289 | continue; |
| 290 | } |
| 291 | |
| 292 | return null; |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | /** |
| 297 | * Check if schema is z.any() or z.unknown() |
no test coverage detected