diff --git a/coverage.svg b/coverage.svg index ffd4d7cec..f9317e682 100644 --- a/coverage.svg +++ b/coverage.svg @@ -1 +1 @@ -Coverage: 89.26%Coverage89.26% \ No newline at end of file +Coverage: 89.16%Coverage89.16% \ No newline at end of file diff --git a/deno/lib/__tests__/error.test.ts b/deno/lib/__tests__/error.test.ts index 83a95ee16..1758bcaa3 100644 --- a/deno/lib/__tests__/error.test.ts +++ b/deno/lib/__tests__/error.test.ts @@ -367,3 +367,19 @@ test("invalid and required and errorMap", () => { }); }).toThrow(); }); + +test("dont short circuit on continuable errors", () => { + const user = z + .object({ + password: z.string().min(6), + confirm: z.string(), + }) + .refine((data) => data.password === data.confirm, { + message: "Passwords don't match", + path: ["confirm"], + }); + const result = user.safeParse({ password: "asdf", confirm: "qwer" }); + if (!result.success) { + expect(result.error.issues.length).toEqual(2); + } +}); diff --git a/package.json b/package.json index 709b16757..d9d2ff684 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zod", - "version": "3.9.0", + "version": "3.9.1", "description": "TypeScript-first schema declaration and validation library with static type inference", "main": "./lib/index.js", "types": "./lib/index.d.ts", diff --git a/src/__tests__/error.test.ts b/src/__tests__/error.test.ts index ea9159eab..0c8101d5a 100644 --- a/src/__tests__/error.test.ts +++ b/src/__tests__/error.test.ts @@ -366,3 +366,19 @@ test("invalid and required and errorMap", () => { }); }).toThrow(); }); + +test("dont short circuit on continuable errors", () => { + const user = z + .object({ + password: z.string().min(6), + confirm: z.string(), + }) + .refine((data) => data.password === data.confirm, { + message: "Passwords don't match", + path: ["confirm"], + }); + const result = user.safeParse({ password: "asdf", confirm: "qwer" }); + if (!result.success) { + expect(result.error.issues.length).toEqual(2); + } +});