{"id":"4e6d52932af3ce4b","repo":"colinhacks/zod","slug":"you-must-pass-an-array-of-schemas-to-z-tuple","errorCode":null,"errorMessage":"You must pass an array of schemas to z.tuple([ ... ])","messagePattern":"You must pass an array of schemas to z\\.tuple\\(\\[ \\.\\.\\. \\]\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/zod/src/v3/types.ts","lineNumber":3468,"sourceCode":"  }\n\n  get items() {\n    return this._def.items;\n  }\n\n  rest<RestSchema extends ZodTypeAny>(rest: RestSchema): ZodTuple<T, RestSchema> {\n    return new ZodTuple({\n      ...this._def,\n      rest,\n    });\n  }\n\n  static create = <Items extends [ZodTypeAny, ...ZodTypeAny[]] | []>(\n    schemas: Items,\n    params?: RawCreateParams\n  ): ZodTuple<Items, null> => {\n    if (!Array.isArray(schemas)) {\n      throw new Error(\"You must pass an array of schemas to z.tuple([ ... ])\");\n    }\n    return new ZodTuple({\n      items: schemas,\n      typeName: ZodFirstPartyTypeKind.ZodTuple,\n      rest: null,\n      ...processCreateParams(params),\n    });\n  };\n}\n\n/////////////////////////////////////////\n/////////////////////////////////////////\n//////////                     //////////\n//////////      ZodRecord      //////////\n//////////                     //////////\n/////////////////////////////////////////\n/////////////////////////////////////////\nexport interface ZodRecordDef<Key extends KeySchema = ZodString, Value extends ZodTypeAny = ZodTypeAny>","sourceCodeStart":3450,"sourceCodeEnd":3486,"githubUrl":"https://github.com/colinhacks/zod/blob/912f0f51b0ced654d0069741e7160834dca742ee/packages/zod/src/v3/types.ts#L3450-L3486","documentation":"Thrown by z.tuple.create when its first argument is not an array. The v3 signature overloads to require an array of schemas, so passing a single schema, a rest spread, or an object fails the runtime Array.isArray guard before construction.","triggerScenarios":"Calling `z.tuple(z.string())`, `z.tuple(...schemas)`, or `z.tuple({0: z.string()})` instead of `z.tuple([z.string()])`. Also triggered by tooling that strips array brackets when generating code.","commonSituations":"Code-generation bugs; refactoring a single-element tuple and dropping the brackets; confusing z.tuple (positional, array) with z.array (homogeneous) or z.tuple with z.object.","solutions":["Wrap schemas in an array literal: `z.tuple([a, b])`.","Use z.array for a homogeneous list of one schema type.","If spreading, wrap: `z.tuple([...rest])`."],"exampleFix":"// before\nz.tuple(z.string(), z.number());\n\n// after\nz.tuple([z.string(), z.number()]);","handlingStrategy":"type-guard","validationCode":"function assertTupleSchemas(schemas: unknown) {\n  if (!Array.isArray(schemas)) {\n    throw new TypeError(\"Expected an array of Zod schemas\");\n  }\n}","typeGuard":"function isZodSchemaArray(x: unknown): x is z.ZodTypeAny[] {\n  return Array.isArray(x) && x.every((s) => s instanceof z.ZodType);\n}","tryCatchPattern":null,"preventionTips":["Always use the array literal form `z.tuple([...])`.","Enable @typescript-eslint/no-confusing-arguments to catch the multi-arg misuse.","For homogeneous lists use z.array instead."],"tags":["tuple","schema-construction","v3"],"analyzedSha":"912f0f51b0ced654d0069741e7160834dca742ee","analyzedAt":"2026-08-03T17:41:55.908Z","schemaVersion":2}