Basically, the description for a type was getting unexpectedly duplicated when using .array(). For example:
z.string().describe("a description").array()
// ^ was functionally the same as v
z.array(
z.string().describe("a description")
).describe("a description")
The issue was not present for z.array()
z.array(z.string().describe("a description")) // works as expected
This unexpected behavior was introduced in a fix trying to ensure that something like z.string().describe("a description").optional() persisted the description after being wrapped by ZodOptional.
While this behavior makes sense for types like ZodOptional or ZodNullable, ZodArray is a completely separate type.
Other types that do this cascading createParams:
optional
nullable
promise
or
and
transform
default
brand
catch
I think the logic makes sense for all of these (maybe or and and are also exceptions? not sure)
See this issue for more context.
Basically, the description for a type was getting unexpectedly duplicated when using
.array()
. For example:The issue was not present for
z.array()
This unexpected behavior was introduced in a fix trying to ensure that something like
z.string().describe("a description").optional()
persisted the description after being wrapped byZodOptional
.While this behavior makes sense for types like
ZodOptional
orZodNullable
,ZodArray
is a completely separate type.Other types that do this cascading
createParams
:optional
nullable
promise
or
and
transform
default
brand
catch
I think the logic makes sense for all of these (maybe
or
andand
are also exceptions? not sure)Added a test for this as well :)