agent-relay 6.0.3 → 6.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1395 -674
- package/node_modules/@relaycast/sdk/node_modules/zod/README.md +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/locales/package.json +2 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/mini/package.json +2 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/package.json +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v3/tests/all-errors.test.ts +3 -3
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v3/tests/object.test.ts +5 -5
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v3/tests/partials.test.ts +3 -3
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/errors.ts +2 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/external.ts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/from-json-schema.ts +39 -23
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/parse.ts +6 -6
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/schemas.ts +389 -148
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/catch.test.ts +4 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/codec.test.ts +142 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/continuability.test.ts +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/datetime.test.ts +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/default.test.ts +44 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +197 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +31 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +214 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +161 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/function.test.ts +6 -6
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/global-config.test.ts +39 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/index.test.ts +2 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +46 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/locales_ka.test.ts +29 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/locales_ro.test.ts +24 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/number.test.ts +55 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/object.test.ts +83 -6
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/optional.test.ts +114 -4
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/partial.test.ts +28 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/prefault.test.ts +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/record.test.ts +85 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +49 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/refine.test.ts +63 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/string.test.ts +50 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +4 -4
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +128 -14
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/transform.test.ts +17 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/tuple.test.ts +315 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/union.test.ts +54 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/api.ts +25 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/checks.ts +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/core.ts +17 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/errors.ts +31 -24
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/json-schema-processors.ts +15 -17
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/parse.ts +7 -7
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/regexes.ts +8 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/schemas.ts +218 -66
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/tests/locales/el.test.ts +215 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +72 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/tests/locales/hr.test.ts +163 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/tests/locales/uz.test.ts +22 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +58 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/to-json-schema.ts +9 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/util.ts +52 -35
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/versions.ts +2 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/el.ts +121 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/en.ts +4 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/fr.ts +24 -8
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/hr.ts +131 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/index.ts +3 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/it.ts +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/ka.ts +8 -8
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/ro.ts +129 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/uz.ts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/mini/external.ts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/mini/schemas.ts +55 -24
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/mini/tests/codec.test.ts +19 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/mini/tests/index.test.ts +27 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/mini/tests/object.test.ts +9 -9
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +51 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/mini/tests/string.test.ts +5 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v3/package.json +2 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/errors.js +2 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/external.d.cts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/external.d.ts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/from-json-schema.cjs +31 -16
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/from-json-schema.js +31 -16
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/package.json +2 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/schemas.cjs +346 -117
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/schemas.d.cts +34 -12
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/schemas.d.ts +34 -12
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/schemas.js +345 -117
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/api.cjs +7 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/api.d.cts +20 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/api.d.ts +20 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/api.js +7 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/checks.d.cts +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/checks.d.ts +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/core.cjs +3 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/core.js +4 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/errors.cjs +26 -23
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/errors.d.cts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/errors.d.ts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/errors.js +26 -23
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/json-schema-processors.cjs +14 -19
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/json-schema-processors.js +14 -19
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/package.json +2 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/parse.cjs +7 -7
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/parse.js +7 -7
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/regexes.cjs +9 -3
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/regexes.d.cts +6 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/regexes.d.ts +6 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/regexes.js +7 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/schemas.cjs +196 -59
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/schemas.d.cts +21 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/schemas.d.ts +21 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/schemas.js +196 -59
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/to-json-schema.cjs +10 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/to-json-schema.js +10 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/util.cjs +54 -30
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/util.d.cts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/util.d.ts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/util.js +55 -32
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/versions.cjs +2 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/versions.d.cts +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/versions.d.ts +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/versions.js +2 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/el.cjs +136 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/el.d.cts +5 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/el.d.ts +4 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/el.js +109 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/en.cjs +4 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/en.js +4 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/fr.cjs +24 -7
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/fr.js +24 -7
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/hr.cjs +149 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/hr.d.cts +5 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/hr.d.ts +4 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/hr.js +122 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/index.cjs +8 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/index.d.cts +3 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/index.d.ts +3 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/index.js +3 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/it.cjs +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/it.js +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/ka.cjs +8 -8
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/ka.js +8 -8
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/package.json +2 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/ro.cjs +146 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/ro.d.cts +5 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/ro.d.ts +4 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/ro.js +119 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/uz.cjs +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/uz.js +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/mini/external.d.cts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/mini/external.d.ts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/mini/package.json +2 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/mini/schemas.cjs +41 -4
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/mini/schemas.d.cts +27 -9
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/mini/schemas.d.ts +27 -9
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/mini/schemas.js +40 -4
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/package.json +2 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4-mini/package.json +2 -1
- package/package.json +9 -9
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { expect, test } from "vitest";
|
|
2
|
+
import { z } from "../../../../index.js";
|
|
3
|
+
import el from "../../../locales/el.js";
|
|
4
|
+
|
|
5
|
+
test("Greek locale - too_small errors", () => {
|
|
6
|
+
z.config(el());
|
|
7
|
+
|
|
8
|
+
// Test string type translation
|
|
9
|
+
const stringSchema = z.string().min(5);
|
|
10
|
+
const stringResult = stringSchema.safeParse("abc");
|
|
11
|
+
expect(stringResult.success).toBe(false);
|
|
12
|
+
if (!stringResult.success) {
|
|
13
|
+
expect(stringResult.error.issues[0].message).toBe("Πολύ μικρό: αναμενόταν string να έχει >=5 χαρακτήρες");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Test number type translation
|
|
17
|
+
const numberSchema = z.number().min(10);
|
|
18
|
+
const numberResult = numberSchema.safeParse(5);
|
|
19
|
+
expect(numberResult.success).toBe(false);
|
|
20
|
+
if (!numberResult.success) {
|
|
21
|
+
expect(numberResult.error.issues[0].message).toBe("Πολύ μικρό: αναμενόταν number να είναι >=10");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Test array type translation
|
|
25
|
+
const arraySchema = z.array(z.string()).min(3);
|
|
26
|
+
const arrayResult = arraySchema.safeParse(["a", "b"]);
|
|
27
|
+
expect(arrayResult.success).toBe(false);
|
|
28
|
+
if (!arrayResult.success) {
|
|
29
|
+
expect(arrayResult.error.issues[0].message).toBe("Πολύ μικρό: αναμενόταν array να έχει >=3 στοιχεία");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Test set type translation
|
|
33
|
+
const setSchema = z.set(z.string()).min(2);
|
|
34
|
+
const setResult = setSchema.safeParse(new Set(["a"]));
|
|
35
|
+
expect(setResult.success).toBe(false);
|
|
36
|
+
if (!setResult.success) {
|
|
37
|
+
expect(setResult.error.issues[0].message).toBe("Πολύ μικρό: αναμενόταν set να έχει >=2 στοιχεία");
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test("Greek locale - too_big errors", () => {
|
|
42
|
+
z.config(el());
|
|
43
|
+
|
|
44
|
+
// Test string type translation
|
|
45
|
+
const stringSchema = z.string().max(3);
|
|
46
|
+
const stringResult = stringSchema.safeParse("abcde");
|
|
47
|
+
expect(stringResult.success).toBe(false);
|
|
48
|
+
if (!stringResult.success) {
|
|
49
|
+
expect(stringResult.error.issues[0].message).toBe("Πολύ μεγάλο: αναμενόταν string να έχει <=3 χαρακτήρες");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Test number type translation
|
|
53
|
+
const numberSchema = z.number().max(10);
|
|
54
|
+
const numberResult = numberSchema.safeParse(15);
|
|
55
|
+
expect(numberResult.success).toBe(false);
|
|
56
|
+
if (!numberResult.success) {
|
|
57
|
+
expect(numberResult.error.issues[0].message).toBe("Πολύ μεγάλο: αναμενόταν number να είναι <=10");
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Test array type translation
|
|
61
|
+
const arraySchema = z.array(z.string()).max(2);
|
|
62
|
+
const arrayResult = arraySchema.safeParse(["a", "b", "c"]);
|
|
63
|
+
expect(arrayResult.success).toBe(false);
|
|
64
|
+
if (!arrayResult.success) {
|
|
65
|
+
expect(arrayResult.error.issues[0].message).toBe("Πολύ μεγάλο: αναμενόταν array να έχει <=2 στοιχεία");
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test("Greek locale - invalid_type errors", () => {
|
|
70
|
+
z.config(el());
|
|
71
|
+
|
|
72
|
+
// Test string expected, number received
|
|
73
|
+
const stringSchema = z.string();
|
|
74
|
+
const stringResult = stringSchema.safeParse(123);
|
|
75
|
+
expect(stringResult.success).toBe(false);
|
|
76
|
+
if (!stringResult.success) {
|
|
77
|
+
expect(stringResult.error.issues[0].message).toBe("Μη έγκυρη είσοδος: αναμενόταν string, λήφθηκε number");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Test number expected, string received
|
|
81
|
+
const numberSchema = z.number();
|
|
82
|
+
const numberResult = numberSchema.safeParse("abc");
|
|
83
|
+
expect(numberResult.success).toBe(false);
|
|
84
|
+
if (!numberResult.success) {
|
|
85
|
+
expect(numberResult.error.issues[0].message).toBe("Μη έγκυρη είσοδος: αναμενόταν number, λήφθηκε string");
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Test boolean expected, null received
|
|
89
|
+
const booleanSchema = z.boolean();
|
|
90
|
+
const booleanResult = booleanSchema.safeParse(null);
|
|
91
|
+
expect(booleanResult.success).toBe(false);
|
|
92
|
+
if (!booleanResult.success) {
|
|
93
|
+
expect(booleanResult.error.issues[0].message).toBe("Μη έγκυρη είσοδος: αναμενόταν boolean, λήφθηκε null");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Test array expected, object received
|
|
97
|
+
const arraySchema = z.array(z.string());
|
|
98
|
+
const arrayResult = arraySchema.safeParse({});
|
|
99
|
+
expect(arrayResult.success).toBe(false);
|
|
100
|
+
if (!arrayResult.success) {
|
|
101
|
+
expect(arrayResult.error.issues[0].message).toBe("Μη έγκυρη είσοδος: αναμενόταν array, λήφθηκε object");
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test("Greek locale - other error cases", () => {
|
|
106
|
+
z.config(el());
|
|
107
|
+
|
|
108
|
+
// Test invalid_element with map (only "map" | "set" produce invalid_element)
|
|
109
|
+
const mapSchema = z.map(z.bigint(), z.number());
|
|
110
|
+
const mapResult = mapSchema.safeParse(new Map([[BigInt(123), BigInt(123)]]));
|
|
111
|
+
expect(mapResult.success).toBe(false);
|
|
112
|
+
if (!mapResult.success) {
|
|
113
|
+
expect(mapResult.error.issues[0].code).toBe("invalid_element");
|
|
114
|
+
expect(mapResult.error.issues[0].message).toBe("Μη έγκυρη τιμή στο map");
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Test invalid_key with record (only "map" | "record" produce invalid_key)
|
|
118
|
+
const recordSchema = z.record(z.number(), z.string());
|
|
119
|
+
const recordResult = recordSchema.safeParse({ notANumber: "value" });
|
|
120
|
+
expect(recordResult.success).toBe(false);
|
|
121
|
+
if (!recordResult.success) {
|
|
122
|
+
expect(recordResult.error.issues[0].code).toBe("invalid_key");
|
|
123
|
+
expect(recordResult.error.issues[0].message).toBe("Μη έγκυρο κλειδί στο record");
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Test invalid_value with enum
|
|
127
|
+
const enumSchema = z.enum(["a", "b"]);
|
|
128
|
+
const enumResult = enumSchema.safeParse("c");
|
|
129
|
+
expect(enumResult.success).toBe(false);
|
|
130
|
+
if (!enumResult.success) {
|
|
131
|
+
expect(enumResult.error.issues[0].message).toBe('Μη έγκυρη επιλογή: αναμενόταν ένα από "a"|"b"');
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Test not_multiple_of
|
|
135
|
+
const multipleSchema = z.number().multipleOf(3);
|
|
136
|
+
const multipleResult = multipleSchema.safeParse(10);
|
|
137
|
+
expect(multipleResult.success).toBe(false);
|
|
138
|
+
if (!multipleResult.success) {
|
|
139
|
+
expect(multipleResult.error.issues[0].message).toBe("Μη έγκυρος αριθμός: πρέπει να είναι πολλαπλάσιο του 3");
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Test unrecognized_keys (single key)
|
|
143
|
+
const strictSchema = z.object({ a: z.string() }).strict();
|
|
144
|
+
const strictResult = strictSchema.safeParse({ a: "test", b: "extra" });
|
|
145
|
+
expect(strictResult.success).toBe(false);
|
|
146
|
+
if (!strictResult.success) {
|
|
147
|
+
expect(strictResult.error.issues[0].message).toBe('Άγνωστο κλειδί: "b"');
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Test unrecognized_keys (multiple keys)
|
|
151
|
+
const strictMultipleResult = strictSchema.safeParse({
|
|
152
|
+
a: "test",
|
|
153
|
+
b: "extra",
|
|
154
|
+
c: "another",
|
|
155
|
+
});
|
|
156
|
+
expect(strictMultipleResult.success).toBe(false);
|
|
157
|
+
if (!strictMultipleResult.success) {
|
|
158
|
+
expect(strictMultipleResult.error.issues[0].message).toBe('Άγνωστα κλειδιά: "b", "c"');
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Test invalid_union
|
|
162
|
+
const unionSchema = z.union([z.string(), z.number()]);
|
|
163
|
+
const unionResult = unionSchema.safeParse(true);
|
|
164
|
+
expect(unionResult.success).toBe(false);
|
|
165
|
+
if (!unionResult.success) {
|
|
166
|
+
expect(unionResult.error.issues[0].message).toBe("Μη έγκυρη είσοδος");
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Test invalid_format with regex
|
|
170
|
+
const regexSchema = z.string().regex(/^[a-z]+$/);
|
|
171
|
+
const regexResult = regexSchema.safeParse("ABC123");
|
|
172
|
+
expect(regexResult.success).toBe(false);
|
|
173
|
+
if (!regexResult.success) {
|
|
174
|
+
expect(regexResult.error.issues[0].message).toBe(
|
|
175
|
+
"Μη έγκυρη συμβολοσειρά: πρέπει να ταιριάζει με το μοτίβο /^[a-z]+$/"
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Test invalid_format with startsWith
|
|
180
|
+
const startsWithSchema = z.string().startsWith("hello");
|
|
181
|
+
const startsWithResult = startsWithSchema.safeParse("world");
|
|
182
|
+
expect(startsWithResult.success).toBe(false);
|
|
183
|
+
if (!startsWithResult.success) {
|
|
184
|
+
expect(startsWithResult.error.issues[0].message).toBe('Μη έγκυρη συμβολοσειρά: πρέπει να ξεκινά με "hello"');
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Test invalid_format with endsWith
|
|
188
|
+
const endsWithSchema = z.string().endsWith("world");
|
|
189
|
+
const endsWithResult = endsWithSchema.safeParse("hello");
|
|
190
|
+
expect(endsWithResult.success).toBe(false);
|
|
191
|
+
if (!endsWithResult.success) {
|
|
192
|
+
expect(endsWithResult.error.issues[0].message).toBe('Μη έγκυρη συμβολοσειρά: πρέπει να τελειώνει με "world"');
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Test invalid_format with includes
|
|
196
|
+
const includesSchema = z.string().includes("test");
|
|
197
|
+
const includesResult = includesSchema.safeParse("hello");
|
|
198
|
+
expect(includesResult.success).toBe(false);
|
|
199
|
+
if (!includesResult.success) {
|
|
200
|
+
expect(includesResult.error.issues[0].message).toBe('Μη έγκυρη συμβολοσειρά: πρέπει να περιέχει "test"');
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
test("Greek locale - invalid_type with instanceof (class-name expected)", () => {
|
|
205
|
+
z.config(el());
|
|
206
|
+
|
|
207
|
+
// When `expected` starts with a capital letter, render an `instanceof` message,
|
|
208
|
+
// matching the convention used by most other locales (de, es, fr, it, etc.).
|
|
209
|
+
const dateSchema = z.instanceof(Date);
|
|
210
|
+
const dateResult = dateSchema.safeParse("not a date");
|
|
211
|
+
expect(dateResult.success).toBe(false);
|
|
212
|
+
if (!dateResult.success) {
|
|
213
|
+
expect(dateResult.error.issues[0].message).toBe("Μη έγκυρη είσοδος: αναμενόταν instanceof Date, λήφθηκε string");
|
|
214
|
+
}
|
|
215
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { expect, test } from "vitest";
|
|
2
|
+
import { z } from "../../../../index.js";
|
|
3
|
+
import fr from "../../../locales/fr.js";
|
|
4
|
+
|
|
5
|
+
test("French locale - type name translations in too_small errors", () => {
|
|
6
|
+
z.config(fr());
|
|
7
|
+
|
|
8
|
+
const stringResult = z.string().min(5).safeParse("abc");
|
|
9
|
+
expect(stringResult.success).toBe(false);
|
|
10
|
+
if (!stringResult.success) {
|
|
11
|
+
expect(stringResult.error.issues[0].message).toBe("Trop petit : chaîne doit avoir >=5 caractères");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const numberResult = z.number().min(10).safeParse(5);
|
|
15
|
+
expect(numberResult.success).toBe(false);
|
|
16
|
+
if (!numberResult.success) {
|
|
17
|
+
expect(numberResult.error.issues[0].message).toBe("Trop petit : nombre doit être >=10");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const arrayResult = z.array(z.string()).min(3).safeParse(["a", "b"]);
|
|
21
|
+
expect(arrayResult.success).toBe(false);
|
|
22
|
+
if (!arrayResult.success) {
|
|
23
|
+
expect(arrayResult.error.issues[0].message).toBe("Trop petit : tableau doit avoir >=3 éléments");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const setResult = z
|
|
27
|
+
.set(z.string())
|
|
28
|
+
.min(2)
|
|
29
|
+
.safeParse(new Set(["a"]));
|
|
30
|
+
expect(setResult.success).toBe(false);
|
|
31
|
+
if (!setResult.success) {
|
|
32
|
+
expect(setResult.error.issues[0].message).toBe("Trop petit : ensemble doit avoir >=2 éléments");
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("French locale - type name translations in too_big errors", () => {
|
|
37
|
+
z.config(fr());
|
|
38
|
+
|
|
39
|
+
const stringResult = z.string().max(3).safeParse("abcde");
|
|
40
|
+
expect(stringResult.success).toBe(false);
|
|
41
|
+
if (!stringResult.success) {
|
|
42
|
+
expect(stringResult.error.issues[0].message).toBe("Trop grand : chaîne doit avoir <=3 caractères");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const numberResult = z.number().max(10).safeParse(15);
|
|
46
|
+
expect(numberResult.success).toBe(false);
|
|
47
|
+
if (!numberResult.success) {
|
|
48
|
+
expect(numberResult.error.issues[0].message).toBe("Trop grand : nombre doit être <=10");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const arrayResult = z.array(z.string()).max(2).safeParse(["a", "b", "c"]);
|
|
52
|
+
expect(arrayResult.success).toBe(false);
|
|
53
|
+
if (!arrayResult.success) {
|
|
54
|
+
expect(arrayResult.error.issues[0].message).toBe("Trop grand : tableau doit avoir <=2 éléments");
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test("French locale - type name translations in invalid_type errors", () => {
|
|
59
|
+
z.config(fr());
|
|
60
|
+
|
|
61
|
+
const stringResult = z.string().safeParse(123);
|
|
62
|
+
expect(stringResult.success).toBe(false);
|
|
63
|
+
if (!stringResult.success) {
|
|
64
|
+
expect(stringResult.error.issues[0].message).toBe("Entrée invalide : chaîne attendu, nombre reçu");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const arrayResult = z.array(z.string()).safeParse({});
|
|
68
|
+
expect(arrayResult.success).toBe(false);
|
|
69
|
+
if (!arrayResult.success) {
|
|
70
|
+
expect(arrayResult.error.issues[0].message).toBe("Entrée invalide : tableau attendu, objet reçu");
|
|
71
|
+
}
|
|
72
|
+
});
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { expect, test } from "vitest";
|
|
2
|
+
import { z } from "../../../../index.js";
|
|
3
|
+
import hr from "../../../locales/hr.js";
|
|
4
|
+
|
|
5
|
+
test("Croatian locale - type name translations in too_small errors", () => {
|
|
6
|
+
z.config(hr());
|
|
7
|
+
|
|
8
|
+
// Test string type translation
|
|
9
|
+
const stringSchema = z.string().min(5);
|
|
10
|
+
const stringResult = stringSchema.safeParse("abc");
|
|
11
|
+
expect(stringResult.success).toBe(false);
|
|
12
|
+
if (!stringResult.success) {
|
|
13
|
+
expect(stringResult.error.issues[0].message).toBe("Premalo: očekivano da tekst ima >=5 znakova");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Test number type translation
|
|
17
|
+
const numberSchema = z.number().min(10);
|
|
18
|
+
const numberResult = numberSchema.safeParse(5);
|
|
19
|
+
expect(numberResult.success).toBe(false);
|
|
20
|
+
if (!numberResult.success) {
|
|
21
|
+
expect(numberResult.error.issues[0].message).toBe("Premalo: očekivano da broj bude >=10");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Test array type translation
|
|
25
|
+
const arraySchema = z.array(z.string()).min(3);
|
|
26
|
+
const arrayResult = arraySchema.safeParse(["a", "b"]);
|
|
27
|
+
expect(arrayResult.success).toBe(false);
|
|
28
|
+
if (!arrayResult.success) {
|
|
29
|
+
expect(arrayResult.error.issues[0].message).toBe("Premalo: očekivano da niz ima >=3 stavki");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Test set type translation
|
|
33
|
+
const setSchema = z.set(z.string()).min(2);
|
|
34
|
+
const setResult = setSchema.safeParse(new Set(["a"]));
|
|
35
|
+
expect(setResult.success).toBe(false);
|
|
36
|
+
if (!setResult.success) {
|
|
37
|
+
expect(setResult.error.issues[0].message).toBe("Premalo: očekivano da skup ima >=2 stavki");
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test("Croatian locale - type name translations in too_big errors", () => {
|
|
42
|
+
z.config(hr());
|
|
43
|
+
|
|
44
|
+
// Test string type translation
|
|
45
|
+
const stringSchema = z.string().max(3);
|
|
46
|
+
const stringResult = stringSchema.safeParse("abcde");
|
|
47
|
+
expect(stringResult.success).toBe(false);
|
|
48
|
+
if (!stringResult.success) {
|
|
49
|
+
expect(stringResult.error.issues[0].message).toBe("Preveliko: očekivano da tekst ima <=3 znakova");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Test number type translation
|
|
53
|
+
const numberSchema = z.number().max(10);
|
|
54
|
+
const numberResult = numberSchema.safeParse(15);
|
|
55
|
+
expect(numberResult.success).toBe(false);
|
|
56
|
+
if (!numberResult.success) {
|
|
57
|
+
expect(numberResult.error.issues[0].message).toBe("Preveliko: očekivano da broj bude <=10");
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Test array type translation
|
|
61
|
+
const arraySchema = z.array(z.string()).max(2);
|
|
62
|
+
const arrayResult = arraySchema.safeParse(["a", "b", "c"]);
|
|
63
|
+
expect(arrayResult.success).toBe(false);
|
|
64
|
+
if (!arrayResult.success) {
|
|
65
|
+
expect(arrayResult.error.issues[0].message).toBe("Preveliko: očekivano da niz ima <=2 stavki");
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test("Croatian locale - type name translations in invalid_type errors", () => {
|
|
70
|
+
z.config(hr());
|
|
71
|
+
|
|
72
|
+
// Test string expected, number received
|
|
73
|
+
const stringSchema = z.string();
|
|
74
|
+
const stringResult = stringSchema.safeParse(123);
|
|
75
|
+
expect(stringResult.success).toBe(false);
|
|
76
|
+
if (!stringResult.success) {
|
|
77
|
+
expect(stringResult.error.issues[0].message).toBe("Neispravan unos: očekuje se tekst, a primljeno je broj");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Test number expected, string received
|
|
81
|
+
const numberSchema = z.number();
|
|
82
|
+
const numberResult = numberSchema.safeParse("abc");
|
|
83
|
+
expect(numberResult.success).toBe(false);
|
|
84
|
+
if (!numberResult.success) {
|
|
85
|
+
expect(numberResult.error.issues[0].message).toBe("Neispravan unos: očekuje se broj, a primljeno je tekst");
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Test boolean expected, null received
|
|
89
|
+
const booleanSchema = z.boolean();
|
|
90
|
+
const booleanResult = booleanSchema.safeParse(null);
|
|
91
|
+
expect(booleanResult.success).toBe(false);
|
|
92
|
+
if (!booleanResult.success) {
|
|
93
|
+
expect(booleanResult.error.issues[0].message).toBe("Neispravan unos: očekuje se boolean, a primljeno je null");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Test array expected, object received
|
|
97
|
+
const arraySchema = z.array(z.string());
|
|
98
|
+
const arrayResult = arraySchema.safeParse({});
|
|
99
|
+
expect(arrayResult.success).toBe(false);
|
|
100
|
+
if (!arrayResult.success) {
|
|
101
|
+
expect(arrayResult.error.issues[0].message).toBe("Neispravan unos: očekuje se niz, a primljeno je objekt");
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test("Croatian locale - other error cases", () => {
|
|
106
|
+
z.config(hr());
|
|
107
|
+
|
|
108
|
+
// Test invalid_element with tuple
|
|
109
|
+
const tupleSchema = z.tuple([z.string(), z.number()]);
|
|
110
|
+
const tupleResult = tupleSchema.safeParse(["abc", "not a number"]);
|
|
111
|
+
expect(tupleResult.success).toBe(false);
|
|
112
|
+
if (!tupleResult.success) {
|
|
113
|
+
expect(tupleResult.error.issues[0].message).toContain("Neispravan unos");
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Test invalid_value with enum
|
|
117
|
+
const enumSchema = z.enum(["a", "b"]);
|
|
118
|
+
const enumResult = enumSchema.safeParse("c");
|
|
119
|
+
expect(enumResult.success).toBe(false);
|
|
120
|
+
if (!enumResult.success) {
|
|
121
|
+
expect(enumResult.error.issues[0].message).toBe('Neispravna opcija: očekivano jedno od "a"|"b"');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Test not_multiple_of
|
|
125
|
+
const multipleSchema = z.number().multipleOf(3);
|
|
126
|
+
const multipleResult = multipleSchema.safeParse(10);
|
|
127
|
+
expect(multipleResult.success).toBe(false);
|
|
128
|
+
if (!multipleResult.success) {
|
|
129
|
+
expect(multipleResult.error.issues[0].message).toBe("Neispravan broj: mora biti višekratnik od 3");
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Test unrecognized_keys
|
|
133
|
+
const strictSchema = z.object({ a: z.string() }).strict();
|
|
134
|
+
const strictResult = strictSchema.safeParse({ a: "test", b: "extra" });
|
|
135
|
+
expect(strictResult.success).toBe(false);
|
|
136
|
+
if (!strictResult.success) {
|
|
137
|
+
expect(strictResult.error.issues[0].message).toBe('Neprepoznat ključ: "b"');
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Test invalid_union
|
|
141
|
+
const unionSchema = z.union([z.string(), z.number()]);
|
|
142
|
+
const unionResult = unionSchema.safeParse(true);
|
|
143
|
+
expect(unionResult.success).toBe(false);
|
|
144
|
+
if (!unionResult.success) {
|
|
145
|
+
expect(unionResult.error.issues[0].message).toBe("Neispravan unos");
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Test invalid_format with regex
|
|
149
|
+
const regexSchema = z.string().regex(/^[a-z]+$/);
|
|
150
|
+
const regexResult = regexSchema.safeParse("ABC123");
|
|
151
|
+
expect(regexResult.success).toBe(false);
|
|
152
|
+
if (!regexResult.success) {
|
|
153
|
+
expect(regexResult.error.issues[0].message).toBe("Neispravan tekst: mora odgovarati uzorku /^[a-z]+$/");
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Test invalid_format with startsWith
|
|
157
|
+
const startsWithSchema = z.string().startsWith("hello");
|
|
158
|
+
const startsWithResult = startsWithSchema.safeParse("world");
|
|
159
|
+
expect(startsWithResult.success).toBe(false);
|
|
160
|
+
if (!startsWithResult.success) {
|
|
161
|
+
expect(startsWithResult.error.issues[0].message).toBe('Neispravan tekst: mora započinjati s "hello"');
|
|
162
|
+
}
|
|
163
|
+
});
|
|
@@ -80,4 +80,26 @@ test("locales - uz", () => {
|
|
|
80
80
|
const invalidElement = z.array(z.string()).safeParse([1, 2, 3]);
|
|
81
81
|
expect(invalidElement.error!.issues[0].code).toBe("invalid_type");
|
|
82
82
|
expect(invalidElement.error!.issues[0].message).toContain("raqam");
|
|
83
|
+
|
|
84
|
+
const tooSmallMap = z
|
|
85
|
+
.map(z.string(), z.string())
|
|
86
|
+
.min(3)
|
|
87
|
+
.safeParse(new Map([["a", "b"]]));
|
|
88
|
+
expect(tooSmallMap.error!.issues[0].code).toBe("too_small");
|
|
89
|
+
expect(tooSmallMap.error!.issues[0].message).toContain("yozuv");
|
|
90
|
+
expect(tooSmallMap.error!.issues[0].message).toContain("bo‘lishi kerak");
|
|
91
|
+
|
|
92
|
+
const tooBigMap = z
|
|
93
|
+
.map(z.string(), z.string())
|
|
94
|
+
.max(2)
|
|
95
|
+
.safeParse(
|
|
96
|
+
new Map([
|
|
97
|
+
["a", "b"],
|
|
98
|
+
["c", "d"],
|
|
99
|
+
["e", "f"],
|
|
100
|
+
])
|
|
101
|
+
);
|
|
102
|
+
expect(tooBigMap.error!.issues[0].code).toBe("too_big");
|
|
103
|
+
expect(tooBigMap.error!.issues[0].message).toContain("yozuv");
|
|
104
|
+
expect(tooBigMap.error!.issues[0].message).toContain("bo‘lishi kerak");
|
|
83
105
|
});
|
package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/tests/record-constructor.test.ts
CHANGED
|
@@ -65,3 +65,61 @@ test("record should work with different key types and constructor field", () =>
|
|
|
65
65
|
const result = enumSchema.parse({ constructor: "value1", key: "value2" });
|
|
66
66
|
expect(result).toEqual({ constructor: "value1", key: "value2" });
|
|
67
67
|
});
|
|
68
|
+
|
|
69
|
+
test("record should skip non-enumerable own properties", () => {
|
|
70
|
+
const schema = z.record(z.string(), z.string());
|
|
71
|
+
|
|
72
|
+
const input = { key: "value" };
|
|
73
|
+
Object.defineProperty(input, "~standard", {
|
|
74
|
+
value: { validate: () => {}, vendor: "zod", version: 1 },
|
|
75
|
+
enumerable: false,
|
|
76
|
+
writable: false,
|
|
77
|
+
configurable: false,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const result = schema.safeParse(input);
|
|
81
|
+
expect(result.success).toBe(true);
|
|
82
|
+
if (result.success) {
|
|
83
|
+
expect(result.data).toEqual({ key: "value" });
|
|
84
|
+
expect("~standard" in result.data).toBe(false);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test("record fails on enumerable invalid values even when non-enumerable properties are present", () => {
|
|
89
|
+
const schema = z.record(z.string(), z.string());
|
|
90
|
+
|
|
91
|
+
const input = { key: "value", bad: 123 };
|
|
92
|
+
Object.defineProperty(input, "hidden", {
|
|
93
|
+
value: "should be ignored",
|
|
94
|
+
enumerable: false,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const result = schema.safeParse(input);
|
|
98
|
+
expect(result.success).toBe(false);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test("record validates enumerable Symbol keys and skips non-enumerable Symbol keys", () => {
|
|
102
|
+
const enumerableSym = Symbol.for("included");
|
|
103
|
+
const nonEnumerableSym = Symbol.for("hidden");
|
|
104
|
+
const schema = z.record(z.symbol(), z.string());
|
|
105
|
+
|
|
106
|
+
const input: Record<symbol, unknown> = { [enumerableSym]: "value" };
|
|
107
|
+
Object.defineProperty(input, nonEnumerableSym, {
|
|
108
|
+
value: 123,
|
|
109
|
+
enumerable: false,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const result = schema.safeParse(input);
|
|
113
|
+
expect(result.success).toBe(true);
|
|
114
|
+
if (result.success) {
|
|
115
|
+
expect(result.data[enumerableSym]).toBe("value");
|
|
116
|
+
expect(Object.prototype.hasOwnProperty.call(result.data, nonEnumerableSym)).toBe(false);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test("z.json() accepts z.toJSONSchema() output (issue #5714)", () => {
|
|
121
|
+
const schema = z.object({ name: z.string() });
|
|
122
|
+
const jsonSchema = z.toJSONSchema(schema);
|
|
123
|
+
|
|
124
|
+
expect(z.json().safeParse(jsonSchema).success).toBe(true);
|
|
125
|
+
});
|
|
@@ -205,7 +205,7 @@ export function process<T extends schemas.$ZodType>(
|
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
// set prefault as default
|
|
208
|
-
if (ctx.io === "input" && result.schema
|
|
208
|
+
if (ctx.io === "input" && "_prefault" in result.schema) result.schema.default ??= result.schema._prefault;
|
|
209
209
|
delete result.schema._prefault;
|
|
210
210
|
|
|
211
211
|
// pulling fresh from ctx.seen in case it was overwritten
|
|
@@ -471,11 +471,19 @@ export function finalize<T extends schemas.$ZodType>(
|
|
|
471
471
|
|
|
472
472
|
Object.assign(result, root.def ?? root.schema);
|
|
473
473
|
|
|
474
|
+
// The `id` in `.meta()` is a Zod-specific registration tag used to extract
|
|
475
|
+
// schemas into $defs — it is not user-facing JSON Schema metadata. Strip it
|
|
476
|
+
// from the output body where it would otherwise leak. The id is preserved
|
|
477
|
+
// implicitly via the $defs key (and via $ref paths).
|
|
478
|
+
const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
|
|
479
|
+
if (rootMetaId !== undefined && result.id === rootMetaId) delete result.id;
|
|
480
|
+
|
|
474
481
|
// build defs object
|
|
475
482
|
const defs: JSONSchema.BaseSchema["$defs"] = ctx.external?.defs ?? {};
|
|
476
483
|
for (const entry of ctx.seen.entries()) {
|
|
477
484
|
const seen = entry[1];
|
|
478
485
|
if (seen.def && seen.defId) {
|
|
486
|
+
if (seen.def.id === seen.defId) delete seen.def.id;
|
|
479
487
|
defs[seen.defId] = seen.def;
|
|
480
488
|
}
|
|
481
489
|
}
|