Const
Zod schema for parsing comma/newline-separated string to array of strings. Supports both comma-separated and newline-separated values. Use .optional() for optional fields.
.optional()
const schema = z.object({ tags: zStringArray });schema.parse({ tags: "a,b,c" }); // { tags: ["a", "b", "c"] }schema.parse({ tags: "a\nb\nc" }); // { tags: ["a", "b", "c"] } Copy
const schema = z.object({ tags: zStringArray });schema.parse({ tags: "a,b,c" }); // { tags: ["a", "b", "c"] }schema.parse({ tags: "a\nb\nc" }); // { tags: ["a", "b", "c"] }
Zod schema for parsing comma/newline-separated string to array of strings. Supports both comma-separated and newline-separated values. Use
.optional()for optional fields.