|
1 |
| -import { z } from "zod/v4-mini"; |
| 1 | +import { z } from "zod/v4"; |
2 | 2 |
|
3 |
| -// const zval = z |
4 |
| -// .string() |
5 |
| -// .check((ctx) => { |
6 |
| -// console.log(`Checking value: ${ctx.value}`); |
7 |
| -// if (ctx.value !== "expected") { |
8 |
| -// ctx.issues.push({ |
9 |
| -// message: `Value must be 'expected', got '${ctx.value}'`, |
10 |
| -// input: ctx.value, |
11 |
| -// code: "custom", |
12 |
| -// fatal: true, |
13 |
| -// // continue: false, |
14 |
| -// // fa |
15 |
| -// }); |
16 |
| -// } |
17 |
| -// }) |
18 |
| -// .transform((val) => { |
19 |
| -// console.log(`Transforming value: ${val}`); |
20 |
| -// return val.toUpperCase(); |
21 |
| -// }) |
22 |
| -// .prefault("unexpected"); |
23 |
| - |
24 |
| -// const obj = z.object({ |
25 |
| -// test: zval, |
26 |
| -// }); |
27 |
| - |
28 |
| -// console.log("NESTED"); |
29 |
| -// console.log(obj.safeParse({ test: undefined }, { jitless: true })); // check runs, doesn't throw, transform not run |
30 |
| - |
31 |
| -// console.log("\n\nTOP LEVEL"); |
32 |
| -// console.log(zval.safeParse(undefined, { jitless: true })); // check runs, throws |
33 |
| - |
34 |
| -const Shared = z.object({ |
35 |
| - label: z.string(), |
36 |
| - description: z.string(), |
| 3 | +console.dir(z.toJSONSchema(z.string().startsWith("hello").includes("cruel").endsWith("world").regex(/stuff/)), { |
| 4 | + depth: null, |
37 | 5 | });
|
38 |
| - |
39 |
| -const DU = z.discriminatedUnion("type", [ |
40 |
| - z.extend(Shared, { type: z.literal("a"), value: z.number() }), |
41 |
| - z.extend(Shared, { type: z.literal("b"), value: z.string() }), |
42 |
| - z.extend(Shared, { type: z.literal("c"), value: z.boolean() }), |
43 |
| -]); |
0 commit comments