* Check if a Zod type is optional/nullable/has default.
(t: z.ZodType)
| 93 | * Check if a Zod type is optional/nullable/has default. |
| 94 | */ |
| 95 | function isOptional(t: z.ZodType): boolean { |
| 96 | const typeName = getZodTypeName(t); |
| 97 | |
| 98 | if ( |
| 99 | typeName === 'optional' || |
| 100 | typeName === 'nullable' || |
| 101 | typeName === 'default' || |
| 102 | typeName === 'prefault' |
| 103 | ) { |
| 104 | return true; |
| 105 | } |
| 106 | |
| 107 | // Check wrapper types recursively |
| 108 | const inner = getInnerType(t); |
| 109 | if (inner) return isOptional(inner); |
| 110 | |
| 111 | return false; |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Get description from a Zod type if available. |
no test coverage detected