We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6b6face commit f340b09Copy full SHA for f340b09
packages/convex-helpers/server/zod.test.ts
@@ -1077,3 +1077,13 @@ test("convexToZod union of one literal", () => {
1077
expect(zodUnion.parse("hello")).toBe("hello");
1078
expect(() => zodUnion.parse("world")).toThrow();
1079
});
1080
+
1081
+test("convexToZod object with union of one literal", () => {
1082
+ const unionValidator = v.object({
1083
+ member: v.union(v.literal("hello")),
1084
+ });
1085
+ const zodUnion = convexToZod(unionValidator);
1086
+ expect(zodUnion.constructor.name).toBe("ZodObject");
1087
+ expect(zodUnion.parse({ member: "hello" })).toEqual({ member: "hello" });
1088
+ expect(() => zodUnion.parse({ member: "world" })).toThrow();
1089
+});
0 commit comments