Skip to content

Commit 89656da

Browse files
committed
Added test for failing optional async refine.
1 parent 9629fcf commit 89656da

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/tests/superValidate.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,18 @@ describe('Zod', () => {
489489
expect(() => zod(NumberSchema)).toThrowError(SchemaError);
490490
});
491491

492+
it('cannot handle promises in optional refine', async () => {
493+
const schema = z.object({
494+
name: z.string().min(1),
495+
email: z
496+
.string()
497+
.optional()
498+
.refine(async () => Promise.resolve(true))
499+
});
500+
501+
expect(() => zod(schema)).toThrow(Error);
502+
});
503+
492504
schemaTest(zod(schema));
493505
});
494506

0 commit comments

Comments
 (0)