Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove createParams cascade from .array() #3530

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions deno/lib/__tests__/description.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,11 @@ test("description should carry over to chained schemas", () => {
description
);
});

test("description should not carry over to chained array schema", () => {
const schema = z.string().describe(description)

expect(schema.description).toEqual(description);
expect(schema.array().description).toEqual(undefined);
expect(z.array(schema).description).toEqual(undefined);
})
2 changes: 1 addition & 1 deletion deno/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ export abstract class ZodType<
return this.nullable().optional();
}
array(): ZodArray<this> {
return ZodArray.create(this, this._def);
return ZodArray.create(this);
}
promise(): ZodPromise<this> {
return ZodPromise.create(this, this._def);
Expand Down
8 changes: 8 additions & 0 deletions src/__tests__/description.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ test("description should carry over to chained schemas", () => {
description
);
});

test("description should not carry over to chained array schema", () => {
const schema = z.string().describe(description)

expect(schema.description).toEqual(description);
expect(schema.array().description).toEqual(undefined);
expect(z.array(schema).description).toEqual(undefined);
})
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ export abstract class ZodType<
return this.nullable().optional();
}
array(): ZodArray<this> {
return ZodArray.create(this, this._def);
return ZodArray.create(this);
}
promise(): ZodPromise<this> {
return ZodPromise.create(this, this._def);
Expand Down