Validates comma-separated string or array inputs and normalizes them to typed arrays.
Accepts:
Designed for shared contracts where the server receives comma-separated query strings and the client passes typed arrays.
Composable with .optional(), .nullable(), etc. at the call site:
.optional()
.nullable()
z.object({ workerTypes: commaSeparatedArray(z.string().min(1)).optional(), dates: commaSeparatedArray(dateTimeSchema()).optional(),}); Copy
z.object({ workerTypes: commaSeparatedArray(z.string().min(1)).optional(), dates: commaSeparatedArray(dateTimeSchema()).optional(),});
z.input → string | T[] (where T is z.input of the item schema) z.output → T[] (where T is z.output of the item schema)
Validates comma-separated string or array inputs and normalizes them to typed arrays.
Accepts:
Designed for shared contracts where the server receives comma-separated query strings and the client passes typed arrays.
Composable with
.optional(),.nullable(), etc. at the call site:z.input → string | T[] (where T is z.input of the item schema) z.output → T[] (where T is z.output of the item schema)