.
This commit is contained in:
@@ -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>>>>
|
||||||
|
|||||||
Reference in New Issue
Block a user