(a: z.ZodTypeAny, bad: any)
| 4 | import * as z from "zod/v3"; |
| 5 | |
| 6 | function checkErrors(a: z.ZodTypeAny, bad: any) { |
| 7 | let expected: any; |
| 8 | try { |
| 9 | a.parse(bad); |
| 10 | } catch (error) { |
| 11 | expected = (error as z.ZodError).formErrors; |
| 12 | } |
| 13 | try { |
| 14 | a.nullable().parse(bad); |
| 15 | } catch (error) { |
| 16 | expect((error as z.ZodError).formErrors).toEqual(expected); |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | test("Should have error messages appropriate for the underlying type", () => { |
| 21 | checkErrors(z.string().min(2), 1); |
no test coverage detected