* Unwrap Zod wrapper types to get the underlying type.
(t: z.ZodType)
| 67 | * Unwrap Zod wrapper types to get the underlying type. |
| 68 | */ |
| 69 | function unwrap(t: z.ZodType): z.ZodType { |
| 70 | const typeName = getZodTypeName(t); |
| 71 | |
| 72 | // Wrapper types that should be unwrapped |
| 73 | const wrapperTypes = [ |
| 74 | 'optional', |
| 75 | 'nullable', |
| 76 | 'default', |
| 77 | 'transform', |
| 78 | 'pipe', |
| 79 | 'prefault', |
| 80 | 'catch', |
| 81 | 'readonly', |
| 82 | ]; |
| 83 | |
| 84 | if (typeName && wrapperTypes.includes(typeName)) { |
| 85 | const inner = getInnerType(t); |
| 86 | if (inner) return unwrap(inner); |
| 87 | } |
| 88 | |
| 89 | return t; |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * Check if a Zod type is optional/nullable/has default. |
no test coverage detected