This commit is contained in:
2025-05-21 08:47:21 +03:00
parent 079ce23363
commit 3cd4b8861e
8 changed files with 123 additions and 124 deletions

View File

@@ -1,8 +1,7 @@
import { z } from "zod"; import { z } from "zod";
export type TypeToZod<T> = { export type TypeToZod<T> = {
[K in keyof T]: // 1. Handle Arrays (including arrays of objects, optional or required) [K in keyof T]: T[K] extends ReadonlyArray<infer E> | undefined // 1. Handle Arrays (including arrays of objects, optional or required)
T[K] extends ReadonlyArray<infer E> | undefined
? undefined extends T[K] ? undefined extends T[K]
? E extends object ? E extends object
? z.ZodOptional<z.ZodArray<z.ZodObject<TypeToZod<E>>>> ? z.ZodOptional<z.ZodArray<z.ZodObject<TypeToZod<E>>>>