Leon4gr45 commited on
Commit
e24377d
·
verified ·
1 Parent(s): 645f52a

Upload folder using huggingface_hub (part 12)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4-mini/index.ts +1 -0
  2. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/nan.test.ts +21 -0
  3. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/nested-refine.test.ts +168 -0
  4. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/nonoptional.test.ts +86 -0
  5. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/nullable.test.ts +22 -0
  6. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/number.test.ts +247 -0
  7. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/object.test.ts +563 -0
  8. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/optional.test.ts +123 -0
  9. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/partial.test.ts +147 -0
  10. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/pickomit.test.ts +127 -0
  11. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/pipe.test.ts +81 -0
  12. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/prefault.test.ts +37 -0
  13. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +298 -0
  14. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/primitive.test.ts +175 -0
  15. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/promise.test.ts +81 -0
  16. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/prototypes.test.ts +23 -0
  17. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/readonly.test.ts +252 -0
  18. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/record.test.ts +342 -0
  19. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +356 -0
  20. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/refine.test.ts +532 -0
  21. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/registries.test.ts +204 -0
  22. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/set.test.ts +179 -0
  23. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +57 -0
  24. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/string-formats.test.ts +109 -0
  25. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/string.test.ts +881 -0
  26. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +66 -0
  27. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +758 -0
  28. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +2314 -0
  29. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/transform.test.ts +250 -0
  30. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/tuple.test.ts +163 -0
  31. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/union.test.ts +94 -0
  32. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/validations.test.ts +283 -0
  33. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/void.test.ts +12 -0
  34. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/api.ts +1594 -0
  35. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/checks.ts +1283 -0
  36. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/config.ts +15 -0
  37. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/core.ts +134 -0
  38. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/doc.ts +44 -0
  39. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/errors.ts +424 -0
  40. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/function.ts +176 -0
  41. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/index.ts +15 -0
  42. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/json-schema.ts +143 -0
  43. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/parse.ts +94 -0
  44. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/regexes.ts +135 -0
  45. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/registries.ts +96 -0
  46. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/schemas.ts +0 -0
  47. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/standard-schema.ts +64 -0
  48. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/tests/index.test.ts +46 -0
  49. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/tests/locales/be.test.ts +124 -0
  50. node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/tests/locales/en.test.ts +22 -0
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4-mini/index.ts ADDED
@@ -0,0 +1 @@
 
 
1
+ export * from "../v4/mini/index.js";
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/nan.test.ts ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+
3
+ import * as z from "zod/v4";
4
+
5
+ const schema = z.nan();
6
+
7
+ test("passing validations", () => {
8
+ schema.parse(Number.NaN);
9
+ schema.parse(Number("Not a number"));
10
+ expectTypeOf<typeof schema._output>().toEqualTypeOf<number>();
11
+ });
12
+
13
+ test("failing validations", () => {
14
+ expect(() => schema.parse(5)).toThrow();
15
+ expect(() => schema.parse("John")).toThrow();
16
+ expect(() => schema.parse(true)).toThrow();
17
+ expect(() => schema.parse(null)).toThrow();
18
+ expect(() => schema.parse(undefined)).toThrow();
19
+ expect(() => schema.parse({})).toThrow();
20
+ expect(() => schema.parse([])).toThrow();
21
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/nested-refine.test.ts ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+
4
+ test("nested refinements", () => {
5
+ const zodSchema = z
6
+ .object({
7
+ password: z.string().min(1),
8
+ nested: z
9
+ .object({
10
+ confirm: z
11
+ .string()
12
+ .min(1)
13
+ .refine((value) => value.length > 2, {
14
+ message: "Confirm length should be > 2",
15
+ }),
16
+ })
17
+ .refine(
18
+ (data) => {
19
+ return data.confirm === "bar";
20
+ },
21
+ {
22
+ path: ["confirm"],
23
+ error: 'Value must be "bar"',
24
+ }
25
+ ),
26
+ })
27
+ .refine(
28
+ (data) => {
29
+ return data.nested.confirm === data.password;
30
+ },
31
+ {
32
+ path: ["nested", "confirm"],
33
+ error: "Password and confirm must match",
34
+ }
35
+ );
36
+
37
+ const DATA = {
38
+ password: "bar",
39
+ nested: { confirm: "" },
40
+ };
41
+ expect(zodSchema.safeParse(DATA)).toMatchInlineSnapshot(`
42
+ {
43
+ "error": [ZodError: [
44
+ {
45
+ "origin": "string",
46
+ "code": "too_small",
47
+ "minimum": 1,
48
+ "inclusive": true,
49
+ "path": [
50
+ "nested",
51
+ "confirm"
52
+ ],
53
+ "message": "Too small: expected string to have >=1 characters"
54
+ },
55
+ {
56
+ "code": "custom",
57
+ "path": [
58
+ "nested",
59
+ "confirm"
60
+ ],
61
+ "message": "Confirm length should be > 2"
62
+ },
63
+ {
64
+ "code": "custom",
65
+ "path": [
66
+ "nested",
67
+ "confirm"
68
+ ],
69
+ "message": "Value must be \\"bar\\""
70
+ },
71
+ {
72
+ "code": "custom",
73
+ "path": [
74
+ "nested",
75
+ "confirm"
76
+ ],
77
+ "message": "Password and confirm must match"
78
+ }
79
+ ]],
80
+ "success": false,
81
+ }
82
+ `);
83
+
84
+ expect(zodSchema.safeParse(DATA, { jitless: true })).toMatchInlineSnapshot(`
85
+ {
86
+ "error": [ZodError: [
87
+ {
88
+ "origin": "string",
89
+ "code": "too_small",
90
+ "minimum": 1,
91
+ "inclusive": true,
92
+ "path": [
93
+ "nested",
94
+ "confirm"
95
+ ],
96
+ "message": "Too small: expected string to have >=1 characters"
97
+ },
98
+ {
99
+ "code": "custom",
100
+ "path": [
101
+ "nested",
102
+ "confirm"
103
+ ],
104
+ "message": "Confirm length should be > 2"
105
+ },
106
+ {
107
+ "code": "custom",
108
+ "path": [
109
+ "nested",
110
+ "confirm"
111
+ ],
112
+ "message": "Value must be \\"bar\\""
113
+ },
114
+ {
115
+ "code": "custom",
116
+ "path": [
117
+ "nested",
118
+ "confirm"
119
+ ],
120
+ "message": "Password and confirm must match"
121
+ }
122
+ ]],
123
+ "success": false,
124
+ }
125
+ `);
126
+
127
+ expect(zodSchema["~standard"].validate(DATA)).toMatchInlineSnapshot(`
128
+ {
129
+ "issues": [
130
+ {
131
+ "code": "too_small",
132
+ "inclusive": true,
133
+ "message": "Too small: expected string to have >=1 characters",
134
+ "minimum": 1,
135
+ "origin": "string",
136
+ "path": [
137
+ "nested",
138
+ "confirm",
139
+ ],
140
+ },
141
+ {
142
+ "code": "custom",
143
+ "message": "Confirm length should be > 2",
144
+ "path": [
145
+ "nested",
146
+ "confirm",
147
+ ],
148
+ },
149
+ {
150
+ "code": "custom",
151
+ "message": "Value must be "bar"",
152
+ "path": [
153
+ "nested",
154
+ "confirm",
155
+ ],
156
+ },
157
+ {
158
+ "code": "custom",
159
+ "message": "Password and confirm must match",
160
+ "path": [
161
+ "nested",
162
+ "confirm",
163
+ ],
164
+ },
165
+ ],
166
+ }
167
+ `);
168
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/nonoptional.test.ts ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+ import { z } from "zod/v4";
3
+
4
+ test("nonoptional", () => {
5
+ const schema = z.string().nonoptional();
6
+ expectTypeOf<typeof schema._input>().toEqualTypeOf<string>();
7
+ expectTypeOf<typeof schema._output>().toEqualTypeOf<string>();
8
+
9
+ const result = schema.safeParse(undefined);
10
+ expect(result.success).toBe(false);
11
+ expect(result).toMatchInlineSnapshot(`
12
+ {
13
+ "error": [ZodError: [
14
+ {
15
+ "expected": "string",
16
+ "code": "invalid_type",
17
+ "path": [],
18
+ "message": "Invalid input: expected string, received undefined"
19
+ }
20
+ ]],
21
+ "success": false,
22
+ }
23
+ `);
24
+ });
25
+
26
+ test("nonoptional with default", () => {
27
+ const schema = z.string().optional().nonoptional();
28
+ expectTypeOf<typeof schema._input>().toEqualTypeOf<string>();
29
+ expectTypeOf<typeof schema._output>().toEqualTypeOf<string>();
30
+
31
+ const result = schema.safeParse(undefined);
32
+ expect(result.success).toBe(false);
33
+ expect(result).toMatchInlineSnapshot(`
34
+ {
35
+ "error": [ZodError: [
36
+ {
37
+ "code": "invalid_type",
38
+ "expected": "nonoptional",
39
+ "path": [],
40
+ "message": "Invalid input: expected nonoptional, received undefined"
41
+ }
42
+ ]],
43
+ "success": false,
44
+ }
45
+ `);
46
+ });
47
+
48
+ test("nonoptional in object", () => {
49
+ const schema = z.object({ hi: z.string().optional().nonoptional() });
50
+
51
+ expectTypeOf<typeof schema._input>().toEqualTypeOf<{ hi: string }>();
52
+ expectTypeOf<typeof schema._output>().toEqualTypeOf<{ hi: string }>();
53
+ const r1 = schema.safeParse({ hi: "asdf" });
54
+ expect(r1.success).toEqual(true);
55
+
56
+ const r2 = schema.safeParse({ hi: undefined });
57
+ // expect(schema.safeParse({ hi: undefined }).success).toEqual(false);
58
+ expect(r2.success).toEqual(false);
59
+ expect(r2.error).toMatchInlineSnapshot(`
60
+ [ZodError: [
61
+ {
62
+ "code": "invalid_type",
63
+ "expected": "nonoptional",
64
+ "path": [
65
+ "hi"
66
+ ],
67
+ "message": "Invalid input: expected nonoptional, received undefined"
68
+ }
69
+ ]]
70
+ `);
71
+
72
+ const r3 = schema.safeParse({});
73
+ expect(r3.success).toEqual(false);
74
+ expect(r3.error).toMatchInlineSnapshot(`
75
+ [ZodError: [
76
+ {
77
+ "code": "invalid_type",
78
+ "expected": "nonoptional",
79
+ "path": [
80
+ "hi"
81
+ ],
82
+ "message": "Invalid input: expected nonoptional, received undefined"
83
+ }
84
+ ]]
85
+ `);
86
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/nullable.test.ts ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, test } from "vitest";
2
+
3
+ import * as z from "zod/v4";
4
+
5
+ test(".nullable()", () => {
6
+ const nullable = z.string().nullable();
7
+ expect(nullable.parse(null)).toBe(null);
8
+ expect(nullable.parse("asdf")).toBe("asdf");
9
+ expect(() => nullable.parse(123)).toThrow();
10
+ });
11
+
12
+ test(".nullable unwrap", () => {
13
+ const schema = z.string().nullable();
14
+ expect(schema).toBeInstanceOf(z.ZodNullable);
15
+ expect(schema.unwrap()).toBeInstanceOf(z.ZodString);
16
+ });
17
+
18
+ test("z.null", () => {
19
+ const n = z.null();
20
+ expect(n.parse(null)).toBe(null);
21
+ expect(() => n.parse("asdf")).toThrow();
22
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/number.test.ts ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, test } from "vitest";
2
+
3
+ import * as z from "zod/v4";
4
+
5
+ test("z.number() basic validation", () => {
6
+ const schema = z.number();
7
+ expect(schema.parse(1234)).toEqual(1234);
8
+ });
9
+
10
+ test("NaN validation", () => {
11
+ const schema = z.number();
12
+ expect(() => schema.parse(Number.NaN)).toThrow();
13
+ });
14
+
15
+ test("Infinity validation", () => {
16
+ const schema = z.number();
17
+ expect(schema.safeParse(Number.POSITIVE_INFINITY)).toMatchInlineSnapshot(`
18
+ {
19
+ "error": [ZodError: [
20
+ {
21
+ "expected": "number",
22
+ "code": "invalid_type",
23
+ "received": "Infinity",
24
+ "path": [],
25
+ "message": "Invalid input: expected number, received number"
26
+ }
27
+ ]],
28
+ "success": false,
29
+ }
30
+ `);
31
+ expect(schema.safeParse(Number.NEGATIVE_INFINITY)).toMatchInlineSnapshot(`
32
+ {
33
+ "error": [ZodError: [
34
+ {
35
+ "expected": "number",
36
+ "code": "invalid_type",
37
+ "received": "Infinity",
38
+ "path": [],
39
+ "message": "Invalid input: expected number, received number"
40
+ }
41
+ ]],
42
+ "success": false,
43
+ }
44
+ `);
45
+ });
46
+
47
+ test(".gt() validation", () => {
48
+ const schema = z.number().gt(0).gt(5);
49
+ expect(schema.parse(6)).toEqual(6);
50
+ expect(() => schema.parse(5)).toThrow();
51
+ });
52
+
53
+ test(".gte() validation", () => {
54
+ const schema = z.number().gt(0).gte(1).gte(5);
55
+ expect(schema.parse(5)).toEqual(5);
56
+ expect(() => schema.parse(4)).toThrow();
57
+ });
58
+
59
+ test(".min() validation", () => {
60
+ const schema = z.number().min(0).min(5);
61
+ expect(schema.parse(5)).toEqual(5);
62
+ expect(() => schema.parse(4)).toThrow();
63
+ });
64
+
65
+ test(".lt() validation", () => {
66
+ const schema = z.number().lte(10).lt(5);
67
+ expect(schema.parse(4)).toEqual(4);
68
+ expect(() => schema.parse(5)).toThrow();
69
+ });
70
+
71
+ test(".lte() validation", () => {
72
+ const schema = z.number().lte(10).lte(5);
73
+ expect(schema.parse(5)).toEqual(5);
74
+ expect(() => schema.parse(6)).toThrow();
75
+ });
76
+
77
+ test(".max() validation", () => {
78
+ const schema = z.number().max(10).max(5);
79
+ expect(schema.parse(5)).toEqual(5);
80
+ expect(() => schema.parse(6)).toThrow();
81
+ });
82
+
83
+ test(".int() validation", () => {
84
+ const schema = z.number().int();
85
+ expect(schema.parse(4)).toEqual(4);
86
+ expect(() => schema.parse(3.14)).toThrow();
87
+ });
88
+
89
+ test(".positive() validation", () => {
90
+ const schema = z.number().positive();
91
+ expect(schema.parse(1)).toEqual(1);
92
+ expect(() => schema.parse(0)).toThrow();
93
+ expect(() => schema.parse(-1)).toThrow();
94
+ });
95
+
96
+ test(".negative() validation", () => {
97
+ const schema = z.number().negative();
98
+ expect(schema.parse(-1)).toEqual(-1);
99
+ expect(() => schema.parse(0)).toThrow();
100
+ expect(() => schema.parse(1)).toThrow();
101
+ });
102
+
103
+ test(".nonpositive() validation", () => {
104
+ const schema = z.number().nonpositive();
105
+ expect(schema.parse(0)).toEqual(0);
106
+ expect(schema.parse(-1)).toEqual(-1);
107
+ expect(() => schema.parse(1)).toThrow();
108
+ });
109
+
110
+ test(".nonnegative() validation", () => {
111
+ const schema = z.number().nonnegative();
112
+ expect(schema.parse(0)).toEqual(0);
113
+ expect(schema.parse(1)).toEqual(1);
114
+ expect(() => schema.parse(-1)).toThrow();
115
+ });
116
+
117
+ test(".multipleOf() with positive divisor", () => {
118
+ const schema = z.number().multipleOf(5);
119
+ expect(schema.parse(15)).toEqual(15);
120
+ expect(schema.parse(-15)).toEqual(-15);
121
+ expect(() => schema.parse(7.5)).toThrow();
122
+ expect(() => schema.parse(-7.5)).toThrow();
123
+ });
124
+
125
+ test(".multipleOf() with negative divisor", () => {
126
+ const schema = z.number().multipleOf(-5);
127
+ expect(schema.parse(-15)).toEqual(-15);
128
+ expect(schema.parse(15)).toEqual(15);
129
+ expect(() => schema.parse(-7.5)).toThrow();
130
+ expect(() => schema.parse(7.5)).toThrow();
131
+ });
132
+
133
+ test(".step() validation", () => {
134
+ const schemaPointOne = z.number().step(0.1);
135
+ const schemaPointZeroZeroZeroOne = z.number().step(0.0001);
136
+ const schemaSixPointFour = z.number().step(6.4);
137
+
138
+ expect(schemaPointOne.parse(6)).toEqual(6);
139
+ expect(schemaPointOne.parse(6.1)).toEqual(6.1);
140
+ expect(schemaSixPointFour.parse(12.8)).toEqual(12.8);
141
+ expect(schemaPointZeroZeroZeroOne.parse(3.01)).toEqual(3.01);
142
+ expect(() => schemaPointOne.parse(6.11)).toThrow();
143
+ expect(() => schemaPointOne.parse(6.1000000001)).toThrow();
144
+ expect(() => schemaSixPointFour.parse(6.41)).toThrow();
145
+ });
146
+
147
+ test(".finite() validation", () => {
148
+ const schema = z.number().finite();
149
+ expect(schema.parse(123)).toEqual(123);
150
+ expect(schema.safeParse(Number.POSITIVE_INFINITY)).toMatchInlineSnapshot(`
151
+ {
152
+ "error": [ZodError: [
153
+ {
154
+ "expected": "number",
155
+ "code": "invalid_type",
156
+ "received": "Infinity",
157
+ "path": [],
158
+ "message": "Invalid input: expected number, received number"
159
+ }
160
+ ]],
161
+ "success": false,
162
+ }
163
+ `);
164
+ expect(schema.safeParse(Number.NEGATIVE_INFINITY)).toMatchInlineSnapshot(`
165
+ {
166
+ "error": [ZodError: [
167
+ {
168
+ "expected": "number",
169
+ "code": "invalid_type",
170
+ "received": "Infinity",
171
+ "path": [],
172
+ "message": "Invalid input: expected number, received number"
173
+ }
174
+ ]],
175
+ "success": false,
176
+ }
177
+ `);
178
+ });
179
+
180
+ test(".safe() validation", () => {
181
+ const schema = z.number().safe();
182
+ expect(schema.parse(Number.MIN_SAFE_INTEGER)).toEqual(Number.MIN_SAFE_INTEGER);
183
+ expect(schema.parse(Number.MAX_SAFE_INTEGER)).toEqual(Number.MAX_SAFE_INTEGER);
184
+ expect(() => schema.parse(Number.MIN_SAFE_INTEGER - 1)).toThrow();
185
+ expect(() => schema.parse(Number.MAX_SAFE_INTEGER + 1)).toThrow();
186
+ });
187
+
188
+ test("min value getters", () => {
189
+ expect(z.number().minValue).toBeNull;
190
+ expect(z.number().lt(5).minValue).toBeNull;
191
+ expect(z.number().lte(5).minValue).toBeNull;
192
+ expect(z.number().max(5).minValue).toBeNull;
193
+ expect(z.number().negative().minValue).toBeNull;
194
+ expect(z.number().nonpositive().minValue).toBeNull;
195
+ expect(z.number().int().minValue).toBeNull;
196
+ expect(z.number().multipleOf(5).minValue).toBeNull;
197
+ expect(z.number().finite().minValue).toBeNull;
198
+ expect(z.number().gt(5).minValue).toEqual(5);
199
+ expect(z.number().gte(5).minValue).toEqual(5);
200
+ expect(z.number().min(5).minValue).toEqual(5);
201
+ expect(z.number().min(5).min(10).minValue).toEqual(10);
202
+ expect(z.number().positive().minValue).toEqual(0);
203
+ expect(z.number().nonnegative().minValue).toEqual(0);
204
+ expect(z.number().safe().minValue).toEqual(Number.MIN_SAFE_INTEGER);
205
+ });
206
+
207
+ test("max value getters", () => {
208
+ expect(z.number().maxValue).toBeNull;
209
+ expect(z.number().gt(5).maxValue).toBeNull;
210
+ expect(z.number().gte(5).maxValue).toBeNull;
211
+ expect(z.number().min(5).maxValue).toBeNull;
212
+ expect(z.number().positive().maxValue).toBeNull;
213
+ expect(z.number().nonnegative().maxValue).toBeNull;
214
+ expect(z.number().int().minValue).toBeNull;
215
+ expect(z.number().multipleOf(5).minValue).toBeNull;
216
+ expect(z.number().finite().minValue).toBeNull;
217
+ expect(z.number().lt(5).maxValue).toEqual(5);
218
+ expect(z.number().lte(5).maxValue).toEqual(5);
219
+ expect(z.number().max(5).maxValue).toEqual(5);
220
+ expect(z.number().max(5).max(1).maxValue).toEqual(1);
221
+ expect(z.number().negative().maxValue).toEqual(0);
222
+ expect(z.number().nonpositive().maxValue).toEqual(0);
223
+ expect(z.number().safe().maxValue).toEqual(Number.MAX_SAFE_INTEGER);
224
+ });
225
+
226
+ test("int getter", () => {
227
+ expect(z.number().isInt).toEqual(false);
228
+ expect(z.number().int().isInt).toEqual(true);
229
+ expect(z.number().safe().isInt).toEqual(true);
230
+ expect(z.number().multipleOf(5).isInt).toEqual(true);
231
+ });
232
+
233
+ /** In Zod 4, number schemas don't accept infinite values. */
234
+ test("finite getter", () => {
235
+ expect(z.number().isFinite).toEqual(true);
236
+ });
237
+
238
+ test("string format methods", () => {
239
+ const a = z.int32().min(5);
240
+ expect(a.parse(6)).toEqual(6);
241
+ expect(() => a.parse(1)).toThrow();
242
+ });
243
+
244
+ test("error customization", () => {
245
+ z.number().gte(5, { error: (iss) => "Min: " + iss.minimum.valueOf() });
246
+ z.number().lte(5, { error: (iss) => "Max: " + iss.maximum.valueOf() });
247
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/object.test.ts ADDED
@@ -0,0 +1,563 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+ import * as core from "zod/v4/core";
4
+
5
+ const Test = z.object({
6
+ f1: z.number(),
7
+ f2: z.string().optional(),
8
+ f3: z.string().nullable(),
9
+ f4: z.array(z.object({ t: z.union([z.string(), z.boolean()]) })),
10
+ });
11
+
12
+ test("object type inference", () => {
13
+ type TestType = {
14
+ f1: number;
15
+ f2?: string | undefined;
16
+ f3: string | null;
17
+ f4: { t: string | boolean }[];
18
+ };
19
+
20
+ expectTypeOf<z.TypeOf<typeof Test>>().toEqualTypeOf<TestType>();
21
+ });
22
+
23
+ test("unknown throw", () => {
24
+ const asdf: unknown = 35;
25
+ expect(() => Test.parse(asdf)).toThrow();
26
+ });
27
+
28
+ test("shape() should return schema of particular key", () => {
29
+ const f1Schema = Test.shape.f1;
30
+ const f2Schema = Test.shape.f2;
31
+ const f3Schema = Test.shape.f3;
32
+ const f4Schema = Test.shape.f4;
33
+
34
+ expect(f1Schema).toBeInstanceOf(z.ZodNumber);
35
+ expect(f2Schema).toBeInstanceOf(z.ZodOptional);
36
+ expect(f3Schema).toBeInstanceOf(z.ZodNullable);
37
+ expect(f4Schema).toBeInstanceOf(z.ZodArray);
38
+ });
39
+
40
+ test("correct parsing", () => {
41
+ Test.parse({
42
+ f1: 12,
43
+ f2: "string",
44
+ f3: "string",
45
+ f4: [
46
+ {
47
+ t: "string",
48
+ },
49
+ ],
50
+ });
51
+
52
+ Test.parse({
53
+ f1: 12,
54
+ f3: null,
55
+ f4: [
56
+ {
57
+ t: false,
58
+ },
59
+ ],
60
+ });
61
+ });
62
+
63
+ test("nonstrict by default", () => {
64
+ z.object({ points: z.number() }).parse({
65
+ points: 2314,
66
+ unknown: "asdf",
67
+ });
68
+ });
69
+
70
+ test("parse optional keys ", () => {
71
+ const schema = z.object({
72
+ a: z.string().optional(),
73
+ });
74
+ expect(schema.parse({ a: "asdf" })).toEqual({ a: "asdf" });
75
+ });
76
+
77
+ test("empty object", () => {
78
+ const schema = z.object({});
79
+ expect(schema.parse({})).toEqual({});
80
+ expect(schema.parse({ name: "asdf" })).toEqual({});
81
+ expect(schema.safeParse(null).success).toEqual(false);
82
+ expect(schema.safeParse("asdf").success).toEqual(false);
83
+ expectTypeOf<z.output<typeof schema>>().toEqualTypeOf<Record<string, never>>();
84
+ });
85
+
86
+ const data = {
87
+ points: 2314,
88
+ unknown: "asdf",
89
+ };
90
+
91
+ test("strip by default", () => {
92
+ const val = z.object({ points: z.number() }).parse(data);
93
+ expect(val).toEqual({ points: 2314 });
94
+ });
95
+
96
+ test("unknownkeys override", () => {
97
+ const val = z.object({ points: z.number() }).strict().passthrough().strip().passthrough().parse(data);
98
+
99
+ expect(val).toEqual(data);
100
+ });
101
+
102
+ test("passthrough unknown", () => {
103
+ const val = z.object({ points: z.number() }).passthrough().parse(data);
104
+
105
+ expect(val).toEqual(data);
106
+ });
107
+
108
+ test("strip unknown", () => {
109
+ const val = z.object({ points: z.number() }).strip().parse(data);
110
+
111
+ expect(val).toEqual({ points: 2314 });
112
+ });
113
+
114
+ test("strict", () => {
115
+ const val = z.object({ points: z.number() }).strict().safeParse(data);
116
+
117
+ expect(val.success).toEqual(false);
118
+ });
119
+
120
+ test("catchall inference", () => {
121
+ const o1 = z
122
+ .object({
123
+ first: z.string(),
124
+ })
125
+ .catchall(z.number());
126
+
127
+ const d1 = o1.parse({ first: "asdf", num: 1243 });
128
+ // expectTypeOf<(typeof d1)["asdf"]>().toEqualTypeOf<number>();
129
+ expectTypeOf<(typeof d1)["first"]>().toEqualTypeOf<string>();
130
+ });
131
+
132
+ test("catchall overrides strict", () => {
133
+ const o1 = z.object({ first: z.string().optional() }).strict().catchall(z.number());
134
+
135
+ // should run fine
136
+ // setting a catchall overrides the unknownKeys behavior
137
+ o1.parse({
138
+ asdf: 1234,
139
+ });
140
+
141
+ // should only run catchall validation
142
+ // against unknown keys
143
+ o1.parse({
144
+ first: "asdf",
145
+ asdf: 1234,
146
+ });
147
+ });
148
+
149
+ test("catchall overrides strict", () => {
150
+ const o1 = z
151
+ .object({
152
+ first: z.string(),
153
+ })
154
+ .strict()
155
+ .catchall(z.number());
156
+
157
+ // should run fine
158
+ // setting a catchall overrides the unknownKeys behavior
159
+ o1.parse({
160
+ first: "asdf",
161
+ asdf: 1234,
162
+ });
163
+ });
164
+
165
+ test("optional keys are unset", async () => {
166
+ const SNamedEntity = z.object({
167
+ id: z.string(),
168
+ set: z.string().optional(),
169
+ unset: z.string().optional(),
170
+ });
171
+ const result = await SNamedEntity.parse({
172
+ id: "asdf",
173
+ set: undefined,
174
+ });
175
+ expect(Object.keys(result)).toEqual(["id", "set"]);
176
+ });
177
+
178
+ test("catchall parsing", async () => {
179
+ const result = z.object({ name: z.string() }).catchall(z.number()).parse({ name: "Foo", validExtraKey: 61 });
180
+
181
+ expect(result).toEqual({ name: "Foo", validExtraKey: 61 });
182
+
183
+ const result2 = z
184
+ .object({ name: z.string() })
185
+ .catchall(z.number())
186
+ .safeParse({ name: "Foo", validExtraKey: 61, invalid: "asdf" });
187
+
188
+ expect(result2.success).toEqual(false);
189
+ });
190
+
191
+ test("nonexistent keys", async () => {
192
+ const Schema = z.union([z.object({ a: z.string() }), z.object({ b: z.number() })]);
193
+ const obj = { a: "A" };
194
+ const result = await Schema.spa(obj); // Works with 1.11.10, breaks with 2.0.0-beta.21
195
+ expect(result.success).toBe(true);
196
+ });
197
+
198
+ test("test async union", async () => {
199
+ const Schema2 = z.union([
200
+ z.object({
201
+ ty: z.string(),
202
+ }),
203
+ z.object({
204
+ ty: z.number(),
205
+ }),
206
+ ]);
207
+
208
+ const obj = { ty: "A" };
209
+ const result = await Schema2.spa(obj); // Works with 1.11.10, breaks with 2.0.0-beta.21
210
+ expect(result.success).toEqual(true);
211
+ });
212
+
213
+ test("test inferred merged type", async () => {
214
+ const asdf = z.object({ a: z.string() }).merge(z.object({ a: z.number() }));
215
+ type asdf = z.infer<typeof asdf>;
216
+
217
+ expectTypeOf<asdf>().toEqualTypeOf<{ a: number }>();
218
+ });
219
+
220
+ test("inferred type with Record shape", () => {
221
+ type A = z.ZodObject<Record<string, z.ZodType<string, number>>>;
222
+ expectTypeOf<z.infer<A>>().toEqualTypeOf<Record<string, string>>();
223
+ expectTypeOf<z.input<A>>().toEqualTypeOf<Record<string, number>>();
224
+
225
+ type B = z.ZodObject;
226
+ expectTypeOf<z.infer<B>>().toEqualTypeOf<Record<string, unknown>>();
227
+ expectTypeOf<z.input<B>>().toEqualTypeOf<Record<string, unknown>>();
228
+ });
229
+
230
+ test("inferred merged object type with optional properties", async () => {
231
+ const Merged = z
232
+ .object({ a: z.string(), b: z.string().optional() })
233
+ .merge(z.object({ a: z.string().optional(), b: z.string() }));
234
+ type Merged = z.infer<typeof Merged>;
235
+ expectTypeOf<Merged>().toEqualTypeOf<{ a?: string; b: string }>();
236
+ expectTypeOf<Merged>().toEqualTypeOf<{ a?: string; b: string }>();
237
+ });
238
+
239
+ test("inferred unioned object type with optional properties", async () => {
240
+ const Unioned = z.union([
241
+ z.object({ a: z.string(), b: z.string().optional() }),
242
+ z.object({ a: z.string().optional(), b: z.string() }),
243
+ ]);
244
+ type Unioned = z.infer<typeof Unioned>;
245
+ expectTypeOf<Unioned>().toEqualTypeOf<{ a: string; b?: string } | { a?: string; b: string }>();
246
+ });
247
+
248
+ test("inferred enum type", async () => {
249
+ const Enum = z.object({ a: z.string(), b: z.string().optional() }).keyof();
250
+
251
+ expect(Enum.enum).toEqual({
252
+ a: "a",
253
+ b: "b",
254
+ });
255
+
256
+ expect(Enum._zod.def.entries).toEqual({
257
+ a: "a",
258
+ b: "b",
259
+ });
260
+ type Enum = z.infer<typeof Enum>;
261
+ expectTypeOf<Enum>().toEqualTypeOf<"a" | "b">();
262
+ });
263
+
264
+ test("inferred partial object type with optional properties", async () => {
265
+ const Partial = z.object({ a: z.string(), b: z.string().optional() }).partial();
266
+ type Partial = z.infer<typeof Partial>;
267
+ expectTypeOf<Partial>().toEqualTypeOf<{ a?: string; b?: string }>();
268
+ });
269
+
270
+ test("inferred picked object type with optional properties", async () => {
271
+ const Picked = z.object({ a: z.string(), b: z.string().optional() }).pick({ b: true });
272
+ type Picked = z.infer<typeof Picked>;
273
+ expectTypeOf<Picked>().toEqualTypeOf<{ b?: string }>();
274
+ });
275
+
276
+ test("inferred type for unknown/any keys", () => {
277
+ const myType = z.object({
278
+ anyOptional: z.any().optional(),
279
+ anyRequired: z.any(),
280
+ unknownOptional: z.unknown().optional(),
281
+ unknownRequired: z.unknown(),
282
+ });
283
+ type myType = z.infer<typeof myType>;
284
+ expectTypeOf<myType>().toEqualTypeOf<{
285
+ anyOptional?: any;
286
+ anyRequired: any;
287
+ unknownOptional?: unknown;
288
+ unknownRequired: unknown;
289
+ }>();
290
+ });
291
+
292
+ test("strictObject", async () => {
293
+ const strictObj = z.strictObject({
294
+ name: z.string(),
295
+ });
296
+
297
+ const syncResult = strictObj.safeParse({ name: "asdf", unexpected: 13 });
298
+ expect(syncResult.success).toEqual(false);
299
+
300
+ const asyncResult = await strictObj.spa({ name: "asdf", unexpected: 13 });
301
+ expect(asyncResult.success).toEqual(false);
302
+ });
303
+
304
+ test("object with refine", async () => {
305
+ const schema = z
306
+ .object({
307
+ a: z.string().default("foo"),
308
+ b: z.number(),
309
+ })
310
+ .refine(() => true);
311
+ expect(schema.parse({ b: 5 })).toEqual({ b: 5, a: "foo" });
312
+ const result = await schema.parseAsync({ b: 5 });
313
+ expect(result).toEqual({ b: 5, a: "foo" });
314
+ });
315
+
316
+ test("intersection of object with date", async () => {
317
+ const schema = z.object({
318
+ a: z.date(),
319
+ });
320
+ expect(z.intersection(schema, schema).parse({ a: new Date(1637353595983) })).toEqual({
321
+ a: new Date(1637353595983),
322
+ });
323
+ const result = await schema.parseAsync({ a: new Date(1637353595983) });
324
+ expect(result).toEqual({ a: new Date(1637353595983) });
325
+ });
326
+
327
+ test("intersection of object with refine with date", async () => {
328
+ const schema = z
329
+ .object({
330
+ a: z.date(),
331
+ })
332
+ .refine(() => true);
333
+ expect(z.intersection(schema, schema).parse({ a: new Date(1637353595983) })).toEqual({
334
+ a: new Date(1637353595983),
335
+ });
336
+ const result = await schema.parseAsync({ a: new Date(1637353595983) });
337
+ expect(result).toEqual({ a: new Date(1637353595983) });
338
+ });
339
+
340
+ test("constructor key", () => {
341
+ const person = z
342
+ .object({
343
+ name: z.string(),
344
+ })
345
+ .strict();
346
+
347
+ expect(() =>
348
+ person.parse({
349
+ name: "bob dylan",
350
+ constructor: 61,
351
+ })
352
+ ).toThrow();
353
+ });
354
+
355
+ test("constructor key", () => {
356
+ const Example = z.object({
357
+ prop: z.string(),
358
+ opt: z.number().optional(),
359
+ arr: z.string().array(),
360
+ });
361
+
362
+ type Example = z.infer<typeof Example>;
363
+ expectTypeOf<keyof Example>().toEqualTypeOf<"prop" | "opt" | "arr">();
364
+ });
365
+
366
+ test("catchall", () => {
367
+ const a = z.object({});
368
+ expect(a._zod.def.catchall).toBeUndefined();
369
+
370
+ const b = z.strictObject({});
371
+ expect(b._zod.def.catchall).toBeInstanceOf(core.$ZodNever);
372
+
373
+ const c = z.looseObject({});
374
+ expect(c._zod.def.catchall).toBeInstanceOf(core.$ZodUnknown);
375
+
376
+ const d = z.object({}).catchall(z.number());
377
+ expect(d._zod.def.catchall).toBeInstanceOf(core.$ZodNumber);
378
+ });
379
+
380
+ test("unknownkeys merging", () => {
381
+ // This one is "strict"
382
+ const a = z.looseObject({
383
+ a: z.string(),
384
+ });
385
+
386
+ const b = z.strictObject({ b: z.string() });
387
+
388
+ // incoming object overrides
389
+ const c = a.merge(b);
390
+ expect(c._zod.def.catchall).toBeInstanceOf(core.$ZodNever);
391
+ });
392
+
393
+ const personToExtend = z.object({
394
+ firstName: z.string(),
395
+ lastName: z.string(),
396
+ });
397
+
398
+ test("extend() should return schema with new key", () => {
399
+ const PersonWithNickname = personToExtend.extend({ nickName: z.string() });
400
+ type PersonWithNickname = z.infer<typeof PersonWithNickname>;
401
+
402
+ const expected = { firstName: "f", nickName: "n", lastName: "l" };
403
+ const actual = PersonWithNickname.parse(expected);
404
+
405
+ expect(actual).toEqual(expected);
406
+ expectTypeOf<keyof PersonWithNickname>().toEqualTypeOf<"firstName" | "lastName" | "nickName">();
407
+ expectTypeOf<PersonWithNickname>().toEqualTypeOf<{ firstName: string; lastName: string; nickName: string }>();
408
+ });
409
+
410
+ test("extend() should have power to override existing key", () => {
411
+ const PersonWithNumberAsLastName = personToExtend.extend({
412
+ lastName: z.number(),
413
+ });
414
+ type PersonWithNumberAsLastName = z.infer<typeof PersonWithNumberAsLastName>;
415
+
416
+ const expected = { firstName: "f", lastName: 42 };
417
+ const actual = PersonWithNumberAsLastName.parse(expected);
418
+
419
+ expect(actual).toEqual(expected);
420
+ expectTypeOf<PersonWithNumberAsLastName>().toEqualTypeOf<{ firstName: string; lastName: number }>();
421
+ });
422
+
423
+ test("passthrough index signature", () => {
424
+ const a = z.object({ a: z.string() });
425
+ type a = z.infer<typeof a>;
426
+ expectTypeOf<a>().toEqualTypeOf<{ a: string }>();
427
+ const b = a.passthrough();
428
+ type b = z.infer<typeof b>;
429
+ expectTypeOf<b>().toEqualTypeOf<{ a: string; [k: string]: unknown }>();
430
+ });
431
+
432
+ // test("xor", () => {
433
+ // type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never };
434
+ // type XOR<T, U> = T extends object ? (U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : U) : T;
435
+
436
+ // type A = { name: string; a: number };
437
+ // type B = { name: string; b: number };
438
+ // type C = XOR<A, B>;
439
+ // type Outer = { data: C };
440
+ // const Outer = z.object({
441
+ // data: z.union([z.object({ name: z.string(), a: z.number() }), z.object({ name: z.string(), b: z.number() })]),
442
+ // }) satisfies z.ZodType<Outer, any>;
443
+ // });
444
+
445
+ test("assignability", () => {
446
+ z.object({ a: z.string() }) satisfies z.ZodObject<{ a: z.ZodString }>;
447
+ z.object({ a: z.string() }).catchall(z.number()) satisfies z.ZodObject<{ a: z.ZodString }>;
448
+ z.object({ a: z.string() }).strict() satisfies z.ZodObject;
449
+ z.object({}) satisfies z.ZodObject;
450
+
451
+ z.looseObject({ name: z.string() }) satisfies z.ZodObject<
452
+ {
453
+ name: z.ZodString;
454
+ },
455
+ z.core.$loose
456
+ >;
457
+ z.looseObject({ name: z.string() }) satisfies z.ZodObject<{
458
+ name: z.ZodString;
459
+ }>;
460
+ z.strictObject({ name: z.string() }) satisfies z.ZodObject<
461
+ {
462
+ name: z.ZodString;
463
+ },
464
+ z.core.$loose
465
+ >;
466
+ z.strictObject({ name: z.string() }) satisfies z.ZodObject<
467
+ {
468
+ name: z.ZodString;
469
+ },
470
+ z.core.$strict
471
+ >;
472
+ z.object({ name: z.string() }) satisfies z.ZodObject<{
473
+ name: z.ZodString;
474
+ }>;
475
+ z.object({
476
+ a: z.string(),
477
+ b: z.number(),
478
+ c: z.boolean(),
479
+ }) satisfies z.core.$ZodObject;
480
+ });
481
+
482
+ test("null prototype", () => {
483
+ const schema = z.object({ a: z.string() });
484
+ const obj = Object.create(null);
485
+ obj.a = "foo";
486
+ expect(schema.parse(obj)).toEqual({ a: "foo" });
487
+ });
488
+
489
+ test("empty objects", () => {
490
+ const A = z.looseObject({});
491
+ type Ain = z.input<typeof A>;
492
+ expectTypeOf<Ain>().toEqualTypeOf<Record<string, unknown>>();
493
+ type Aout = z.output<typeof A>;
494
+ expectTypeOf<Aout>().toEqualTypeOf<Record<string, unknown>>();
495
+
496
+ const B = z.object({});
497
+ type Bout = z.output<typeof B>;
498
+ expectTypeOf<Bout>().toEqualTypeOf<Record<string, never>>();
499
+ type Bin = z.input<typeof B>;
500
+ expectTypeOf<Bin>().toEqualTypeOf<Record<string, never>>();
501
+
502
+ const C = z.strictObject({});
503
+ type Cout = z.output<typeof C>;
504
+ expectTypeOf<Cout>().toEqualTypeOf<Record<string, never>>();
505
+ type Cin = z.input<typeof C>;
506
+ expectTypeOf<Cin>().toEqualTypeOf<Record<string, never>>();
507
+ });
508
+
509
+ test("preserve key order", () => {
510
+ const schema = z.object({
511
+ a: z.string().optional(),
512
+ b: z.string(),
513
+ });
514
+ const r1 = schema.safeParse({ a: "asdf", b: "qwer" });
515
+ const r2 = schema.safeParse({ a: "asdf", b: "qwer" }, { jitless: true });
516
+
517
+ expect(Object.keys(r1.data!)).toMatchInlineSnapshot(`
518
+ [
519
+ "a",
520
+ "b",
521
+ ]
522
+ `);
523
+ expect(Object.keys(r1.data!)).toEqual(Object.keys(r2.data!));
524
+ });
525
+
526
+ test("empty shape", () => {
527
+ const a = z.object({});
528
+
529
+ a.parse({});
530
+ a.parse({}, { jitless: true });
531
+ a.parse(Object.create(null));
532
+ a.parse(Object.create(null), { jitless: true });
533
+
534
+ expect(() => a.parse([])).toThrow();
535
+ expect(() => a.parse([], { jitless: true })).toThrow();
536
+ });
537
+
538
+ test("zodtype assignability", () => {
539
+ // Does not error
540
+ z.object({ hello: z.string().optional() }) satisfies z.ZodType<{ hello?: string | undefined }>;
541
+ z.object({ hello: z.string() }) satisfies z.ZodType<{ hello?: string | undefined }>;
542
+ // @ts-expect-error
543
+ z.object({}) satisfies z.ZodType<{ hello: string | undefined }>;
544
+ // @ts-expect-error
545
+ z.object({ hello: z.string().optional() }) satisfies z.ZodType<{ hello: string | undefined }>;
546
+ // @ts-expect-error
547
+ z.object({ hello: z.string().optional() }) satisfies z.ZodType<{ hello: string }>;
548
+ // @ts-expect-error
549
+ z.object({ hello: z.number() }) satisfies z.ZodType<{ hello?: string | undefined }>;
550
+ });
551
+
552
+ test("index signature in shape", () => {
553
+ function makeZodObj<const T extends string>(key: T) {
554
+ return z.looseObject({
555
+ [key]: z.string(),
556
+ });
557
+ }
558
+
559
+ const schema = makeZodObj("foo");
560
+ type schema = z.infer<typeof schema>;
561
+
562
+ expectTypeOf<schema>().toEqualTypeOf<Record<string, string>>();
563
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/optional.test.ts ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore TS6133
2
+ import { expect, expectTypeOf, test } from "vitest";
3
+
4
+ import * as z from "zod/v4";
5
+
6
+ test(".optional()", () => {
7
+ const schema = z.string().optional();
8
+ expect(schema.parse("adsf")).toEqual("adsf");
9
+ expect(schema.parse(undefined)).toEqual(undefined);
10
+ expect(schema.safeParse(null).success).toEqual(false);
11
+
12
+ expectTypeOf<typeof schema._output>().toEqualTypeOf<string | undefined>();
13
+ });
14
+
15
+ test("unwrap", () => {
16
+ const unwrapped = z.string().optional().unwrap();
17
+ expect(unwrapped).toBeInstanceOf(z.ZodString);
18
+ });
19
+
20
+ test("optionality", () => {
21
+ const a = z.string();
22
+ expect(a._zod.optin).toEqual(undefined);
23
+ expect(a._zod.optout).toEqual(undefined);
24
+
25
+ const b = z.string().optional();
26
+ expect(b._zod.optin).toEqual("optional");
27
+ expect(b._zod.optout).toEqual("optional");
28
+
29
+ const c = z.string().default("asdf");
30
+ expect(c._zod.optin).toEqual("optional");
31
+ expect(c._zod.optout).toEqual(undefined);
32
+
33
+ const d = z.string().optional().nullable();
34
+ expect(d._zod.optin).toEqual("optional");
35
+ expect(d._zod.optout).toEqual("optional");
36
+
37
+ const e = z.string().default("asdf").nullable();
38
+ expect(e._zod.optin).toEqual("optional");
39
+ expect(e._zod.optout).toEqual(undefined);
40
+
41
+ // z.undefined should NOT be optional
42
+ const f = z.undefined();
43
+ expect(f._zod.optin).toEqual("optional");
44
+ expect(f._zod.optout).toEqual("optional");
45
+ expectTypeOf<typeof f._zod.optin>().toEqualTypeOf<"optional" | undefined>();
46
+ expectTypeOf<typeof f._zod.optout>().toEqualTypeOf<"optional" | undefined>();
47
+
48
+ // z.union should be optional if any of the types are optional
49
+ const g = z.union([z.string(), z.undefined()]);
50
+ expect(g._zod.optin).toEqual("optional");
51
+ expect(g._zod.optout).toEqual("optional");
52
+ expectTypeOf<typeof g._zod.optin>().toEqualTypeOf<"optional" | undefined>();
53
+ expectTypeOf<typeof g._zod.optout>().toEqualTypeOf<"optional" | undefined>();
54
+
55
+ const h = z.union([z.string(), z.optional(z.string())]);
56
+ expect(h._zod.optin).toEqual("optional");
57
+ expect(h._zod.optout).toEqual("optional");
58
+ expectTypeOf<typeof h._zod.optin>().toEqualTypeOf<"optional">();
59
+ expectTypeOf<typeof h._zod.optout>().toEqualTypeOf<"optional">();
60
+ });
61
+
62
+ test("pipe optionality", () => {
63
+ z.string().optional()._zod.optin;
64
+ const a = z.string().optional().pipe(z.string());
65
+ expect(a._zod.optin).toEqual("optional");
66
+ expect(a._zod.optout).toEqual(undefined);
67
+ expectTypeOf<typeof a._zod.optin>().toEqualTypeOf<"optional">();
68
+ expectTypeOf<typeof a._zod.optout>().toEqualTypeOf<"optional" | undefined>();
69
+
70
+ const b = z
71
+ .string()
72
+ .transform((val) => (Math.random() ? val : undefined))
73
+ .pipe(z.string().optional());
74
+ expect(b._zod.optin).toEqual(undefined);
75
+ expect(b._zod.optout).toEqual("optional");
76
+ expectTypeOf<typeof b._zod.optin>().toEqualTypeOf<"optional" | undefined>();
77
+ expectTypeOf<typeof b._zod.optout>().toEqualTypeOf<"optional">();
78
+
79
+ const c = z.string().default("asdf").pipe(z.string());
80
+ expect(c._zod.optin).toEqual("optional");
81
+ expect(c._zod.optout).toEqual(undefined);
82
+
83
+ const d = z
84
+ .string()
85
+ .transform((val) => (Math.random() ? val : undefined))
86
+ .pipe(z.string().default("asdf"));
87
+ expect(d._zod.optin).toEqual(undefined);
88
+ expect(d._zod.optout).toEqual(undefined);
89
+ });
90
+
91
+ test("pipe optionality inside objects", () => {
92
+ const schema = z.object({
93
+ a: z.string().optional(),
94
+ b: z.string().optional().pipe(z.string()),
95
+ c: z.string().default("asdf").pipe(z.string()),
96
+ d: z
97
+ .string()
98
+ .transform((val) => (Math.random() ? val : undefined))
99
+ .pipe(z.string().optional()),
100
+ e: z
101
+ .string()
102
+ .transform((val) => (Math.random() ? val : undefined))
103
+ .pipe(z.string().default("asdf")),
104
+ });
105
+
106
+ type SchemaIn = z.input<typeof schema>;
107
+ expectTypeOf<SchemaIn>().toEqualTypeOf<{
108
+ a?: string | undefined;
109
+ b?: string | undefined;
110
+ c?: string | undefined;
111
+ d: string;
112
+ e: string;
113
+ }>();
114
+
115
+ type SchemaOut = z.output<typeof schema>;
116
+ expectTypeOf<SchemaOut>().toEqualTypeOf<{
117
+ a?: string | undefined;
118
+ b: string;
119
+ c: string;
120
+ d?: string | undefined;
121
+ e: string;
122
+ }>();
123
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/partial.test.ts ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+
4
+ const nested = z.object({
5
+ name: z.string(),
6
+ age: z.number(),
7
+ outer: z.object({
8
+ inner: z.string(),
9
+ }),
10
+ array: z.array(z.object({ asdf: z.string() })),
11
+ });
12
+
13
+ test("shallow inference", () => {
14
+ const shallow = nested.partial();
15
+ type shallow = z.infer<typeof shallow>;
16
+
17
+ expectTypeOf<shallow>().toEqualTypeOf<{
18
+ name?: string | undefined;
19
+ age?: number | undefined;
20
+ outer?: { inner: string } | undefined;
21
+ array?: { asdf: string }[] | undefined;
22
+ }>();
23
+ });
24
+
25
+ test("shallow partial parse", () => {
26
+ const shallow = nested.partial();
27
+ shallow.parse({});
28
+ shallow.parse({
29
+ name: "asdf",
30
+ age: 23143,
31
+ });
32
+ });
33
+
34
+ test("required", () => {
35
+ const object = z.object({
36
+ name: z.string(),
37
+ age: z.number().optional(),
38
+ field: z.string().optional().default("asdf"),
39
+ nullableField: z.number().nullable(),
40
+ nullishField: z.string().nullish(),
41
+ });
42
+
43
+ const requiredObject = object.required();
44
+ expect(requiredObject.shape.name).toBeInstanceOf(z.ZodNonOptional);
45
+ expect(requiredObject.shape.name.unwrap()).toBeInstanceOf(z.ZodString);
46
+ expect(requiredObject.shape.age).toBeInstanceOf(z.ZodNonOptional);
47
+ expect(requiredObject.shape.age.unwrap()).toBeInstanceOf(z.ZodOptional);
48
+ expect(requiredObject.shape.field).toBeInstanceOf(z.ZodNonOptional);
49
+ expect(requiredObject.shape.field.unwrap()).toBeInstanceOf(z.ZodDefault);
50
+ expect(requiredObject.shape.nullableField).toBeInstanceOf(z.ZodNonOptional);
51
+ expect(requiredObject.shape.nullableField.unwrap()).toBeInstanceOf(z.ZodNullable);
52
+ expect(requiredObject.shape.nullishField).toBeInstanceOf(z.ZodNonOptional);
53
+ expect(requiredObject.shape.nullishField.unwrap()).toBeInstanceOf(z.ZodOptional);
54
+ expect(requiredObject.shape.nullishField.unwrap().unwrap()).toBeInstanceOf(z.ZodNullable);
55
+ });
56
+
57
+ test("required inference", () => {
58
+ const object = z.object({
59
+ name: z.string(),
60
+ age: z.number().optional(),
61
+ field: z.string().optional().default("asdf"),
62
+ nullableField: z.number().nullable(),
63
+ nullishField: z.string().nullish(),
64
+ });
65
+
66
+ const requiredObject = object.required();
67
+
68
+ type required = z.infer<typeof requiredObject>;
69
+ type expected = {
70
+ name: string;
71
+ age: number;
72
+ field: string;
73
+ nullableField: number | null;
74
+ nullishField: string | null;
75
+ };
76
+ expectTypeOf<expected>().toEqualTypeOf<required>();
77
+ });
78
+
79
+ test("required with mask", () => {
80
+ const object = z.object({
81
+ name: z.string(),
82
+ age: z.number().optional(),
83
+ field: z.string().optional().default("asdf"),
84
+ country: z.string().optional(),
85
+ });
86
+
87
+ const requiredObject = object.required({ age: true });
88
+ expect(requiredObject.shape.name).toBeInstanceOf(z.ZodString);
89
+ expect(requiredObject.shape.age).toBeInstanceOf(z.ZodNonOptional);
90
+ expect(requiredObject.shape.field).toBeInstanceOf(z.ZodDefault);
91
+ expect(requiredObject.shape.country).toBeInstanceOf(z.ZodOptional);
92
+ });
93
+
94
+ test("required with mask -- ignore falsy values", () => {
95
+ const object = z.object({
96
+ name: z.string(),
97
+ age: z.number().optional(),
98
+ field: z.string().optional().default("asdf"),
99
+ country: z.string().optional(),
100
+ });
101
+
102
+ // @ts-expect-error
103
+ const requiredObject = object.required({ age: true, country: false });
104
+ expect(requiredObject.shape.name).toBeInstanceOf(z.ZodString);
105
+ expect(requiredObject.shape.age).toBeInstanceOf(z.ZodNonOptional);
106
+ expect(requiredObject.shape.field).toBeInstanceOf(z.ZodDefault);
107
+ expect(requiredObject.shape.country).toBeInstanceOf(z.ZodOptional);
108
+ });
109
+
110
+ test("partial with mask", async () => {
111
+ const object = z.object({
112
+ name: z.string(),
113
+ age: z.number().optional(),
114
+ field: z.string().optional().default("asdf"),
115
+ country: z.string(),
116
+ });
117
+
118
+ const masked = object.partial({ age: true, field: true, name: true }).strict();
119
+
120
+ expect(masked.shape.name).toBeInstanceOf(z.ZodOptional);
121
+ expect(masked.shape.age).toBeInstanceOf(z.ZodOptional);
122
+ expect(masked.shape.field).toBeInstanceOf(z.ZodOptional);
123
+ expect(masked.shape.country).toBeInstanceOf(z.ZodString);
124
+
125
+ masked.parse({ country: "US" });
126
+ await masked.parseAsync({ country: "US" });
127
+ });
128
+
129
+ test("partial with mask -- ignore falsy values", async () => {
130
+ const object = z.object({
131
+ name: z.string(),
132
+ age: z.number().optional(),
133
+ field: z.string().optional().default("asdf"),
134
+ country: z.string(),
135
+ });
136
+
137
+ // @ts-expect-error
138
+ const masked = object.partial({ name: true, country: false }).strict();
139
+
140
+ expect(masked.shape.name).toBeInstanceOf(z.ZodOptional);
141
+ expect(masked.shape.age).toBeInstanceOf(z.ZodOptional);
142
+ expect(masked.shape.field).toBeInstanceOf(z.ZodDefault);
143
+ expect(masked.shape.country).toBeInstanceOf(z.ZodString);
144
+
145
+ masked.parse({ country: "US" });
146
+ await masked.parseAsync({ country: "US" });
147
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/pickomit.test.ts ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+
4
+ const fish = z.object({
5
+ name: z.string(),
6
+ age: z.number(),
7
+ nested: z.object({}),
8
+ });
9
+
10
+ test("pick type inference", () => {
11
+ const nameonlyFish = fish.pick({ name: true });
12
+ type nameonlyFish = z.infer<typeof nameonlyFish>;
13
+ expectTypeOf<nameonlyFish>().toEqualTypeOf<{ name: string }>();
14
+ });
15
+
16
+ test("pick parse - success", () => {
17
+ const nameonlyFish = fish.pick({ name: true });
18
+ nameonlyFish.parse({ name: "bob" });
19
+
20
+ // @ts-expect-error checking runtime picks `name` only.
21
+ const anotherNameonlyFish = fish.pick({ name: true, age: false });
22
+ anotherNameonlyFish.parse({ name: "bob" });
23
+ });
24
+
25
+ test("pick parse - fail", () => {
26
+ fish.pick({ name: true }).parse({ name: "12" } as any);
27
+ fish.pick({ name: true }).parse({ name: "bob", age: 12 } as any);
28
+ fish.pick({ age: true }).parse({ age: 12 } as any);
29
+
30
+ const nameonlyFish = fish.pick({ name: true }).strict();
31
+ const bad1 = () => nameonlyFish.parse({ name: 12 } as any);
32
+ const bad2 = () => nameonlyFish.parse({ name: "bob", age: 12 } as any);
33
+ const bad3 = () => nameonlyFish.parse({ age: 12 } as any);
34
+
35
+ // @ts-expect-error checking runtime picks `name` only.
36
+ const anotherNameonlyFish = fish.pick({ name: true, age: false }).strict();
37
+ const bad4 = () => anotherNameonlyFish.parse({ name: "bob", age: 12 } as any);
38
+
39
+ expect(bad1).toThrow();
40
+ expect(bad2).toThrow();
41
+ expect(bad3).toThrow();
42
+ expect(bad4).toThrow();
43
+ });
44
+
45
+ test("pick - remove optional", () => {
46
+ const schema = z.object({ a: z.string(), b: z.string().optional() });
47
+ expect("a" in schema._zod.def.shape).toEqual(true);
48
+ expect("b" in schema._zod.def.shape!).toEqual(true);
49
+ const picked = schema.pick({ a: true });
50
+ expect("a" in picked._zod.def.shape).toEqual(true);
51
+ expect("b" in picked._zod.def.shape!).toEqual(false);
52
+ });
53
+
54
+ test("omit type inference", () => {
55
+ const nonameFish = fish.omit({ name: true });
56
+ type nonameFish = z.infer<typeof nonameFish>;
57
+
58
+ expectTypeOf<nonameFish>().toEqualTypeOf<{ age: number; nested: Record<string, never> }>();
59
+ });
60
+
61
+ test("omit parse - success", () => {
62
+ const nonameFish = fish.omit({ name: true });
63
+ nonameFish.parse({ age: 12, nested: {} });
64
+
65
+ // @ts-expect-error checking runtime omits `name` only.
66
+ const anotherNonameFish = fish.omit({ name: true, age: false });
67
+ anotherNonameFish.parse({ age: 12, nested: {} });
68
+ });
69
+
70
+ test("omit parse - fail", () => {
71
+ const nonameFish = fish.omit({ name: true });
72
+ const bad1 = () => nonameFish.parse({ name: 12 } as any);
73
+ const bad2 = () => nonameFish.parse({ age: 12 } as any);
74
+ const bad3 = () => nonameFish.parse({} as any);
75
+
76
+ // @ts-expect-error checking runtime omits `name` only.
77
+ const anotherNonameFish = fish.omit({ name: true, age: false });
78
+ const bad4 = () => anotherNonameFish.parse({ nested: {} } as any);
79
+
80
+ expect(bad1).toThrow();
81
+ expect(bad2).toThrow();
82
+ expect(bad3).toThrow();
83
+ expect(bad4).toThrow();
84
+ });
85
+
86
+ test("omit - remove optional", () => {
87
+ const schema = z.object({ a: z.string(), b: z.string().optional() });
88
+ expect("a" in schema._zod.def.shape).toEqual(true);
89
+ const omitted = schema.omit({ a: true });
90
+ expect("a" in omitted._zod.def.shape).toEqual(false);
91
+ });
92
+
93
+ test("nonstrict inference", () => {
94
+ const laxfish = fish.pick({ name: true }).catchall(z.any());
95
+ type laxfish = z.infer<typeof laxfish>;
96
+ expectTypeOf<laxfish>().toEqualTypeOf<{ name: string; [k: string]: any }>();
97
+ });
98
+
99
+ test("nonstrict parsing - pass", () => {
100
+ const laxfish = fish.passthrough().pick({ name: true });
101
+ laxfish.parse({ name: "asdf", whatever: "asdf" });
102
+ laxfish.parse({ name: "asdf", age: 12, nested: {} });
103
+ });
104
+
105
+ test("nonstrict parsing - fail", () => {
106
+ const laxfish = fish.passthrough().pick({ name: true });
107
+ const bad = () => laxfish.parse({ whatever: "asdf" } as any);
108
+ expect(bad).toThrow();
109
+ });
110
+
111
+ test("pick/omit/required/partial - do not allow unknown keys", () => {
112
+ const schema = z.object({
113
+ name: z.string(),
114
+ age: z.number(),
115
+ });
116
+
117
+ expect(() => schema.pick({ name: true, asdf: true })).toThrow();
118
+
119
+ // @ts-expect-error
120
+ expect(() => schema.pick({ $unknown: true })).toThrow();
121
+ // @ts-expect-error
122
+ expect(() => schema.omit({ $unknown: true })).toThrow();
123
+ // @ts-expect-error
124
+ expect(() => schema.required({ $unknown: true })).toThrow();
125
+ // @ts-expect-error
126
+ expect(() => schema.partial({ $unknown: true })).toThrow();
127
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/pipe.test.ts ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, test } from "vitest";
2
+
3
+ import * as z from "zod/v4";
4
+
5
+ test("string to number pipe", () => {
6
+ const schema = z.string().transform(Number).pipe(z.number());
7
+ expect(schema.parse("1234")).toEqual(1234);
8
+ });
9
+
10
+ test("string to number pipe async", async () => {
11
+ const schema = z
12
+ .string()
13
+ .transform(async (val) => Number(val))
14
+ .pipe(z.number());
15
+ expect(await schema.parseAsync("1234")).toEqual(1234);
16
+ });
17
+
18
+ test("string with default fallback", () => {
19
+ const stringWithDefault = z
20
+ .pipe(
21
+ z.transform((v) => (v === "none" ? undefined : v)),
22
+ z.string()
23
+ )
24
+ .catch("default");
25
+
26
+ expect(stringWithDefault.parse("ok")).toBe("ok");
27
+ expect(stringWithDefault.parse(undefined)).toBe("default");
28
+ expect(stringWithDefault.parse("none")).toBe("default");
29
+ expect(stringWithDefault.parse(15)).toBe("default");
30
+ });
31
+
32
+ test("continue on non-fatal errors", () => {
33
+ const schema = z
34
+ .string()
35
+ .refine((c) => c === "1234", "A")
36
+ .transform((val) => Number(val))
37
+ .refine((c) => c === 1234, "B");
38
+
39
+ schema.parse("1234");
40
+
41
+ expect(schema.safeParse("4321")).toMatchInlineSnapshot(`
42
+ {
43
+ "error": [ZodError: [
44
+ {
45
+ "code": "custom",
46
+ "path": [],
47
+ "message": "A"
48
+ },
49
+ {
50
+ "code": "custom",
51
+ "path": [],
52
+ "message": "B"
53
+ }
54
+ ]],
55
+ "success": false,
56
+ }
57
+ `);
58
+ });
59
+
60
+ test("break on fatal errors", () => {
61
+ const schema = z
62
+ .string()
63
+ .refine((c) => c === "1234", { message: "A", abort: true })
64
+ .transform((val) => Number(val))
65
+ .refine((c) => c === 1234, "B");
66
+
67
+ schema.parse("1234");
68
+
69
+ expect(schema.safeParse("4321")).toMatchInlineSnapshot(`
70
+ {
71
+ "error": [ZodError: [
72
+ {
73
+ "code": "custom",
74
+ "path": [],
75
+ "message": "A"
76
+ }
77
+ ]],
78
+ "success": false,
79
+ }
80
+ `);
81
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/prefault.test.ts ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+ import { z } from "zod/v4";
3
+
4
+ test("basic prefault", () => {
5
+ const a = z.prefault(z.string().trim(), " default ");
6
+ expect(a).toBeInstanceOf(z.ZodPrefault);
7
+ expect(a.parse(" asdf ")).toEqual("asdf");
8
+ expect(a.parse(undefined)).toEqual("default");
9
+
10
+ type inp = z.input<typeof a>;
11
+ expectTypeOf<inp>().toEqualTypeOf<string | undefined>();
12
+ type out = z.output<typeof a>;
13
+ expectTypeOf<out>().toEqualTypeOf<string>();
14
+ });
15
+
16
+ test("prefault inside object", () => {
17
+ // test optinality
18
+ const a = z.object({
19
+ name: z.string().optional(),
20
+ age: z.number().default(1234),
21
+ email: z.string().prefault("1234"),
22
+ });
23
+
24
+ type inp = z.input<typeof a>;
25
+ expectTypeOf<inp>().toEqualTypeOf<{
26
+ name?: string | undefined;
27
+ age?: number | undefined;
28
+ email?: string | undefined;
29
+ }>();
30
+
31
+ type out = z.output<typeof a>;
32
+ expectTypeOf<out>().toEqualTypeOf<{
33
+ name?: string | undefined;
34
+ age: number;
35
+ email: string;
36
+ }>();
37
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/preprocess.test.ts ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+
4
+ test("preprocess", () => {
5
+ const schema = z.preprocess((data) => [data], z.string().array());
6
+ const value = schema.parse("asdf");
7
+ expect(value).toEqual(["asdf"]);
8
+ expectTypeOf<(typeof schema)["_input"]>().toEqualTypeOf<unknown>();
9
+ });
10
+
11
+ test("async preprocess", async () => {
12
+ const schema = z.preprocess(async (data) => {
13
+ return [data];
14
+ }, z.string().array());
15
+ const value = await schema.safeParseAsync("asdf");
16
+ expect(value.data).toEqual(["asdf"]);
17
+ expect(value).toMatchInlineSnapshot(`
18
+ {
19
+ "data": [
20
+ "asdf",
21
+ ],
22
+ "success": true,
23
+ }
24
+ `);
25
+ });
26
+
27
+ test("ctx.addIssue accepts string", () => {
28
+ const schema = z.preprocess((_, ctx) => {
29
+ ctx.addIssue("bad stuff");
30
+ }, z.string());
31
+ const result = schema.safeParse("asdf");
32
+ expect(result.error!.issues).toHaveLength(1);
33
+ expect(result).toMatchInlineSnapshot(`
34
+ {
35
+ "error": [ZodError: [
36
+ {
37
+ "message": "bad stuff",
38
+ "code": "custom",
39
+ "path": []
40
+ }
41
+ ]],
42
+ "success": false,
43
+ }
44
+ `);
45
+ });
46
+
47
+ test("preprocess ctx.addIssue with parse", () => {
48
+ const a = z.preprocess((data, ctx) => {
49
+ ctx.addIssue({
50
+ input: data,
51
+ code: "custom",
52
+ message: `${data} is not one of our allowed strings`,
53
+ });
54
+ return data;
55
+ }, z.string());
56
+
57
+ const result = a.safeParse("asdf");
58
+
59
+ // expect(result.error!.toJSON()).toContain("not one of our allowed strings");
60
+
61
+ expect(result.error!.issues).toHaveLength(1);
62
+ expect(result).toMatchInlineSnapshot(`
63
+ {
64
+ "error": [ZodError: [
65
+ {
66
+ "code": "custom",
67
+ "message": "asdf is not one of our allowed strings",
68
+ "path": []
69
+ }
70
+ ]],
71
+ "success": false,
72
+ }
73
+ `);
74
+ });
75
+
76
+ test("preprocess ctx.addIssue non-fatal by default", () => {
77
+ const schema = z.preprocess((data, ctx) => {
78
+ ctx.addIssue({
79
+ code: "custom",
80
+ message: `custom error`,
81
+ });
82
+ return data;
83
+ }, z.string());
84
+ const result = schema.safeParse(1234);
85
+
86
+ expect(result.error!.issues).toHaveLength(2);
87
+ expect(result).toMatchInlineSnapshot(`
88
+ {
89
+ "error": [ZodError: [
90
+ {
91
+ "code": "custom",
92
+ "message": "custom error",
93
+ "path": []
94
+ },
95
+ {
96
+ "expected": "string",
97
+ "code": "invalid_type",
98
+ "path": [],
99
+ "message": "Invalid input: expected string, received number"
100
+ }
101
+ ]],
102
+ "success": false,
103
+ }
104
+ `);
105
+ });
106
+
107
+ test("preprocess ctx.addIssue fatal true", () => {
108
+ const schema = z.preprocess((data, ctx) => {
109
+ ctx.addIssue({
110
+ input: data,
111
+ code: "custom",
112
+ origin: "custom",
113
+ message: `custom error`,
114
+ fatal: true,
115
+ });
116
+ return data;
117
+ }, z.string());
118
+
119
+ const result = schema.safeParse(1234);
120
+
121
+ expect(result.error!.issues).toHaveLength(1);
122
+ expect(result).toMatchInlineSnapshot(`
123
+ {
124
+ "error": [ZodError: [
125
+ {
126
+ "code": "custom",
127
+ "origin": "custom",
128
+ "message": "custom error",
129
+ "fatal": true,
130
+ "path": []
131
+ }
132
+ ]],
133
+ "success": false,
134
+ }
135
+ `);
136
+ });
137
+
138
+ test("async preprocess ctx.addIssue with parseAsync", async () => {
139
+ const schema = z.preprocess(async (data, ctx) => {
140
+ ctx.addIssue({
141
+ input: data,
142
+ code: "custom",
143
+ message: `${data} is not one of our allowed strings`,
144
+ });
145
+ return data;
146
+ }, z.string());
147
+
148
+ const result = await schema.safeParseAsync("asdf");
149
+
150
+ expect(result.error!.issues).toHaveLength(1);
151
+ expect(result).toMatchInlineSnapshot(`
152
+ {
153
+ "error": [ZodError: [
154
+ {
155
+ "code": "custom",
156
+ "message": "asdf is not one of our allowed strings",
157
+ "path": []
158
+ }
159
+ ]],
160
+ "success": false,
161
+ }
162
+ `);
163
+ });
164
+
165
+ test("z.NEVER in preprocess", () => {
166
+ const foo = z.preprocess((val, ctx) => {
167
+ if (!val) {
168
+ ctx.addIssue({ input: val, code: "custom", message: "bad" });
169
+ return z.NEVER;
170
+ }
171
+ return val;
172
+ }, z.number());
173
+
174
+ type foo = z.infer<typeof foo>;
175
+ expectTypeOf<foo>().toEqualTypeOf<number>();
176
+ const result = foo.safeParse(undefined);
177
+
178
+ expect(result.error!.issues).toHaveLength(2);
179
+ expect(result).toMatchInlineSnapshot(`
180
+ {
181
+ "error": [ZodError: [
182
+ {
183
+ "code": "custom",
184
+ "message": "bad",
185
+ "path": []
186
+ },
187
+ {
188
+ "expected": "number",
189
+ "code": "invalid_type",
190
+ "path": [],
191
+ "message": "Invalid input: expected number, received object"
192
+ }
193
+ ]],
194
+ "success": false,
195
+ }
196
+ `);
197
+ });
198
+
199
+ test("preprocess as the second property of object", () => {
200
+ const schema = z.object({
201
+ nonEmptyStr: z.string().min(1),
202
+ positiveNum: z.preprocess((v) => Number(v), z.number().positive()),
203
+ });
204
+ const result = schema.safeParse({
205
+ nonEmptyStr: "",
206
+ positiveNum: "",
207
+ });
208
+
209
+ expect(result.error!.issues).toHaveLength(2);
210
+ expect(result).toMatchInlineSnapshot(`
211
+ {
212
+ "error": [ZodError: [
213
+ {
214
+ "origin": "string",
215
+ "code": "too_small",
216
+ "minimum": 1,
217
+ "inclusive": true,
218
+ "path": [
219
+ "nonEmptyStr"
220
+ ],
221
+ "message": "Too small: expected string to have >=1 characters"
222
+ },
223
+ {
224
+ "origin": "number",
225
+ "code": "too_small",
226
+ "minimum": 0,
227
+ "inclusive": false,
228
+ "path": [
229
+ "positiveNum"
230
+ ],
231
+ "message": "Too small: expected number to be >0"
232
+ }
233
+ ]],
234
+ "success": false,
235
+ }
236
+ `);
237
+ });
238
+
239
+ test("preprocess validates with sibling errors", () => {
240
+ const schema = z.object({
241
+ missing: z.string().refine(() => false),
242
+ preprocess: z.preprocess((data: any) => data?.trim(), z.string().regex(/ asdf/)),
243
+ });
244
+
245
+ const result = schema.safeParse({ preprocess: " asdf" });
246
+
247
+ expect(result.error!.issues).toHaveLength(2);
248
+ expect(result).toMatchInlineSnapshot(`
249
+ {
250
+ "error": [ZodError: [
251
+ {
252
+ "expected": "string",
253
+ "code": "invalid_type",
254
+ "path": [
255
+ "missing"
256
+ ],
257
+ "message": "Invalid input: expected string, received undefined"
258
+ },
259
+ {
260
+ "origin": "string",
261
+ "code": "invalid_format",
262
+ "format": "regex",
263
+ "pattern": "/ asdf/",
264
+ "path": [
265
+ "preprocess"
266
+ ],
267
+ "message": "Invalid string: must match pattern / asdf/"
268
+ }
269
+ ]],
270
+ "success": false,
271
+ }
272
+ `);
273
+ });
274
+
275
+ test("perform transform with non-fatal issues", () => {
276
+ const A = z
277
+ .string()
278
+ .refine((_) => false)
279
+ .min(4)
280
+ .transform((val) => val.length)
281
+ .pipe(z.number())
282
+ .refine((_) => false);
283
+ expect(A.safeParse("asdfasdf").error!.issues).toHaveLength(2);
284
+ expect(A.safeParse("asdfasdf").error).toMatchInlineSnapshot(`
285
+ [ZodError: [
286
+ {
287
+ "code": "custom",
288
+ "path": [],
289
+ "message": "Invalid input"
290
+ },
291
+ {
292
+ "code": "custom",
293
+ "path": [],
294
+ "message": "Invalid input"
295
+ }
296
+ ]]
297
+ `);
298
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/primitive.test.ts ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+
4
+ const literalStringSchema = z.literal("asdf");
5
+ const literalNumberSchema = z.literal(12);
6
+ const literalBooleanSchema = z.literal(true);
7
+ const literalBigIntSchema = z.literal(BigInt(42));
8
+
9
+ const stringSchema = z.string();
10
+ const numberSchema = z.number();
11
+ const bigintSchema = z.bigint();
12
+ const booleanSchema = z.boolean();
13
+ const dateSchema = z.date();
14
+ const symbolSchema = z.symbol();
15
+ const nullSchema = z.null();
16
+ const undefinedSchema = z.undefined();
17
+ const stringSchemaOptional = z.string().optional();
18
+ const stringSchemaNullable = z.string().nullable();
19
+ const numberSchemaOptional = z.number().optional();
20
+ const numberSchemaNullable = z.number().nullable();
21
+ const bigintSchemaOptional = z.bigint().optional();
22
+ const bigintSchemaNullable = z.bigint().nullable();
23
+ const booleanSchemaOptional = z.boolean().optional();
24
+ const booleanSchemaNullable = z.boolean().nullable();
25
+ const dateSchemaOptional = z.date().optional();
26
+ const dateSchemaNullable = z.date().nullable();
27
+ const symbolSchemaOptional = z.symbol().optional();
28
+ const symbolSchemaNullable = z.symbol().nullable();
29
+
30
+ test("literal string schema", () => {
31
+ expect(literalStringSchema.parse("asdf")).toBe("asdf");
32
+ expect(() => literalStringSchema.parse("not_asdf")).toThrow();
33
+ expect(() => literalStringSchema.parse(123)).toThrow();
34
+ expect(() => literalStringSchema.parse(true)).toThrow();
35
+ expect(() => literalStringSchema.parse({})).toThrow();
36
+ });
37
+
38
+ test("literal number schema", () => {
39
+ expect(literalNumberSchema.parse(12)).toBe(12);
40
+ expect(() => literalNumberSchema.parse(13)).toThrow();
41
+ expect(() => literalNumberSchema.parse("foo")).toThrow();
42
+ expect(() => literalNumberSchema.parse(true)).toThrow();
43
+ expect(() => literalNumberSchema.parse({})).toThrow();
44
+ });
45
+
46
+ test("literal boolean schema", () => {
47
+ expect(literalBooleanSchema.parse(true)).toBe(true);
48
+ expect(() => literalBooleanSchema.parse(false)).toThrow();
49
+ expect(() => literalBooleanSchema.parse("asdf")).toThrow();
50
+ expect(() => literalBooleanSchema.parse(123)).toThrow();
51
+ expect(() => literalBooleanSchema.parse({})).toThrow();
52
+ });
53
+
54
+ test("literal bigint schema", () => {
55
+ expect(literalBigIntSchema.parse(BigInt(42))).toBe(BigInt(42));
56
+ expect(() => literalBigIntSchema.parse(BigInt(43))).toThrow();
57
+ expect(() => literalBigIntSchema.parse("asdf")).toThrow();
58
+ expect(() => literalBigIntSchema.parse(123)).toThrow();
59
+ expect(() => literalBigIntSchema.parse({})).toThrow();
60
+ });
61
+
62
+ test("string schema", () => {
63
+ stringSchema.parse("foo");
64
+ expect(() => stringSchema.parse(Math.random())).toThrow();
65
+ expect(() => stringSchema.parse(true)).toThrow();
66
+ expect(() => stringSchema.parse(undefined)).toThrow();
67
+ expect(() => stringSchema.parse(null)).toThrow();
68
+ });
69
+
70
+ test("number schema", () => {
71
+ numberSchema.parse(Math.random());
72
+ expect(() => numberSchema.parse("foo")).toThrow();
73
+ expect(() => numberSchema.parse(BigInt(17))).toThrow();
74
+ expect(() => numberSchema.parse(true)).toThrow();
75
+ expect(() => numberSchema.parse(undefined)).toThrow();
76
+ expect(() => numberSchema.parse(null)).toThrow();
77
+ });
78
+
79
+ test("bigint schema", () => {
80
+ bigintSchema.parse(BigInt(17));
81
+ expect(() => bigintSchema.parse("foo")).toThrow();
82
+ expect(() => bigintSchema.parse(Math.random())).toThrow();
83
+ expect(() => bigintSchema.parse(true)).toThrow();
84
+ expect(() => bigintSchema.parse(undefined)).toThrow();
85
+ expect(() => bigintSchema.parse(null)).toThrow();
86
+ });
87
+
88
+ test("boolean schema", () => {
89
+ booleanSchema.parse(true);
90
+ expect(() => booleanSchema.parse("foo")).toThrow();
91
+ expect(() => booleanSchema.parse(Math.random())).toThrow();
92
+ expect(() => booleanSchema.parse(undefined)).toThrow();
93
+ expect(() => booleanSchema.parse(null)).toThrow();
94
+ });
95
+
96
+ test("date schema", async () => {
97
+ dateSchema.parse(new Date());
98
+ expect(() => dateSchema.parse("foo")).toThrow();
99
+ expect(() => dateSchema.parse(Math.random())).toThrow();
100
+ expect(() => dateSchema.parse(true)).toThrow();
101
+ expect(() => dateSchema.parse(undefined)).toThrow();
102
+ expect(() => dateSchema.parse(null)).toThrow();
103
+ expect(await dateSchema.safeParseAsync(new Date("invalid"))).toMatchInlineSnapshot(`
104
+ {
105
+ "error": [ZodError: [
106
+ {
107
+ "expected": "date",
108
+ "code": "invalid_type",
109
+ "received": "Invalid Date",
110
+ "path": [],
111
+ "message": "Invalid input: expected date, received Date"
112
+ }
113
+ ]],
114
+ "success": false,
115
+ }
116
+ `);
117
+ });
118
+
119
+ test("symbol schema", () => {
120
+ symbolSchema.parse(Symbol("foo"));
121
+ expect(() => symbolSchema.parse("foo")).toThrow();
122
+ expect(() => symbolSchema.parse(Math.random())).toThrow();
123
+ expect(() => symbolSchema.parse(true)).toThrow();
124
+ expect(() => symbolSchema.parse(new Date())).toThrow();
125
+ expect(() => symbolSchema.parse(undefined)).toThrow();
126
+ expect(() => symbolSchema.parse(null)).toThrow();
127
+ });
128
+
129
+ test("undefined schema", () => {
130
+ undefinedSchema.parse(undefined);
131
+ expect(() => undefinedSchema.parse("foo")).toThrow();
132
+ expect(() => undefinedSchema.parse(Math.random())).toThrow();
133
+ expect(() => undefinedSchema.parse(true)).toThrow();
134
+ expect(() => undefinedSchema.parse(null)).toThrow();
135
+ });
136
+
137
+ test("null schema", () => {
138
+ nullSchema.parse(null);
139
+ expect(() => nullSchema.parse("foo")).toThrow();
140
+ expect(() => nullSchema.parse(Math.random())).toThrow();
141
+ expect(() => nullSchema.parse(true)).toThrow();
142
+ expect(() => nullSchema.parse(undefined)).toThrow();
143
+ });
144
+
145
+ test("primitive inference", () => {
146
+ expectTypeOf<z.TypeOf<typeof literalStringSchema>>().toEqualTypeOf<"asdf">();
147
+ expectTypeOf<z.TypeOf<typeof literalNumberSchema>>().toEqualTypeOf<12>();
148
+ expectTypeOf<z.TypeOf<typeof literalBooleanSchema>>().toEqualTypeOf<true>();
149
+ expectTypeOf<z.TypeOf<typeof literalBigIntSchema>>().toEqualTypeOf<bigint>();
150
+ expectTypeOf<z.TypeOf<typeof stringSchema>>().toEqualTypeOf<string>();
151
+ expectTypeOf<z.TypeOf<typeof numberSchema>>().toEqualTypeOf<number>();
152
+ expectTypeOf<z.TypeOf<typeof bigintSchema>>().toEqualTypeOf<bigint>();
153
+ expectTypeOf<z.TypeOf<typeof booleanSchema>>().toEqualTypeOf<boolean>();
154
+ expectTypeOf<z.TypeOf<typeof dateSchema>>().toEqualTypeOf<Date>();
155
+ expectTypeOf<z.TypeOf<typeof symbolSchema>>().toEqualTypeOf<symbol>();
156
+ expectTypeOf<z.TypeOf<typeof nullSchema>>().toEqualTypeOf<null>();
157
+ expectTypeOf<z.TypeOf<typeof undefinedSchema>>().toEqualTypeOf<undefined>();
158
+ expectTypeOf<z.TypeOf<typeof stringSchemaOptional>>().toEqualTypeOf<string | undefined>();
159
+ expectTypeOf<z.TypeOf<typeof stringSchemaNullable>>().toEqualTypeOf<string | null>();
160
+ expectTypeOf<z.TypeOf<typeof numberSchemaOptional>>().toEqualTypeOf<number | undefined>();
161
+ expectTypeOf<z.TypeOf<typeof numberSchemaNullable>>().toEqualTypeOf<number | null>();
162
+ expectTypeOf<z.TypeOf<typeof bigintSchemaOptional>>().toEqualTypeOf<bigint | undefined>();
163
+ expectTypeOf<z.TypeOf<typeof bigintSchemaNullable>>().toEqualTypeOf<bigint | null>();
164
+ expectTypeOf<z.TypeOf<typeof booleanSchemaOptional>>().toEqualTypeOf<boolean | undefined>();
165
+ expectTypeOf<z.TypeOf<typeof booleanSchemaNullable>>().toEqualTypeOf<boolean | null>();
166
+ expectTypeOf<z.TypeOf<typeof dateSchemaOptional>>().toEqualTypeOf<Date | undefined>();
167
+ expectTypeOf<z.TypeOf<typeof dateSchemaNullable>>().toEqualTypeOf<Date | null>();
168
+ expectTypeOf<z.TypeOf<typeof symbolSchemaOptional>>().toEqualTypeOf<symbol | undefined>();
169
+ expectTypeOf<z.TypeOf<typeof symbolSchemaNullable>>().toEqualTypeOf<symbol | null>();
170
+ });
171
+
172
+ test("get literal values", () => {
173
+ expect(literalStringSchema.values).toEqual(new Set(["asdf"]));
174
+ expect(literalStringSchema._zod.def.values).toEqual(["asdf"]);
175
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/promise.test.ts ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+
4
+ const promSchema = z.promise(
5
+ z.object({
6
+ name: z.string(),
7
+ age: z.number(),
8
+ })
9
+ );
10
+
11
+ test("promise inference", () => {
12
+ type promSchemaType = z.infer<typeof promSchema>;
13
+ expectTypeOf<promSchemaType>().toEqualTypeOf<{ name: string; age: number }>();
14
+ });
15
+
16
+ test("promise parsing success", async () => {
17
+ // expect(() => promSchema.parse(Promise.resolve({ name: "Bobby", age: 10 }))).toThrow();
18
+ const pr = promSchema.parseAsync(Promise.resolve({ name: "Bobby", age: 10 }));
19
+ expect(pr).toBeInstanceOf(Promise);
20
+ const result = await pr;
21
+ expect(result).toMatchInlineSnapshot(`
22
+ {
23
+ "age": 10,
24
+ "name": "Bobby",
25
+ }
26
+ `);
27
+ });
28
+
29
+ test("promise parsing fail", async () => {
30
+ const bad = await promSchema.safeParseAsync(Promise.resolve({ name: "Bobby", age: "10" }));
31
+ expect(bad.success).toBe(false);
32
+ expect(bad.error).toBeInstanceOf(z.ZodError);
33
+ });
34
+
35
+ test("promise parsing fail 2", async () => {
36
+ const result = await promSchema.safeParseAsync(Promise.resolve({ name: "Bobby", age: "10" }));
37
+ expect(result.success).toBe(false);
38
+ expect(result.error).toBeInstanceOf(z.ZodError);
39
+ });
40
+
41
+ test("promise parsing fail", () => {
42
+ const bad = () => promSchema.parse({ then: () => {}, catch: {} });
43
+ expect(bad).toThrow();
44
+ });
45
+
46
+ test("sync promise parsing", () => {
47
+ expect(() => z.promise(z.string()).parse(Promise.resolve("asfd"))).toThrow();
48
+ });
49
+
50
+ const asyncFunction = z.function({
51
+ input: z.tuple([]),
52
+ output: promSchema,
53
+ });
54
+
55
+ test("async function pass", async () => {
56
+ const validatedFunction = asyncFunction.implementAsync(async () => {
57
+ return { name: "jimmy", age: 14 };
58
+ });
59
+ await expect(validatedFunction()).resolves.toEqual({
60
+ name: "jimmy",
61
+ age: 14,
62
+ });
63
+ });
64
+
65
+ test("async function fail", async () => {
66
+ const validatedFunction = asyncFunction.implementAsync(() => {
67
+ return Promise.resolve("asdf" as any);
68
+ });
69
+ await expect(validatedFunction()).rejects.toBeInstanceOf(z.core.$ZodError);
70
+ });
71
+
72
+ test("async promise parsing", () => {
73
+ const res = z.promise(z.number()).parseAsync(Promise.resolve(12));
74
+ expect(res).toBeInstanceOf(Promise);
75
+ });
76
+
77
+ test("resolves", () => {
78
+ const foo = z.literal("foo");
79
+ const res = z.promise(foo);
80
+ expect(res.unwrap()).toEqual(foo);
81
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/prototypes.test.ts ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+
4
+ declare module "zod/v4" {
5
+ interface ZodType {
6
+ /** @deprecated */
7
+ _classic(): string;
8
+ }
9
+ }
10
+
11
+ test("prototype extension", () => {
12
+ z.ZodType.prototype._classic = function () {
13
+ return "_classic";
14
+ };
15
+
16
+ // should pass
17
+ const result = z.string()._classic();
18
+ expect(result).toBe("_classic");
19
+ // expectTypeOf<typeof result>().toEqualTypeOf<string>();
20
+
21
+ // clean up
22
+ z.ZodType.prototype._classic = undefined;
23
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/readonly.test.ts ADDED
@@ -0,0 +1,252 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+
4
+ enum testEnum {
5
+ A = 0,
6
+ B = 1,
7
+ }
8
+
9
+ test("flat inference", () => {
10
+ const readonlyString = z.string().readonly();
11
+ const readonlyNumber = z.number().readonly();
12
+ const readonlyNaN = z.nan().readonly();
13
+ const readonlyBigInt = z.bigint().readonly();
14
+ const readonlyBoolean = z.boolean().readonly();
15
+ const readonlyDate = z.date().readonly();
16
+ const readonlyUndefined = z.undefined().readonly();
17
+ const readonlyNull = z.null().readonly();
18
+ const readonlyAny = z.any().readonly();
19
+ const readonlyUnknown = z.unknown().readonly();
20
+ const readonlyVoid = z.void().readonly();
21
+ const readonlyStringArray = z.array(z.string()).readonly();
22
+ const readonlyTuple = z.tuple([z.string(), z.number()]).readonly();
23
+ const readonlyMap = z.map(z.string(), z.date()).readonly();
24
+ const readonlySet = z.set(z.string()).readonly();
25
+ const readonlyStringRecord = z.record(z.string(), z.string()).readonly();
26
+ const readonlyNumberRecord = z.record(z.string(), z.number()).readonly();
27
+ const readonlyObject = z.object({ a: z.string(), 1: z.number() }).readonly();
28
+ const readonlyEnum = z.nativeEnum(testEnum).readonly();
29
+ const readonlyPromise = z.promise(z.string()).readonly();
30
+
31
+ expectTypeOf<typeof readonlyString._output>().toEqualTypeOf<string>();
32
+ expectTypeOf<typeof readonlyNumber._output>().toEqualTypeOf<number>();
33
+ expectTypeOf<typeof readonlyNaN._output>().toEqualTypeOf<number>();
34
+ expectTypeOf<typeof readonlyBigInt._output>().toEqualTypeOf<bigint>();
35
+ expectTypeOf<typeof readonlyBoolean._output>().toEqualTypeOf<boolean>();
36
+ expectTypeOf<typeof readonlyDate._output>().toEqualTypeOf<Date>();
37
+ expectTypeOf<typeof readonlyUndefined._output>().toEqualTypeOf<undefined>();
38
+ expectTypeOf<typeof readonlyNull._output>().toEqualTypeOf<null>();
39
+ expectTypeOf<typeof readonlyAny._output>().toEqualTypeOf<any>();
40
+ expectTypeOf<typeof readonlyUnknown._output>().toEqualTypeOf<Readonly<unknown>>();
41
+ expectTypeOf<typeof readonlyVoid._output>().toEqualTypeOf<void>();
42
+ expectTypeOf<typeof readonlyStringArray._output>().toEqualTypeOf<readonly string[]>();
43
+ expectTypeOf<typeof readonlyTuple._output>().toEqualTypeOf<readonly [string, number]>();
44
+ expectTypeOf<typeof readonlyMap._output>().toEqualTypeOf<ReadonlyMap<string, Date>>();
45
+ expectTypeOf<typeof readonlySet._output>().toEqualTypeOf<ReadonlySet<string>>();
46
+ expectTypeOf<typeof readonlyStringRecord._output>().toEqualTypeOf<Readonly<Record<string, string>>>();
47
+ expectTypeOf<typeof readonlyNumberRecord._output>().toEqualTypeOf<Readonly<Record<string, number>>>();
48
+ expectTypeOf<typeof readonlyObject._output>().toEqualTypeOf<{ readonly a: string; readonly 1: number }>();
49
+ expectTypeOf<typeof readonlyEnum._output>().toEqualTypeOf<Readonly<testEnum>>();
50
+ expectTypeOf<typeof readonlyPromise._output>().toEqualTypeOf<string>();
51
+ });
52
+
53
+ // test("deep inference", () => {
54
+ // expectTypeOf<z.infer<(typeof deepReadonlySchemas_0)[0]>>().toEqualTypeOf<string>();
55
+ // expectTypeOf<z.infer<(typeof deepReadonlySchemas_0)[1]>>().toEqualTypeOf<number>();
56
+ // expectTypeOf<z.infer<(typeof deepReadonlySchemas_0)[2]>>().toEqualTypeOf<number>();
57
+ // expectTypeOf<z.infer<(typeof deepReadonlySchemas_0)[3]>>().toEqualTypeOf<bigint>();
58
+ // expectTypeOf<z.infer<(typeof deepReadonlySchemas_0)[4]>>().toEqualTypeOf<boolean>();
59
+ // expectTypeOf<z.infer<(typeof deepReadonlySchemas_0)[5]>>().toEqualTypeOf<Date>();
60
+ // expectTypeOf<z.infer<(typeof deepReadonlySchemas_0)[6]>>().toEqualTypeOf<undefined>();
61
+ // expectTypeOf<z.infer<(typeof deepReadonlySchemas_0)[7]>>().toEqualTypeOf<null>();
62
+ // expectTypeOf<z.infer<(typeof deepReadonlySchemas_0)[8]>>().toEqualTypeOf<any>();
63
+ // expectTypeOf<
64
+ // z.infer<(typeof deepReadonlySchemas_0)[9]>
65
+ // >().toEqualTypeOf<Readonly<unknown>>();
66
+ // expectTypeOf<z.infer<(typeof deepReadonlySchemas_0)[10]>>().toEqualTypeOf<void>();
67
+ // expectTypeOf<
68
+ // z.infer<(typeof deepReadonlySchemas_0)[11]>
69
+ // >().toEqualTypeOf<(args_0: string, args_1: number, ...args_2: unknown[]) => unknown>();
70
+ // expectTypeOf<
71
+ // z.infer<(typeof deepReadonlySchemas_0)[12]>
72
+ // >().toEqualTypeOf<readonly string[]>();
73
+ // expectTypeOf<
74
+ // z.infer<(typeof deepReadonlySchemas_0)[13]>
75
+ // >().toEqualTypeOf<readonly [string, number]>();
76
+ // expectTypeOf<
77
+ // z.infer<(typeof deepReadonlySchemas_0)[14]>
78
+ // >().toEqualTypeOf<ReadonlyMap<string, Date>>();
79
+ // expectTypeOf<
80
+ // z.infer<(typeof deepReadonlySchemas_0)[15]>
81
+ // >().toEqualTypeOf<ReadonlySet<Promise<string>>>();
82
+ // expectTypeOf<
83
+ // z.infer<(typeof deepReadonlySchemas_0)[16]>
84
+ // >().toEqualTypeOf<Readonly<Record<string, string>>>();
85
+ // expectTypeOf<
86
+ // z.infer<(typeof deepReadonlySchemas_0)[17]>
87
+ // >().toEqualTypeOf<Readonly<Record<string, number>>>();
88
+ // expectTypeOf<
89
+ // z.infer<(typeof deepReadonlySchemas_0)[18]>
90
+ // >().toEqualTypeOf<{ readonly a: string; readonly 1: number }>();
91
+ // expectTypeOf<
92
+ // z.infer<(typeof deepReadonlySchemas_0)[19]>
93
+ // >().toEqualTypeOf<Readonly<testEnum>>();
94
+ // expectTypeOf<
95
+ // z.infer<(typeof deepReadonlySchemas_0)[20]>
96
+ // >().toEqualTypeOf<Promise<string>>();
97
+
98
+ // expectTypeOf<
99
+ // z.infer<typeof crazyDeepReadonlySchema>
100
+ // >().toEqualTypeOf<ReadonlyMap<
101
+ // ReadonlySet<readonly [string, number]>,
102
+ // {
103
+ // readonly a: {
104
+ // readonly [x: string]: readonly any[];
105
+ // };
106
+ // readonly b: {
107
+ // readonly c: {
108
+ // readonly d: {
109
+ // readonly e: {
110
+ // readonly f: {
111
+ // readonly g?: {};
112
+ // };
113
+ // };
114
+ // };
115
+ // };
116
+ // };
117
+ // }
118
+ // >>();
119
+ // });
120
+
121
+ test("object freezing", async () => {
122
+ expect(Object.isFrozen(z.array(z.string()).readonly().parse(["a"]))).toBe(true);
123
+ expect(Object.isFrozen(z.tuple([z.string(), z.number()]).readonly().parse(["a", 1]))).toBe(true);
124
+ expect(
125
+ Object.isFrozen(
126
+ z
127
+ .map(z.string(), z.date())
128
+ .readonly()
129
+ .parse(new Map([["a", new Date()]]))
130
+ )
131
+ ).toBe(true);
132
+
133
+ expect(Object.isFrozen(z.record(z.string(), z.string()).readonly().parse({ a: "b" }))).toBe(true);
134
+ expect(Object.isFrozen(z.record(z.string(), z.number()).readonly().parse({ a: 1 }))).toBe(true);
135
+ expect(Object.isFrozen(z.object({ a: z.string(), 1: z.number() }).readonly().parse({ a: "b", 1: 2 }))).toBe(true);
136
+ expect(
137
+ Object.isFrozen(
138
+ await z
139
+ .set(z.promise(z.string()))
140
+ .readonly()
141
+ .parseAsync(new Set([Promise.resolve("a")]))
142
+ )
143
+ ).toBe(true);
144
+ expect(Object.isFrozen(await z.promise(z.string()).readonly().parseAsync(Promise.resolve("a")))).toBe(true);
145
+ });
146
+
147
+ test("async object freezing", async () => {
148
+ expect(Object.isFrozen(await z.array(z.string()).readonly().parseAsync(["a"]))).toBe(true);
149
+ expect(Object.isFrozen(await z.tuple([z.string(), z.number()]).readonly().parseAsync(["a", 1]))).toBe(true);
150
+ expect(
151
+ Object.isFrozen(
152
+ await z
153
+ .map(z.string(), z.date())
154
+ .readonly()
155
+ .parseAsync(new Map([["a", new Date()]]))
156
+ )
157
+ ).toBe(true);
158
+ expect(
159
+ Object.isFrozen(
160
+ await z
161
+ .set(z.promise(z.string()))
162
+ .readonly()
163
+ .parseAsync(new Set([Promise.resolve("a")]))
164
+ )
165
+ ).toBe(true);
166
+ expect(Object.isFrozen(await z.record(z.string(), z.string()).readonly().parseAsync({ a: "b" }))).toBe(true);
167
+ expect(Object.isFrozen(await z.record(z.string(), z.number()).readonly().parseAsync({ a: 1 }))).toBe(true);
168
+ expect(
169
+ Object.isFrozen(await z.object({ a: z.string(), 1: z.number() }).readonly().parseAsync({ a: "b", 1: 2 }))
170
+ ).toBe(true);
171
+ expect(Object.isFrozen(await z.promise(z.string()).readonly().parseAsync(Promise.resolve("a")))).toBe(true);
172
+ });
173
+
174
+ test("readonly inference", () => {
175
+ const readonlyStringArray = z.string().array().readonly();
176
+ const readonlyStringTuple = z.tuple([z.string()]).readonly();
177
+ const deepReadonly = z.object({ a: z.string() }).readonly();
178
+
179
+ type readonlyStringArray = z.infer<typeof readonlyStringArray>;
180
+ type readonlyStringTuple = z.infer<typeof readonlyStringTuple>;
181
+ type deepReadonly = z.infer<typeof deepReadonly>;
182
+
183
+ expectTypeOf<readonlyStringArray>().toEqualTypeOf<readonly string[]>();
184
+ expectTypeOf<readonlyStringTuple>().toEqualTypeOf<readonly [string]>();
185
+ expectTypeOf<deepReadonly>().toEqualTypeOf<{ readonly a: string }>();
186
+ });
187
+
188
+ test("readonly parse", () => {
189
+ const schema = z.array(z.string()).readonly();
190
+ const readonlyArray = ["a", "b", "c"] as const;
191
+ const mutableArray = ["a", "b", "c"];
192
+ const result1 = schema.parse(readonlyArray);
193
+ const result2 = schema.parse(mutableArray);
194
+ expect(result1).toEqual(readonlyArray);
195
+ expect(result2).toEqual(mutableArray);
196
+ });
197
+
198
+ test("readonly parse with tuples", () => {
199
+ const schema = z.tuple([z.string(), z.number()]).readonly();
200
+ schema.parse(["a", 1]);
201
+ });
202
+
203
+ test("readonly and the get method", () => {
204
+ const readonlyString = z.string().readonly();
205
+ const readonlyNumber1 = z.number().readonly();
206
+ const readonlyNumber2 = z.number().readonly();
207
+ const readonlyBigInt = z.bigint().readonly();
208
+ const readonlyBoolean = z.boolean().readonly();
209
+ const readonlyDate = z.date().readonly();
210
+ const readonlyUndefined = z.undefined().readonly();
211
+ const readonlyNull = z.null().readonly();
212
+ const readonlyAny = z.any().readonly();
213
+ const readonlyUnknown = z.unknown().readonly();
214
+ const readonlyVoid = z.void().readonly();
215
+ // const readonlyFunction = z.function(z.tuple([z.string(), z.number()]), z.unknown()).readonly();
216
+ const readonlyStringArray = z.string().array().readonly();
217
+ const readonlyTuple = z.tuple([z.string(), z.number()]).readonly();
218
+
219
+ expectTypeOf<z.infer<typeof readonlyString>>().toEqualTypeOf<string>();
220
+ expectTypeOf<z.infer<typeof readonlyNumber1>>().toEqualTypeOf<number>();
221
+ expectTypeOf<z.infer<typeof readonlyNumber2>>().toEqualTypeOf<number>();
222
+ expectTypeOf<z.infer<typeof readonlyBigInt>>().toEqualTypeOf<bigint>();
223
+ expectTypeOf<z.infer<typeof readonlyBoolean>>().toEqualTypeOf<boolean>();
224
+ expectTypeOf<z.infer<typeof readonlyDate>>().toEqualTypeOf<Date>();
225
+ expectTypeOf<z.infer<typeof readonlyUndefined>>().toEqualTypeOf<undefined>();
226
+ expectTypeOf<z.infer<typeof readonlyNull>>().toEqualTypeOf<null>();
227
+ expectTypeOf<z.infer<typeof readonlyAny>>().toEqualTypeOf<any>();
228
+ expectTypeOf<z.infer<typeof readonlyUnknown>>().toEqualTypeOf<Readonly<unknown>>();
229
+ expectTypeOf<z.infer<typeof readonlyVoid>>().toEqualTypeOf<void>();
230
+ // expectTypeOf<z.infer<typeof readonlyFunction>>().toEqualTypeOf<
231
+ // (args_0: string, args_1: number, ...args_2: unknown[]) => unknown
232
+ // >();
233
+ expectTypeOf<z.infer<typeof readonlyStringArray>>().toEqualTypeOf<readonly string[]>();
234
+ expectTypeOf<z.infer<typeof readonlyTuple>>().toEqualTypeOf<readonly [string, number]>();
235
+
236
+ expect(readonlyString.parse("asdf")).toEqual("asdf");
237
+ expect(readonlyNumber1.parse(1234)).toEqual(1234);
238
+ expect(readonlyNumber2.parse(1234)).toEqual(1234);
239
+ const bigIntVal = BigInt(1);
240
+ expect(readonlyBigInt.parse(bigIntVal)).toEqual(bigIntVal);
241
+ expect(readonlyBoolean.parse(true)).toEqual(true);
242
+ const dateVal = new Date();
243
+ expect(readonlyDate.parse(dateVal)).toEqual(dateVal);
244
+ expect(readonlyUndefined.parse(undefined)).toEqual(undefined);
245
+ expect(readonlyNull.parse(null)).toEqual(null);
246
+ expect(readonlyAny.parse("whatever")).toEqual("whatever");
247
+ expect(readonlyUnknown.parse("whatever")).toEqual("whatever");
248
+ expect(readonlyVoid.parse(undefined)).toEqual(undefined);
249
+ // expect(readonlyFunction.parse(() => void 0)).toEqual(() => void 0);
250
+ expect(readonlyStringArray.parse(["asdf"])).toEqual(["asdf"]);
251
+ expect(readonlyTuple.parse(["asdf", 1234])).toEqual(["asdf", 1234]);
252
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/record.test.ts ADDED
@@ -0,0 +1,342 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+
4
+ test("type inference", () => {
5
+ const booleanRecord = z.record(z.string(), z.boolean());
6
+ type booleanRecord = typeof booleanRecord._output;
7
+
8
+ const recordWithEnumKeys = z.record(z.enum(["Tuna", "Salmon"]), z.string());
9
+ type recordWithEnumKeys = z.infer<typeof recordWithEnumKeys>;
10
+
11
+ const recordWithLiteralKey = z.record(z.literal(["Tuna", "Salmon"]), z.string());
12
+ type recordWithLiteralKey = z.infer<typeof recordWithLiteralKey>;
13
+
14
+ const recordWithLiteralUnionKeys = z.record(z.union([z.literal("Tuna"), z.literal("Salmon")]), z.string());
15
+ type recordWithLiteralUnionKeys = z.infer<typeof recordWithLiteralUnionKeys>;
16
+
17
+ expectTypeOf<booleanRecord>().toEqualTypeOf<Record<string, boolean>>();
18
+ expectTypeOf<recordWithEnumKeys>().toEqualTypeOf<Record<"Tuna" | "Salmon", string>>();
19
+ expectTypeOf<recordWithLiteralKey>().toEqualTypeOf<Record<"Tuna" | "Salmon", string>>();
20
+ expectTypeOf<recordWithLiteralUnionKeys>().toEqualTypeOf<Record<"Tuna" | "Salmon", string>>();
21
+ });
22
+
23
+ test("enum exhaustiveness", () => {
24
+ const schema = z.record(z.enum(["Tuna", "Salmon"]), z.string());
25
+ expect(
26
+ schema.parse({
27
+ Tuna: "asdf",
28
+ Salmon: "asdf",
29
+ })
30
+ ).toEqual({
31
+ Tuna: "asdf",
32
+ Salmon: "asdf",
33
+ });
34
+
35
+ expect(schema.safeParse({ Tuna: "asdf", Salmon: "asdf", Trout: "asdf" })).toMatchInlineSnapshot(`
36
+ {
37
+ "error": [ZodError: [
38
+ {
39
+ "code": "unrecognized_keys",
40
+ "keys": [
41
+ "Trout"
42
+ ],
43
+ "path": [],
44
+ "message": "Unrecognized key: \\"Trout\\""
45
+ }
46
+ ]],
47
+ "success": false,
48
+ }
49
+ `);
50
+ expect(schema.safeParse({ Tuna: "asdf" })).toMatchInlineSnapshot(`
51
+ {
52
+ "error": [ZodError: [
53
+ {
54
+ "expected": "string",
55
+ "code": "invalid_type",
56
+ "path": [
57
+ "Salmon"
58
+ ],
59
+ "message": "Invalid input: expected string, received undefined"
60
+ }
61
+ ]],
62
+ "success": false,
63
+ }
64
+ `);
65
+ });
66
+
67
+ test("literal exhaustiveness", () => {
68
+ const schema = z.record(z.literal(["Tuna", "Salmon"]), z.string());
69
+ schema.parse({
70
+ Tuna: "asdf",
71
+ Salmon: "asdf",
72
+ });
73
+
74
+ expect(schema.safeParse({ Tuna: "asdf", Salmon: "asdf", Trout: "asdf" })).toMatchInlineSnapshot(`
75
+ {
76
+ "error": [ZodError: [
77
+ {
78
+ "code": "unrecognized_keys",
79
+ "keys": [
80
+ "Trout"
81
+ ],
82
+ "path": [],
83
+ "message": "Unrecognized key: \\"Trout\\""
84
+ }
85
+ ]],
86
+ "success": false,
87
+ }
88
+ `);
89
+ expect(schema.safeParse({ Tuna: "asdf" })).toMatchInlineSnapshot(`
90
+ {
91
+ "error": [ZodError: [
92
+ {
93
+ "expected": "string",
94
+ "code": "invalid_type",
95
+ "path": [
96
+ "Salmon"
97
+ ],
98
+ "message": "Invalid input: expected string, received undefined"
99
+ }
100
+ ]],
101
+ "success": false,
102
+ }
103
+ `);
104
+ });
105
+
106
+ test("pipe exhaustiveness", () => {
107
+ const schema = z.record(z.enum(["Tuna", "Salmon"]).pipe(z.any()), z.string());
108
+ expect(schema.parse({ Tuna: "asdf", Salmon: "asdf" })).toEqual({
109
+ Tuna: "asdf",
110
+ Salmon: "asdf",
111
+ });
112
+
113
+ expect(schema.safeParse({ Tuna: "asdf", Salmon: "asdf", Trout: "asdf" })).toMatchInlineSnapshot(`
114
+ {
115
+ "error": [ZodError: [
116
+ {
117
+ "code": "unrecognized_keys",
118
+ "keys": [
119
+ "Trout"
120
+ ],
121
+ "path": [],
122
+ "message": "Unrecognized key: \\"Trout\\""
123
+ }
124
+ ]],
125
+ "success": false,
126
+ }
127
+ `);
128
+ expect(schema.safeParse({ Tuna: "asdf" })).toMatchInlineSnapshot(`
129
+ {
130
+ "error": [ZodError: [
131
+ {
132
+ "expected": "string",
133
+ "code": "invalid_type",
134
+ "path": [
135
+ "Salmon"
136
+ ],
137
+ "message": "Invalid input: expected string, received undefined"
138
+ }
139
+ ]],
140
+ "success": false,
141
+ }
142
+ `);
143
+ });
144
+
145
+ test("union exhaustiveness", () => {
146
+ const schema = z.record(z.union([z.literal("Tuna"), z.literal("Salmon")]), z.string());
147
+ expect(schema.parse({ Tuna: "asdf", Salmon: "asdf" })).toEqual({
148
+ Tuna: "asdf",
149
+ Salmon: "asdf",
150
+ });
151
+
152
+ expect(schema.safeParse({ Tuna: "asdf", Salmon: "asdf", Trout: "asdf" })).toMatchInlineSnapshot(`
153
+ {
154
+ "error": [ZodError: [
155
+ {
156
+ "code": "unrecognized_keys",
157
+ "keys": [
158
+ "Trout"
159
+ ],
160
+ "path": [],
161
+ "message": "Unrecognized key: \\"Trout\\""
162
+ }
163
+ ]],
164
+ "success": false,
165
+ }
166
+ `);
167
+ expect(schema.safeParse({ Tuna: "asdf" })).toMatchInlineSnapshot(`
168
+ {
169
+ "error": [ZodError: [
170
+ {
171
+ "expected": "string",
172
+ "code": "invalid_type",
173
+ "path": [
174
+ "Salmon"
175
+ ],
176
+ "message": "Invalid input: expected string, received undefined"
177
+ }
178
+ ]],
179
+ "success": false,
180
+ }
181
+ `);
182
+ });
183
+
184
+ test("string record parse - pass", () => {
185
+ const schema = z.record(z.string(), z.boolean());
186
+ schema.parse({
187
+ k1: true,
188
+ k2: false,
189
+ 1234: false,
190
+ });
191
+
192
+ expect(schema.safeParse({ asdf: 1234 }).success).toEqual(false);
193
+ expect(schema.safeParse("asdf")).toMatchInlineSnapshot(`
194
+ {
195
+ "error": [ZodError: [
196
+ {
197
+ "expected": "record",
198
+ "code": "invalid_type",
199
+ "path": [],
200
+ "message": "Invalid input: expected record, received string"
201
+ }
202
+ ]],
203
+ "success": false,
204
+ }
205
+ `);
206
+ });
207
+
208
+ test("key and value getters", () => {
209
+ const rec = z.record(z.string(), z.number());
210
+
211
+ rec.keyType.parse("asdf");
212
+ rec.valueType.parse(1234);
213
+ });
214
+
215
+ test("is not vulnerable to prototype pollution", async () => {
216
+ const rec = z.record(
217
+ z.string(),
218
+ z.object({
219
+ a: z.string(),
220
+ })
221
+ );
222
+
223
+ const data = JSON.parse(`
224
+ {
225
+ "__proto__": {
226
+ "a": "evil"
227
+ },
228
+ "b": {
229
+ "a": "good"
230
+ }
231
+ }
232
+ `);
233
+
234
+ const obj1 = rec.parse(data);
235
+ expect(obj1.a).toBeUndefined();
236
+
237
+ const obj2 = rec.safeParse(data);
238
+ expect(obj2.success).toBe(true);
239
+ if (obj2.success) {
240
+ expect(obj2.data.a).toBeUndefined();
241
+ }
242
+
243
+ const obj3 = await rec.parseAsync(data);
244
+ expect(obj3.a).toBeUndefined();
245
+
246
+ const obj4 = await rec.safeParseAsync(data);
247
+ expect(obj4.success).toBe(true);
248
+ if (obj4.success) {
249
+ expect(obj4.data.a).toBeUndefined();
250
+ }
251
+ });
252
+
253
+ test("dont remove undefined values", () => {
254
+ const result1 = z.record(z.string(), z.any()).parse({ foo: undefined });
255
+
256
+ expect(result1).toEqual({
257
+ foo: undefined,
258
+ });
259
+ });
260
+
261
+ test("allow undefined values", () => {
262
+ const schema = z.record(z.string(), z.undefined());
263
+
264
+ expect(
265
+ Object.keys(
266
+ schema.parse({
267
+ _test: undefined,
268
+ })
269
+ )
270
+ ).toEqual(["_test"]);
271
+ });
272
+
273
+ test("async parsing", async () => {
274
+ const schema = z
275
+ .record(
276
+ z.string(),
277
+ z
278
+ .string()
279
+ .optional()
280
+ .refine(async () => true)
281
+ )
282
+ .refine(async () => true);
283
+
284
+ const data = {
285
+ foo: "bar",
286
+ baz: "qux",
287
+ };
288
+ const result = await schema.safeParseAsync(data);
289
+ expect(result.data).toEqual(data);
290
+ });
291
+
292
+ test("async parsing", async () => {
293
+ const schema = z
294
+ .record(
295
+ z.string(),
296
+ z
297
+ .string()
298
+ .optional()
299
+ .refine(async () => false)
300
+ )
301
+ .refine(async () => false);
302
+
303
+ const data = {
304
+ foo: "bar",
305
+ baz: "qux",
306
+ };
307
+ const result = await schema.safeParseAsync(data);
308
+ expect(result.success).toEqual(false);
309
+ expect(result.error).toMatchInlineSnapshot(`
310
+ [ZodError: [
311
+ {
312
+ "code": "custom",
313
+ "path": [
314
+ "foo"
315
+ ],
316
+ "message": "Invalid input"
317
+ },
318
+ {
319
+ "code": "custom",
320
+ "path": [
321
+ "baz"
322
+ ],
323
+ "message": "Invalid input"
324
+ },
325
+ {
326
+ "code": "custom",
327
+ "path": [],
328
+ "message": "Invalid input"
329
+ }
330
+ ]]
331
+ `);
332
+ });
333
+
334
+ test("partial record", () => {
335
+ const schema = z.partialRecord(z.string(), z.string());
336
+ type schema = z.infer<typeof schema>;
337
+ expectTypeOf<schema>().toEqualTypeOf<Partial<Record<string, string>>>();
338
+
339
+ const Keys = z.enum(["id", "name", "email"]).or(z.never());
340
+ const Person = z.partialRecord(Keys, z.string());
341
+ expectTypeOf<z.infer<typeof Person>>().toEqualTypeOf<Partial<Record<"id" | "name" | "email", string>>>();
342
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts ADDED
@@ -0,0 +1,356 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+ import { z } from "zod/v4";
3
+
4
+ test("recursion with z.lazy", () => {
5
+ const data = {
6
+ name: "I",
7
+ subcategories: [
8
+ {
9
+ name: "A",
10
+ subcategories: [
11
+ {
12
+ name: "1",
13
+ subcategories: [
14
+ {
15
+ name: "a",
16
+ subcategories: [],
17
+ },
18
+ ],
19
+ },
20
+ ],
21
+ },
22
+ ],
23
+ };
24
+
25
+ const Category = z.object({
26
+ name: z.string(),
27
+ get subcategories() {
28
+ return z.array(Category).optional().nullable();
29
+ },
30
+ });
31
+ type Category = z.infer<typeof Category>;
32
+ interface _Category {
33
+ name: string;
34
+ subcategories?: _Category[] | undefined | null;
35
+ }
36
+ expectTypeOf<Category>().toEqualTypeOf<_Category>();
37
+ Category.parse(data);
38
+ });
39
+
40
+ test("recursion involving union type", () => {
41
+ const data = {
42
+ value: 1,
43
+ next: {
44
+ value: 2,
45
+ next: {
46
+ value: 3,
47
+ next: {
48
+ value: 4,
49
+ next: null,
50
+ },
51
+ },
52
+ },
53
+ };
54
+
55
+ const LL = z.object({
56
+ value: z.number(),
57
+ get next() {
58
+ return LL.nullable();
59
+ },
60
+ });
61
+ type LL = z.infer<typeof LL>;
62
+ type _LL = {
63
+ value: number;
64
+ next: _LL | null;
65
+ };
66
+ expectTypeOf<LL>().toEqualTypeOf<_LL>();
67
+
68
+ LL.parse(data);
69
+ });
70
+
71
+ test("mutual recursion - native", () => {
72
+ const Alazy = z.object({
73
+ val: z.number(),
74
+ get b() {
75
+ return Blazy;
76
+ },
77
+ });
78
+
79
+ const Blazy = z.object({
80
+ val: z.number(),
81
+ get a() {
82
+ return Alazy.optional();
83
+ },
84
+ });
85
+ const testData = {
86
+ val: 1,
87
+ b: {
88
+ val: 5,
89
+ a: {
90
+ val: 3,
91
+ b: {
92
+ val: 4,
93
+ a: {
94
+ val: 2,
95
+ b: {
96
+ val: 1,
97
+ },
98
+ },
99
+ },
100
+ },
101
+ },
102
+ };
103
+
104
+ type Alazy = z.infer<typeof Alazy>;
105
+ type Blazy = z.infer<typeof Blazy>;
106
+ interface _Alazy {
107
+ val: number;
108
+ b: _Blazy;
109
+ }
110
+ interface _Blazy {
111
+ val: number;
112
+ a?: _Alazy | undefined;
113
+ }
114
+ expectTypeOf<Alazy>().toEqualTypeOf<_Alazy>();
115
+ expectTypeOf<Blazy>().toEqualTypeOf<_Blazy>();
116
+ Alazy.parse(testData);
117
+ Blazy.parse(testData.b);
118
+
119
+ expect(() => Alazy.parse({ val: "asdf" })).toThrow();
120
+ });
121
+
122
+ test("pick and omit with getter", () => {
123
+ const Category = z.strictObject({
124
+ name: z.string(),
125
+ get subcategories() {
126
+ return z.array(Category);
127
+ },
128
+ });
129
+
130
+ type Category = z.infer<typeof Category>;
131
+
132
+ interface _Category {
133
+ name: string;
134
+ subcategories: _Category[];
135
+ }
136
+ expectTypeOf<Category>().toEqualTypeOf<_Category>();
137
+
138
+ const PickedCategory = Category.pick({ name: true });
139
+ const OmittedCategory = Category.omit({ subcategories: true });
140
+
141
+ const picked = { name: "test" };
142
+ const omitted = { name: "test" };
143
+
144
+ PickedCategory.parse(picked);
145
+ OmittedCategory.parse(omitted);
146
+
147
+ expect(() => PickedCategory.parse({ name: "test", subcategories: [] })).toThrow();
148
+ expect(() => OmittedCategory.parse({ name: "test", subcategories: [] })).toThrow();
149
+ });
150
+
151
+ test("deferred self-recursion", () => {
152
+ const Feature = z.object({
153
+ title: z.string(),
154
+ get features(): z.ZodOptional<z.ZodArray<typeof Feature>> {
155
+ return z.optional(z.array(Feature)); //.optional();
156
+ },
157
+ });
158
+ // type Feature = z.infer<typeof Feature>;
159
+
160
+ const Output = z.object({
161
+ id: z.int(), //.nonnegative(),
162
+ name: z.string(),
163
+ get features(): z.ZodArray<typeof Feature> {
164
+ return Feature.array();
165
+ },
166
+ });
167
+ type Output = z.output<typeof Output>;
168
+
169
+ type _Feature = {
170
+ title: string;
171
+ features?: _Feature[] | undefined;
172
+ };
173
+
174
+ type _Output = {
175
+ id: number;
176
+ name: string;
177
+ features: _Feature[];
178
+ };
179
+
180
+ // expectTypeOf<Feature>().toEqualTypeOf<_Feature>();
181
+ expectTypeOf<Output>().toEqualTypeOf<_Output>();
182
+ });
183
+
184
+ test("deferred mutual recursion", () => {
185
+ const Slot = z.object({
186
+ slotCode: z.string(),
187
+
188
+ get blocks() {
189
+ return z.array(Block);
190
+ },
191
+ });
192
+ type Slot = z.infer<typeof Slot>;
193
+
194
+ const Block = z.object({
195
+ blockCode: z.string(),
196
+ get slots() {
197
+ return z.array(Slot).optional();
198
+ },
199
+ });
200
+ type Block = z.infer<typeof Block>;
201
+
202
+ const Page = z.object({
203
+ slots: z.array(Slot),
204
+ });
205
+ type Page = z.infer<typeof Page>;
206
+
207
+ type _Slot = {
208
+ slotCode: string;
209
+ blocks: _Block[];
210
+ };
211
+ type _Block = {
212
+ blockCode: string;
213
+ slots?: _Slot[] | undefined;
214
+ };
215
+ type _Page = {
216
+ slots: _Slot[];
217
+ };
218
+ expectTypeOf<Slot>().toEqualTypeOf<_Slot>();
219
+ expectTypeOf<Block>().toEqualTypeOf<_Block>();
220
+ expectTypeOf<Page>().toEqualTypeOf<_Page>();
221
+ });
222
+
223
+ test("mutual recursion with meta", () => {
224
+ const A = z
225
+ .object({
226
+ name: z.string(),
227
+ get b() {
228
+ return B;
229
+ },
230
+ })
231
+ .readonly()
232
+ .meta({ id: "A" })
233
+ .optional();
234
+
235
+ const B = z
236
+ .object({
237
+ name: z.string(),
238
+ get a() {
239
+ return A;
240
+ },
241
+ })
242
+ .readonly()
243
+ .meta({ id: "B" });
244
+
245
+ type A = z.infer<typeof A>;
246
+ type B = z.infer<typeof B>;
247
+
248
+ type _A =
249
+ | Readonly<{
250
+ name: string;
251
+ b: _B;
252
+ }>
253
+ | undefined;
254
+ // | undefined;
255
+ type _B = Readonly<{
256
+ name: string;
257
+ a?: _A;
258
+ }>;
259
+ expectTypeOf<A>().toEqualTypeOf<_A>();
260
+ expectTypeOf<B>().toEqualTypeOf<_B>();
261
+ });
262
+
263
+ test("recursion compatibility", () => {
264
+ // array
265
+ const A = z.object({
266
+ get array() {
267
+ return A.array();
268
+ },
269
+ get optional() {
270
+ return A.optional();
271
+ },
272
+ get nullable() {
273
+ return A.nullable();
274
+ },
275
+ get nonoptional() {
276
+ return A.nonoptional();
277
+ },
278
+ get readonly() {
279
+ return A.readonly();
280
+ },
281
+ get describe() {
282
+ return A.describe("A recursive type");
283
+ },
284
+ get meta() {
285
+ return A.meta({ description: "A recursive type" });
286
+ },
287
+ get pipe() {
288
+ return A.pipe(z.any());
289
+ },
290
+ get strict() {
291
+ return A.strict();
292
+ },
293
+ get tuple() {
294
+ return z.tuple([A, A]);
295
+ },
296
+ get object() {
297
+ return z
298
+ .object({
299
+ subcategories: A,
300
+ })
301
+ .strict()
302
+ .loose();
303
+ },
304
+ get union() {
305
+ return z.union([A, A]);
306
+ },
307
+ get intersection() {
308
+ return z.intersection(A, A);
309
+ },
310
+ get record() {
311
+ return z.record(z.string(), A);
312
+ },
313
+ get map() {
314
+ return z.map(z.string(), A);
315
+ },
316
+ get set() {
317
+ return z.set(A);
318
+ },
319
+ get lazy() {
320
+ return z.lazy(() => A);
321
+ },
322
+ get promise() {
323
+ return z.promise(A);
324
+ },
325
+ });
326
+ });
327
+
328
+ // biome-ignore lint: sadf
329
+ export type RecursiveA = z.ZodUnion<
330
+ [
331
+ z.ZodObject<{
332
+ a: z.ZodDefault<RecursiveA>;
333
+ b: z.ZodPrefault<RecursiveA>;
334
+ c: z.ZodNonOptional<RecursiveA>;
335
+ d: z.ZodOptional<RecursiveA>;
336
+ e: z.ZodNullable<RecursiveA>;
337
+ g: z.ZodReadonly<RecursiveA>;
338
+ h: z.ZodPipe<RecursiveA, z.ZodString>;
339
+ i: z.ZodArray<RecursiveA>;
340
+ j: z.ZodSet<RecursiveA>;
341
+ k: z.ZodMap<RecursiveA, RecursiveA>;
342
+ l: z.ZodRecord<z.ZodString, RecursiveA>;
343
+ m: z.ZodUnion<[RecursiveA, RecursiveA]>;
344
+ n: z.ZodIntersection<RecursiveA, RecursiveA>;
345
+ o: z.ZodLazy<RecursiveA>;
346
+ p: z.ZodPromise<RecursiveA>;
347
+ q: z.ZodCatch<RecursiveA>;
348
+ r: z.ZodSuccess<RecursiveA>;
349
+ s: z.ZodTransform<RecursiveA, string>;
350
+ t: z.ZodTuple<[RecursiveA, RecursiveA]>;
351
+ u: z.ZodObject<{
352
+ a: RecursiveA;
353
+ }>;
354
+ }>,
355
+ ]
356
+ >;
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/refine.test.ts ADDED
@@ -0,0 +1,532 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { describe, expect, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+
4
+ describe("basic refinement functionality", () => {
5
+ test("should create a new schema instance when refining", () => {
6
+ const obj1 = z.object({
7
+ first: z.string(),
8
+ second: z.string(),
9
+ });
10
+ const obj2 = obj1.partial().strict();
11
+ const obj3 = obj2.refine((data) => data.first || data.second, "Either first or second should be filled in.");
12
+
13
+ expect(obj1 === (obj2 as any)).toEqual(false);
14
+ expect(obj2 === (obj3 as any)).toEqual(false);
15
+ });
16
+
17
+ test("should validate according to refinement logic", () => {
18
+ const schema = z
19
+ .object({
20
+ first: z.string(),
21
+ second: z.string(),
22
+ })
23
+ .partial()
24
+ .strict()
25
+ .refine((data) => data.first || data.second, "Either first or second should be filled in.");
26
+
27
+ // Should fail on empty object
28
+ expect(() => schema.parse({})).toThrow();
29
+
30
+ // Should pass with first property
31
+ expect(schema.parse({ first: "a" })).toEqual({ first: "a" });
32
+
33
+ // Should pass with second property
34
+ expect(schema.parse({ second: "a" })).toEqual({ second: "a" });
35
+
36
+ // Should pass with both properties
37
+ expect(schema.parse({ first: "a", second: "a" })).toEqual({ first: "a", second: "a" });
38
+ });
39
+
40
+ test("should validate strict mode correctly", () => {
41
+ const schema = z
42
+ .object({
43
+ first: z.string(),
44
+ second: z.string(),
45
+ })
46
+ .partial()
47
+ .strict();
48
+
49
+ // Should throw on extra properties
50
+ expect(() => schema.parse({ third: "adsf" })).toThrow();
51
+ });
52
+ });
53
+
54
+ describe("refinement with custom error messages", () => {
55
+ test("should use custom error message when validation fails", () => {
56
+ const validationSchema = z
57
+ .object({
58
+ email: z.string().email(),
59
+ password: z.string(),
60
+ confirmPassword: z.string(),
61
+ })
62
+ .refine((data) => data.password === data.confirmPassword, "Both password and confirmation must match");
63
+
64
+ const result = validationSchema.safeParse({
65
+ email: "aaaa@gmail.com",
66
+ password: "aaaaaaaa",
67
+ confirmPassword: "bbbbbbbb",
68
+ });
69
+
70
+ expect(result.success).toEqual(false);
71
+ if (!result.success) {
72
+ expect(result.error.issues[0].message).toEqual("Both password and confirmation must match");
73
+ }
74
+ });
75
+ });
76
+
77
+ describe("async refinements", () => {
78
+ test("should support async refinement functions", async () => {
79
+ const validationSchema = z
80
+ .object({
81
+ email: z.string().email(),
82
+ password: z.string(),
83
+ confirmPassword: z.string(),
84
+ })
85
+ .refine(
86
+ (data) => Promise.resolve().then(() => data.password === data.confirmPassword),
87
+ "Both password and confirmation must match"
88
+ );
89
+
90
+ // Should pass with matching passwords
91
+ const validData = {
92
+ email: "aaaa@gmail.com",
93
+ password: "password",
94
+ confirmPassword: "password",
95
+ };
96
+
97
+ await expect(validationSchema.parseAsync(validData)).resolves.toEqual(validData);
98
+
99
+ // Should fail with non-matching passwords
100
+ await expect(
101
+ validationSchema.parseAsync({
102
+ email: "aaaa@gmail.com",
103
+ password: "password",
104
+ confirmPassword: "different",
105
+ })
106
+ ).rejects.toThrow();
107
+ });
108
+ });
109
+
110
+ describe("early termination options", () => {
111
+ test("should abort early with continue: false", () => {
112
+ const schema = z
113
+ .string()
114
+ .superRefine((val, ctx) => {
115
+ if (val.length < 2) {
116
+ ctx.addIssue({
117
+ code: "custom",
118
+ message: "BAD",
119
+ continue: false,
120
+ });
121
+ }
122
+ })
123
+ .refine((_) => false);
124
+
125
+ const result = schema.safeParse("");
126
+ expect(result.success).toEqual(false);
127
+ if (!result.success) {
128
+ expect(result.error.issues.length).toEqual(1);
129
+ expect(result.error.issues[0].message).toEqual("BAD");
130
+ }
131
+ });
132
+
133
+ test("should abort early with fatal: true", () => {
134
+ const schema = z
135
+ .string()
136
+ .superRefine((val, ctx) => {
137
+ if (val.length < 2) {
138
+ ctx.addIssue({
139
+ code: "custom",
140
+ fatal: true,
141
+ message: "BAD",
142
+ });
143
+ }
144
+ })
145
+ .refine((_) => false);
146
+
147
+ const result = schema.safeParse("");
148
+ expect(result.success).toEqual(false);
149
+ if (!result.success) {
150
+ expect(result.error.issues.length).toEqual(1);
151
+ expect(result.error.issues[0].message).toEqual("BAD");
152
+ }
153
+ });
154
+
155
+ test("should abort early with abort flag", () => {
156
+ const schema = z
157
+ .string()
158
+ .refine((_) => false, { abort: true })
159
+ .refine((_) => false);
160
+
161
+ const result = schema.safeParse("");
162
+ expect(result.success).toEqual(false);
163
+ if (!result.success) {
164
+ expect(result.error.issues.length).toEqual(1);
165
+ }
166
+ });
167
+ });
168
+
169
+ describe("custom error paths", () => {
170
+ test("should use custom path in error message", async () => {
171
+ const result = await z
172
+ .object({ password: z.string(), confirm: z.string() })
173
+ .refine((data) => data.confirm === data.password, { path: ["confirm"] })
174
+ .safeParse({ password: "asdf", confirm: "qewr" });
175
+
176
+ expect(result.success).toEqual(false);
177
+ if (!result.success) {
178
+ expect(result.error.issues[0].path).toEqual(["confirm"]);
179
+ }
180
+ });
181
+ });
182
+
183
+ describe("superRefine functionality", () => {
184
+ test("should support multiple validation rules", () => {
185
+ const Strings = z.array(z.string()).superRefine((val, ctx) => {
186
+ if (val.length > 3) {
187
+ ctx.addIssue({
188
+ input: val,
189
+ code: "too_big",
190
+ origin: "array",
191
+ maximum: 3,
192
+ inclusive: true,
193
+ exact: true,
194
+ message: "Too many items 😡",
195
+ });
196
+ }
197
+
198
+ if (val.length !== new Set(val).size) {
199
+ ctx.addIssue({
200
+ input: val,
201
+ code: "custom",
202
+ message: `No duplicates allowed.`,
203
+ });
204
+ }
205
+ });
206
+
207
+ // Should fail with too many items and duplicates
208
+ const result = Strings.safeParse(["asfd", "asfd", "asfd", "asfd"]);
209
+ expect(result.success).toEqual(false);
210
+ if (!result.success) {
211
+ expect(result.error.issues.length).toEqual(2);
212
+ expect(result.error.issues[0].message).toEqual("Too many items 😡");
213
+ expect(result.error.issues[1].message).toEqual("No duplicates allowed.");
214
+ }
215
+
216
+ // Should pass with valid input
217
+ const validArray = ["asfd", "qwer"];
218
+ expect(Strings.parse(validArray)).toEqual(validArray);
219
+ });
220
+
221
+ test("should support async superRefine", async () => {
222
+ const Strings = z.array(z.string()).superRefine(async (val, ctx) => {
223
+ if (val.length > 3) {
224
+ ctx.addIssue({
225
+ input: val,
226
+ code: "too_big",
227
+ origin: "array",
228
+ maximum: 3,
229
+ inclusive: true,
230
+ message: "Too many items 😡",
231
+ });
232
+ }
233
+
234
+ if (val.length !== new Set(val).size) {
235
+ ctx.addIssue({
236
+ input: val,
237
+ code: "custom",
238
+ message: `No duplicates allowed.`,
239
+ });
240
+ }
241
+ });
242
+
243
+ // Should fail with too many items and duplicates
244
+ const result = await Strings.safeParseAsync(["asfd", "asfd", "asfd", "asfd"]);
245
+ expect(result.success).toEqual(false);
246
+ if (!result.success) {
247
+ expect(result.error.issues.length).toEqual(2);
248
+ }
249
+
250
+ // Should pass with valid input
251
+ const validArray = ["asfd", "qwer"];
252
+ await expect(Strings.parseAsync(validArray)).resolves.toEqual(validArray);
253
+ });
254
+
255
+ test("should accept string as shorthand for custom error message", () => {
256
+ const schema = z.string().superRefine((_, ctx) => {
257
+ ctx.addIssue("bad stuff");
258
+ });
259
+
260
+ const result = schema.safeParse("asdf");
261
+ expect(result.success).toEqual(false);
262
+ if (!result.success) {
263
+ expect(result.error.issues).toHaveLength(1);
264
+ expect(result.error.issues[0].message).toEqual("bad stuff");
265
+ }
266
+ });
267
+
268
+ test("should respect fatal flag in superRefine", () => {
269
+ const schema = z
270
+ .string()
271
+ .superRefine((val, ctx) => {
272
+ if (val === "") {
273
+ ctx.addIssue({
274
+ input: val,
275
+ code: "custom",
276
+ message: "foo",
277
+ fatal: true,
278
+ });
279
+ }
280
+ })
281
+ .superRefine((val, ctx) => {
282
+ if (val !== " ") {
283
+ ctx.addIssue({
284
+ input: val,
285
+ code: "custom",
286
+ message: "bar",
287
+ });
288
+ }
289
+ });
290
+
291
+ const result = schema.safeParse("");
292
+ expect(result.success).toEqual(false);
293
+ if (!result.success) {
294
+ expect(result.error.issues.length).toEqual(1);
295
+ expect(result.error.issues[0].message).toEqual("foo");
296
+ }
297
+ });
298
+ });
299
+
300
+ describe("chained refinements", () => {
301
+ test("should collect all validation errors when appropriate", () => {
302
+ const objectSchema = z
303
+ .object({
304
+ length: z.number(),
305
+ size: z.number(),
306
+ })
307
+ .refine(({ length }) => length > 5, {
308
+ path: ["length"],
309
+ message: "length greater than 5",
310
+ })
311
+ .refine(({ size }) => size > 7, {
312
+ path: ["size"],
313
+ message: "size greater than 7",
314
+ });
315
+
316
+ // Should fail with one error
317
+ const r1 = objectSchema.safeParse({
318
+ length: 4,
319
+ size: 9,
320
+ });
321
+ expect(r1.success).toEqual(false);
322
+ if (!r1.success) {
323
+ expect(r1.error.issues.length).toEqual(1);
324
+ expect(r1.error.issues[0].path).toEqual(["length"]);
325
+ }
326
+
327
+ // Should fail with two errors
328
+ const r2 = objectSchema.safeParse({
329
+ length: 4,
330
+ size: 3,
331
+ });
332
+ expect(r2.success).toEqual(false);
333
+ if (!r2.success) {
334
+ expect(r2.error.issues.length).toEqual(2);
335
+ }
336
+
337
+ // Should pass with valid input
338
+ const validData = {
339
+ length: 6,
340
+ size: 8,
341
+ };
342
+ expect(objectSchema.parse(validData)).toEqual(validData);
343
+ });
344
+ });
345
+
346
+ // Commented tests can be uncommented once type-checking issues are resolved
347
+ /*
348
+ describe("type refinement", () => {
349
+ test("refinement type guard", () => {
350
+ const validationSchema = z.object({
351
+ a: z.string().refine((s): s is "a" => s === "a"),
352
+ });
353
+ type Input = z.input<typeof validationSchema>;
354
+ type Schema = z.infer<typeof validationSchema>;
355
+
356
+ expectTypeOf<Input["a"]>().not.toEqualTypeOf<"a">();
357
+ expectTypeOf<Input["a"]>().toEqualTypeOf<string>();
358
+
359
+ expectTypeOf<Schema["a"]>().toEqualTypeOf<"a">();
360
+ expectTypeOf<Schema["a"]>().not.toEqualTypeOf<string>();
361
+ });
362
+
363
+ test("superRefine - type narrowing", () => {
364
+ type NarrowType = { type: string; age: number };
365
+ const schema = z
366
+ .object({
367
+ type: z.string(),
368
+ age: z.number(),
369
+ })
370
+ .nullable()
371
+ .superRefine((arg, ctx): arg is NarrowType => {
372
+ if (!arg) {
373
+ // still need to make a call to ctx.addIssue
374
+ ctx.addIssue({
375
+ input: arg,
376
+ code: "custom",
377
+ message: "cannot be null",
378
+ fatal: true,
379
+ });
380
+ return false;
381
+ }
382
+ return true;
383
+ });
384
+
385
+ expectTypeOf<z.infer<typeof schema>>().toEqualTypeOf<NarrowType>();
386
+
387
+ expect(schema.safeParse({ type: "test", age: 0 }).success).toEqual(true);
388
+ expect(schema.safeParse(null).success).toEqual(false);
389
+ });
390
+
391
+ test("chained mixed refining types", () => {
392
+ type firstRefinement = { first: string; second: number; third: true };
393
+ type secondRefinement = { first: "bob"; second: number; third: true };
394
+ type thirdRefinement = { first: "bob"; second: 33; third: true };
395
+ const schema = z
396
+ .object({
397
+ first: z.string(),
398
+ second: z.number(),
399
+ third: z.boolean(),
400
+ })
401
+ .nullable()
402
+ .refine((arg): arg is firstRefinement => !!arg?.third)
403
+ .superRefine((arg, ctx): arg is secondRefinement => {
404
+ expectTypeOf<typeof arg>().toEqualTypeOf<firstRefinement>();
405
+ if (arg.first !== "bob") {
406
+ ctx.addIssue({
407
+ input: arg,
408
+ code: "custom",
409
+ message: "`first` property must be `bob`",
410
+ });
411
+ return false;
412
+ }
413
+ return true;
414
+ })
415
+ .refine((arg): arg is thirdRefinement => {
416
+ expectTypeOf<typeof arg>().toEqualTypeOf<secondRefinement>();
417
+ return arg.second === 33;
418
+ });
419
+
420
+ expectTypeOf<z.infer<typeof schema>>().toEqualTypeOf<thirdRefinement>();
421
+ });
422
+ });
423
+ */
424
+
425
+ test("when", () => {
426
+ const schema = z
427
+ .strictObject({
428
+ password: z.string().min(8),
429
+ confirmPassword: z.string(),
430
+ other: z.string(),
431
+ })
432
+ .refine(
433
+ (data) => {
434
+ console.log("running check...");
435
+ console.log(data);
436
+ console.log(data.password);
437
+ return data.password === data.confirmPassword;
438
+ },
439
+ {
440
+ message: "Passwords do not match",
441
+ path: ["confirmPassword"],
442
+ when(payload) {
443
+ if (payload.value === undefined) return false;
444
+ if (payload.value === null) return false;
445
+ // no issues with confirmPassword or password
446
+ return payload.issues.every((iss) => iss.path?.[0] !== "confirmPassword" && iss.path?.[0] !== "password");
447
+ },
448
+ }
449
+ );
450
+
451
+ expect(schema.safeParse(undefined)).toMatchInlineSnapshot(`
452
+ {
453
+ "error": [ZodError: [
454
+ {
455
+ "expected": "object",
456
+ "code": "invalid_type",
457
+ "path": [],
458
+ "message": "Invalid input: expected object, received undefined"
459
+ }
460
+ ]],
461
+ "success": false,
462
+ }
463
+ `);
464
+ expect(schema.safeParse(null)).toMatchInlineSnapshot(`
465
+ {
466
+ "error": [ZodError: [
467
+ {
468
+ "expected": "object",
469
+ "code": "invalid_type",
470
+ "path": [],
471
+ "message": "Invalid input: expected object, received null"
472
+ }
473
+ ]],
474
+ "success": false,
475
+ }
476
+ `);
477
+ expect(
478
+ schema.safeParse({
479
+ password: "asdf",
480
+ confirmPassword: "asdfg",
481
+ other: "qwer",
482
+ })
483
+ ).toMatchInlineSnapshot(`
484
+ {
485
+ "error": [ZodError: [
486
+ {
487
+ "origin": "string",
488
+ "code": "too_small",
489
+ "minimum": 8,
490
+ "inclusive": true,
491
+ "path": [
492
+ "password"
493
+ ],
494
+ "message": "Too small: expected string to have >=8 characters"
495
+ }
496
+ ]],
497
+ "success": false,
498
+ }
499
+ `);
500
+
501
+ expect(
502
+ schema.safeParse({
503
+ password: "asdf",
504
+ confirmPassword: "asdfg",
505
+ other: 1234,
506
+ })
507
+ ).toMatchInlineSnapshot(`
508
+ {
509
+ "error": [ZodError: [
510
+ {
511
+ "origin": "string",
512
+ "code": "too_small",
513
+ "minimum": 8,
514
+ "inclusive": true,
515
+ "path": [
516
+ "password"
517
+ ],
518
+ "message": "Too small: expected string to have >=8 characters"
519
+ },
520
+ {
521
+ "expected": "string",
522
+ "code": "invalid_type",
523
+ "path": [
524
+ "other"
525
+ ],
526
+ "message": "Invalid input: expected string, received number"
527
+ }
528
+ ]],
529
+ "success": false,
530
+ }
531
+ `);
532
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/registries.test.ts ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+
4
+ test("globalRegistry", () => {
5
+ const reg = z.registry();
6
+
7
+ const a = z.string();
8
+ reg.add(a);
9
+ expect(reg.has(a)).toEqual(true);
10
+
11
+ reg.remove(a);
12
+ expect(reg.has(a)).toEqual(false);
13
+
14
+ a.register(z.globalRegistry, { field: "sup" });
15
+ expect(z.globalRegistry.has(a)).toEqual(true);
16
+ expect(z.globalRegistry.get(a)).toEqual({ field: "sup" });
17
+
18
+ z.globalRegistry.remove(a);
19
+ expect(z.globalRegistry.has(a)).toEqual(false);
20
+ });
21
+
22
+ test("z.registry", () => {
23
+ const fieldRegistry = z.registry<{ name: string; description: string }>();
24
+
25
+ const a = z.string();
26
+ fieldRegistry.add(a, { name: "hello", description: "world" });
27
+ const a_meta = fieldRegistry.get(a);
28
+ expect(a_meta).toEqual({ name: "hello", description: "world" });
29
+
30
+ fieldRegistry.remove(a);
31
+ expect(fieldRegistry.has(a)).toEqual(false);
32
+ expect(fieldRegistry.get(a)).toEqual(undefined);
33
+ });
34
+
35
+ test("z.registry no metadata", () => {
36
+ const fieldRegistry = z.registry();
37
+
38
+ const a = z.string();
39
+ fieldRegistry.add(a);
40
+ fieldRegistry.add(z.number());
41
+ expect(fieldRegistry.get(a)).toEqual(undefined);
42
+ expect(fieldRegistry.has(a)).toEqual(true);
43
+ });
44
+
45
+ test("z.registry with schema constraints", () => {
46
+ const fieldRegistry = z.registry<{ name: string; description: string }, z.ZodString>();
47
+
48
+ const a = z.string();
49
+ fieldRegistry.add(a, { name: "hello", description: "world" });
50
+ // @ts-expect-error
51
+ fieldRegistry.add(z.number(), { name: "test" });
52
+ // @ts-expect-error
53
+ z.number().register(fieldRegistry, { name: "test", description: "test" });
54
+ });
55
+
56
+ // test("z.namedRegistry", () => {
57
+ // const namedReg = z
58
+ // .namedRegistry<{ name: string; description: string }>()
59
+ // .add(z.string(), { name: "hello", description: "world" })
60
+ // .add(z.number(), { name: "number", description: "number" });
61
+
62
+ // expect(namedReg.get("hello")).toEqual({
63
+ // name: "hello",
64
+ // description: "world",
65
+ // });
66
+ // expect(namedReg.has("hello")).toEqual(true);
67
+ // expect(namedReg.get("number")).toEqual({
68
+ // name: "number",
69
+ // description: "number",
70
+ // });
71
+
72
+ // // @ts-expect-error
73
+ // namedReg.get("world");
74
+ // // @ts-expect-error
75
+ // expect(namedReg.get("world")).toEqual(undefined);
76
+
77
+ // const hello = namedReg.get("hello");
78
+ // expect(hello).toEqual({ name: "hello", description: "world" });
79
+ // expectTypeOf<typeof hello>().toEqualTypeOf<{
80
+ // name: "hello";
81
+ // description: "world";
82
+ // }>();
83
+ // expectTypeOf<typeof namedReg.items>().toEqualTypeOf<{
84
+ // hello: { name: "hello"; description: "world" };
85
+ // number: { name: "number"; description: "number" };
86
+ // }>();
87
+ // });
88
+
89
+ test("output type in registry meta", () => {
90
+ const reg = z.registry<{ out: z.$output }>();
91
+ const a = z.string();
92
+ reg.add(a, { out: "asdf" });
93
+ // @ts-expect-error
94
+ reg.add(a, 1234);
95
+ expectTypeOf(reg.get(a)).toEqualTypeOf<{ out: string } | undefined>();
96
+ });
97
+
98
+ test("output type in registry meta - objects and arrays", () => {
99
+ const reg = z.registry<{ name: string; examples: z.$output[] }>();
100
+ const a = z.string();
101
+ reg.add(a, { name: "hello", examples: ["world"] });
102
+
103
+ // @ts-expect-error
104
+ reg.add(a, { name: "hello", examples: "world" });
105
+ expectTypeOf(reg.get(a)).toEqualTypeOf<{ name: string; examples: string[] } | undefined>();
106
+ });
107
+
108
+ test("input type in registry meta", () => {
109
+ const reg = z.registry<{ in: z.$input }>();
110
+ const a = z.pipe(z.number(), z.transform(String));
111
+ reg.add(a, { in: 1234 });
112
+ // @ts-expect-error
113
+ reg.add(a, "1234");
114
+ expectTypeOf(reg.get(a)).toEqualTypeOf<{ in: number } | undefined>();
115
+ });
116
+
117
+ test("input type in registry meta - objects and arrays", () => {
118
+ const reg = z.registry<{ name: string; examples: z.$input[] }>();
119
+ const a = z.pipe(z.number(), z.transform(String));
120
+ reg.add(a, { name: "hello", examples: [1234] });
121
+
122
+ // @ts-expect-error
123
+ reg.add(a, { name: "hello", examples: "world" });
124
+ expectTypeOf(reg.get(a)).toEqualTypeOf<{ name: string; examples: number[] } | undefined>();
125
+ });
126
+
127
+ test(".meta method", () => {
128
+ const a1 = z.string();
129
+ const a2 = a1.meta({ name: "hello" });
130
+
131
+ expect(a1.meta()).toEqual(undefined);
132
+ expect(a2.meta()).toEqual({ name: "hello" });
133
+ expect(a1 === a2).toEqual(false);
134
+ });
135
+
136
+ test(".meta metadata does not bubble up", () => {
137
+ const a1 = z.string().meta({ name: "hello" });
138
+ const a2 = a1.optional();
139
+
140
+ expect(a1.meta()).toEqual({ name: "hello" });
141
+ expect(a2.meta()).toEqual(undefined);
142
+ });
143
+
144
+ test(".describe", () => {
145
+ const a1 = z.string();
146
+ const a2 = a1.describe("Hello");
147
+
148
+ expect(a1.description).toEqual(undefined);
149
+ expect(a2.description).toEqual("Hello");
150
+ });
151
+
152
+ test("inherit across clone", () => {
153
+ const A = z.string().meta({ a: true });
154
+ expect(A.meta()).toEqual({ a: true });
155
+ const B = A.meta({ b: true });
156
+ expect(B.meta()).toEqual({ a: true, b: true });
157
+ const C = B.describe("hello");
158
+ expect(C.meta()).toEqual({ a: true, b: true, description: "hello" });
159
+ });
160
+
161
+ test("loose examples", () => {
162
+ z.string().register(z.globalRegistry, {
163
+ examples: ["example"],
164
+ });
165
+ });
166
+
167
+ test("function meta witout replacement", () => {
168
+ const myReg = z.registry<{
169
+ defaulter: (arg: string, test: boolean) => number;
170
+ }>();
171
+
172
+ const mySchema = z.date();
173
+ myReg.add(mySchema, {
174
+ defaulter: (arg, _test) => {
175
+ return arg.length;
176
+ },
177
+ });
178
+
179
+ expect(myReg.get(mySchema)!.defaulter("hello", true)).toEqual(5);
180
+ });
181
+
182
+ test("function meta with replacement", () => {
183
+ const myReg = z.registry<{
184
+ defaulter: (arg: z.$input, test: boolean) => z.$output;
185
+ }>();
186
+
187
+ const mySchema = z.string().transform((val) => val.length);
188
+ myReg.add(mySchema, {
189
+ defaulter: (arg, _test) => {
190
+ return arg.length;
191
+ },
192
+ });
193
+
194
+ expect(myReg.get(mySchema)!.defaulter("hello", true)).toEqual(5);
195
+ });
196
+
197
+ test("test .clear()", () => {
198
+ const reg = z.registry();
199
+ const a = z.string();
200
+ reg.add(a);
201
+ expect(reg.has(a)).toEqual(true);
202
+ reg.clear();
203
+ expect(reg.has(a)).toEqual(false);
204
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/set.test.ts ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+
4
+ const stringSet = z.set(z.string());
5
+ type stringSet = z.infer<typeof stringSet>;
6
+
7
+ const minTwo = z.set(z.string()).min(2);
8
+ const maxTwo = z.set(z.string()).max(2);
9
+ const justTwo = z.set(z.string()).size(2);
10
+ const nonEmpty = z.set(z.string()).nonempty();
11
+ const nonEmptyMax = z.set(z.string()).nonempty().max(2);
12
+
13
+ test("type inference", () => {
14
+ expectTypeOf<stringSet>().toEqualTypeOf<Set<string>>();
15
+ });
16
+
17
+ test("valid parse", () => {
18
+ const result = stringSet.safeParse(new Set(["first", "second"]));
19
+ expect(result.success).toEqual(true);
20
+ expect(result.data!.has("first")).toEqual(true);
21
+ expect(result.data!.has("second")).toEqual(true);
22
+ expect(result.data!.has("third")).toEqual(false);
23
+
24
+ expect(() => {
25
+ minTwo.parse(new Set(["a", "b"]));
26
+ minTwo.parse(new Set(["a", "b", "c"]));
27
+ maxTwo.parse(new Set(["a", "b"]));
28
+ maxTwo.parse(new Set(["a"]));
29
+ justTwo.parse(new Set(["a", "b"]));
30
+ nonEmpty.parse(new Set(["a"]));
31
+ nonEmptyMax.parse(new Set(["a"]));
32
+ }).not.toThrow();
33
+ });
34
+
35
+ test("valid parse async", async () => {
36
+ const result = await stringSet.spa(new Set(["first", "second"]));
37
+ expect(result.success).toEqual(true);
38
+ expect(result.data!.has("first")).toEqual(true);
39
+ expect(result.data!.has("second")).toEqual(true);
40
+ expect(result.data!.has("third")).toEqual(false);
41
+
42
+ const asyncResult = await stringSet.safeParse(new Set(["first", "second"]));
43
+ expect(asyncResult.success).toEqual(true);
44
+ expect(asyncResult.data!.has("first")).toEqual(true);
45
+ expect(asyncResult.data!.has("second")).toEqual(true);
46
+ expect(asyncResult.data!.has("third")).toEqual(false);
47
+ });
48
+
49
+ test("valid parse: size-related methods", () => {
50
+ expect(() => {
51
+ minTwo.parse(new Set(["a", "b"]));
52
+ minTwo.parse(new Set(["a", "b", "c"]));
53
+ maxTwo.parse(new Set(["a", "b"]));
54
+ maxTwo.parse(new Set(["a"]));
55
+ justTwo.parse(new Set(["a", "b"]));
56
+ nonEmpty.parse(new Set(["a"]));
57
+ nonEmptyMax.parse(new Set(["a"]));
58
+ }).not.toThrow();
59
+
60
+ const sizeZeroResult = stringSet.parse(new Set());
61
+ expect(sizeZeroResult.size).toBe(0);
62
+
63
+ const sizeTwoResult = minTwo.parse(new Set(["a", "b"]));
64
+ expect(sizeTwoResult.size).toBe(2);
65
+ });
66
+
67
+ test("failing when parsing empty set in nonempty ", () => {
68
+ const result = nonEmpty.safeParse(new Set());
69
+ expect(result.success).toEqual(false);
70
+ expect(result.error!.issues.length).toEqual(1);
71
+ expect(result.error!.issues[0].code).toEqual("too_small");
72
+ });
73
+
74
+ test("failing when set is smaller than min() ", () => {
75
+ const result = minTwo.safeParse(new Set(["just_one"]));
76
+ expect(result.success).toEqual(false);
77
+ expect(result.error!.issues.length).toEqual(1);
78
+ expect(result.error!.issues[0].code).toEqual("too_small");
79
+ });
80
+
81
+ test("failing when set is bigger than max() ", () => {
82
+ const result = maxTwo.safeParse(new Set(["one", "two", "three"]));
83
+ expect(result.success).toEqual(false);
84
+ expect(result.error!.issues.length).toEqual(1);
85
+ expect(result.error!.issues[0].code).toEqual("too_big");
86
+ });
87
+
88
+ test("doesn’t throw when an empty set is given", () => {
89
+ const result = stringSet.safeParse(new Set([]));
90
+ expect(result.success).toEqual(true);
91
+ });
92
+
93
+ test("throws when a Map is given", () => {
94
+ const result = stringSet.safeParse(new Map([]));
95
+ expect(result.success).toEqual(false);
96
+ expect(result.error).toMatchInlineSnapshot(`
97
+ [ZodError: [
98
+ {
99
+ "expected": "set",
100
+ "code": "invalid_type",
101
+ "path": [],
102
+ "message": "Invalid input: expected set, received Map"
103
+ }
104
+ ]]
105
+ `);
106
+ });
107
+
108
+ test("throws when the given set has invalid input", () => {
109
+ const result = stringSet.safeParse(new Set([Symbol()]));
110
+ expect(result.success).toEqual(false);
111
+ expect(result.error!.issues.length).toEqual(1);
112
+ expect(result.error).toMatchInlineSnapshot(`
113
+ [ZodError: [
114
+ {
115
+ "expected": "string",
116
+ "code": "invalid_type",
117
+ "path": [],
118
+ "message": "Invalid input: expected string, received symbol"
119
+ }
120
+ ]]
121
+ `);
122
+ });
123
+
124
+ test("throws when the given set has multiple invalid entries", () => {
125
+ const result = stringSet.safeParse(new Set([1, 2] as any[]));
126
+ expect(result.success).toEqual(false);
127
+ expect(result.error!.issues.length).toEqual(2);
128
+ expect(result.error).toMatchInlineSnapshot(`
129
+ [ZodError: [
130
+ {
131
+ "expected": "string",
132
+ "code": "invalid_type",
133
+ "path": [],
134
+ "message": "Invalid input: expected string, received number"
135
+ },
136
+ {
137
+ "expected": "string",
138
+ "code": "invalid_type",
139
+ "path": [],
140
+ "message": "Invalid input: expected string, received number"
141
+ }
142
+ ]]
143
+ `);
144
+ });
145
+
146
+ test("min/max", async () => {
147
+ const schema = z.set(z.string()).min(4).max(5);
148
+
149
+ const r1 = schema.safeParse(new Set(["a", "b", "c", "d"]));
150
+ expect(r1.success).toEqual(true);
151
+
152
+ const r2 = schema.safeParse(new Set(["a", "b", "c"]));
153
+ expect(r2.success).toEqual(false);
154
+ expect(r2.error!.issues).toMatchInlineSnapshot(`
155
+ [
156
+ {
157
+ "code": "too_small",
158
+ "message": "Too small: expected set to have >4 items",
159
+ "minimum": 4,
160
+ "origin": "set",
161
+ "path": [],
162
+ },
163
+ ]
164
+ `);
165
+
166
+ const r3 = schema.safeParse(new Set(["a", "b", "c", "d", "e", "f"]));
167
+ expect(r3.success).toEqual(false);
168
+ expect(r3.error!.issues).toMatchInlineSnapshot(`
169
+ [
170
+ {
171
+ "code": "too_big",
172
+ "maximum": 5,
173
+ "message": "Too big: expected set to have <5 items",
174
+ "origin": "set",
175
+ "path": [],
176
+ },
177
+ ]
178
+ `);
179
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, test } from "vitest";
2
+
3
+ import * as z from "zod/v4";
4
+
5
+ test("length checks", async () => {
6
+ const schema = z.string();
7
+ const result = await schema["~standard"].validate(12);
8
+ expect(result).toMatchInlineSnapshot(`
9
+ {
10
+ "issues": [
11
+ {
12
+ "code": "invalid_type",
13
+ "expected": "string",
14
+ "message": "Invalid input: expected string, received number",
15
+ "path": [],
16
+ },
17
+ ],
18
+ }
19
+ `);
20
+ });
21
+
22
+ test("length checks", async () => {
23
+ const schema = z.string();
24
+ const result = await schema["~standard"].validate("asdf");
25
+ expect(result).toMatchInlineSnapshot(`
26
+ {
27
+ "value": "asdf",
28
+ }
29
+ `);
30
+ });
31
+
32
+ test("length checks", async () => {
33
+ const schema = z.string().refine(async (val) => val.length > 5);
34
+ const result = await schema["~standard"].validate(12);
35
+ expect(result).toMatchInlineSnapshot(`
36
+ {
37
+ "issues": [
38
+ {
39
+ "code": "invalid_type",
40
+ "expected": "string",
41
+ "message": "Invalid input: expected string, received number",
42
+ "path": [],
43
+ },
44
+ ],
45
+ }
46
+ `);
47
+ });
48
+
49
+ test("length checks", async () => {
50
+ const schema = z.string().refine(async (val) => val.length > 5);
51
+ const result = await schema["~standard"].validate("234134134");
52
+ expect(result).toMatchInlineSnapshot(`
53
+ {
54
+ "value": "234134134",
55
+ }
56
+ `);
57
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/string-formats.test.ts ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, test } from "vitest";
2
+
3
+ import * as z from "zod/v4";
4
+
5
+ test("string format methods", () => {
6
+ const a = z.email().min(10);
7
+ const b = z.email().max(10);
8
+ const c = z.email().length(10);
9
+ const d = z.email().uppercase();
10
+ const e = z.email().lowercase();
11
+
12
+ // Positive and negative cases for `a`
13
+ expect(a.safeParse("longemail@example.com").success).toBe(true); // Positive
14
+ expect(a.safeParse("ort@e.co").success).toBe(false); // Negative
15
+
16
+ // Positive and negative cases for `b`
17
+ expect(b.safeParse("sho@e.co").success).toBe(true); // Positive
18
+ expect(b.safeParse("longemail@example.com").success).toBe(false); // Negative
19
+
20
+ // Positive and negative cases for `c`
21
+ expect(c.safeParse("56780@e.co").success).toBe(true); // Positive
22
+ expect(c.safeParse("shoasdfasdfrt@e.co").success).toBe(false); // Negative
23
+
24
+ // Positive and negative cases for `d`
25
+ expect(d.safeParse("EMAIL@EXAMPLE.COM").success).toBe(true); // Positive
26
+ expect(d.safeParse("email@example.com").success).toBe(false); // Negative
27
+
28
+ // Positive and negative cases for `e`
29
+ expect(e.safeParse("email@example.com").success).toBe(true); // Positive
30
+ expect(e.safeParse("EMAIL@EXAMPLE.COM").success).toBe(false); // Negative
31
+ });
32
+
33
+ test("z.stringFormat", () => {
34
+ const ccRegex = /^(?:\d{14,19}|\d{4}(?: \d{3,6}){2,4}|\d{4}(?:-\d{3,6}){2,4})$/u;
35
+
36
+ const a = z
37
+ .stringFormat("creditCard", (val) => ccRegex.test(val), {
38
+ error: `Invalid credit card number`,
39
+ })
40
+ .refine((_) => false, "Also bad");
41
+
42
+ expect(a.safeParse("asdf")).toMatchInlineSnapshot(`
43
+ {
44
+ "error": [ZodError: [
45
+ {
46
+ "code": "invalid_format",
47
+ "format": "creditCard",
48
+ "path": [],
49
+ "message": "Invalid credit card number"
50
+ },
51
+ {
52
+ "code": "custom",
53
+ "path": [],
54
+ "message": "Also bad"
55
+ }
56
+ ]],
57
+ "success": false,
58
+ }
59
+ `);
60
+ expect(a.safeParse("1234-5678-9012-3456")).toMatchInlineSnapshot(`
61
+ {
62
+ "error": [ZodError: [
63
+ {
64
+ "code": "custom",
65
+ "path": [],
66
+ "message": "Also bad"
67
+ }
68
+ ]],
69
+ "success": false,
70
+ }
71
+ `);
72
+ expect(a.def.pattern).toMatchInlineSnapshot(`undefined`);
73
+
74
+ const b = z
75
+ .stringFormat("creditCard", ccRegex, {
76
+ abort: true,
77
+ error: `Invalid credit card number`,
78
+ })
79
+ .refine((_) => false, "Also bad");
80
+
81
+ expect(b.safeParse("asdf")).toMatchInlineSnapshot(`
82
+ {
83
+ "error": [ZodError: [
84
+ {
85
+ "code": "invalid_format",
86
+ "format": "creditCard",
87
+ "path": [],
88
+ "message": "Invalid credit card number"
89
+ }
90
+ ]],
91
+ "success": false,
92
+ }
93
+ `);
94
+ expect(b.safeParse("1234-5678-9012-3456")).toMatchInlineSnapshot(`
95
+ {
96
+ "error": [ZodError: [
97
+ {
98
+ "code": "custom",
99
+ "path": [],
100
+ "message": "Also bad"
101
+ }
102
+ ]],
103
+ "success": false,
104
+ }
105
+ `);
106
+ expect(b.def.pattern).toMatchInlineSnapshot(
107
+ `/\\^\\(\\?:\\\\d\\{14,19\\}\\|\\\\d\\{4\\}\\(\\?: \\\\d\\{3,6\\}\\)\\{2,4\\}\\|\\\\d\\{4\\}\\(\\?:-\\\\d\\{3,6\\}\\)\\{2,4\\}\\)\\$/u`
108
+ );
109
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/string.test.ts ADDED
@@ -0,0 +1,881 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { randomBytes } from "node:crypto";
2
+ import { expect, test } from "vitest";
3
+
4
+ import * as z from "zod/v4";
5
+
6
+ const minFive = z.string().min(5, "min5");
7
+ const maxFive = z.string().max(5, "max5");
8
+ const justFive = z.string().length(5);
9
+ const nonempty = z.string().min(1, "nonempty");
10
+ const includes = z.string().includes("includes");
11
+ const includesFromIndex2 = z.string().includes("includes", { position: 2 });
12
+ const startsWith = z.string().startsWith("startsWith");
13
+ const endsWith = z.string().endsWith("endsWith");
14
+
15
+ test("length checks", () => {
16
+ minFive.parse("12345");
17
+ minFive.parse("123456");
18
+ maxFive.parse("12345");
19
+ maxFive.parse("1234");
20
+ nonempty.parse("1");
21
+ justFive.parse("12345");
22
+
23
+ expect(() => minFive.parse("1234")).toThrow();
24
+ expect(() => maxFive.parse("123456")).toThrow();
25
+ expect(() => nonempty.parse("")).toThrow();
26
+ expect(() => justFive.parse("1234")).toThrow();
27
+ expect(() => justFive.parse("123456")).toThrow();
28
+ });
29
+
30
+ test("includes", () => {
31
+ includes.parse("XincludesXX");
32
+ includesFromIndex2.parse("XXXincludesXX");
33
+
34
+ expect(() => includes.parse("XincludeXX")).toThrow();
35
+ expect(() => includesFromIndex2.parse("XincludesXX")).toThrow();
36
+ });
37
+
38
+ test("startswith/endswith", () => {
39
+ startsWith.parse("startsWithX");
40
+ endsWith.parse("XendsWith");
41
+
42
+ expect(() => startsWith.parse("x")).toThrow();
43
+ expect(() => endsWith.parse("x")).toThrow();
44
+ });
45
+
46
+ test("email validations", () => {
47
+ const validEmails = [
48
+ `email@domain.com`,
49
+ `firstname.lastname@domain.com`,
50
+ `email@subdomain.domain.com`,
51
+ `firstname+lastname@domain.com`,
52
+ `1234567890@domain.com`,
53
+ `email@domain-one.com`,
54
+ `_______@domain.com`,
55
+ `email@domain.name`,
56
+ `email@domain.co.jp`,
57
+ `firstname-lastname@domain.com`,
58
+ `very.common@example.com`,
59
+ `disposable.style.email.with+symbol@example.com`,
60
+ `other.email-with-hyphen@example.com`,
61
+ `fully-qualified-domain@example.com`,
62
+ `user.name+tag+sorting@example.com`,
63
+ `x@example.com`,
64
+ `mojojojo@asdf.example.com`,
65
+ `example-indeed@strange-example.com`,
66
+ `example@s.example`,
67
+ `user-@example.org`,
68
+ `user@my-example.com`,
69
+ `a@b.cd`,
70
+ `work+user@mail.com`,
71
+ `tom@test.te-st.com`,
72
+ `something@subdomain.domain-with-hyphens.tld`,
73
+ `common'name@domain.com`,
74
+ `francois@etu.inp-n7.fr`,
75
+ ];
76
+ const invalidEmails = [
77
+ // no "printable characters"
78
+ // `user%example.com@example.org`,
79
+ // `mailhost!username@example.org`,
80
+ // `test/test@test.com`,
81
+
82
+ // double @
83
+ `francois@@etu.inp-n7.fr`,
84
+ // do not support quotes
85
+ `"email"@domain.com`,
86
+ `"e asdf sadf ?<>ail"@domain.com`,
87
+ `" "@example.org`,
88
+ `"john..doe"@example.org`,
89
+ `"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com`,
90
+ // do not support comma
91
+ `a,b@domain.com`,
92
+
93
+ // do not support IPv4
94
+ `email@123.123.123.123`,
95
+ `email@[123.123.123.123]`,
96
+ `postmaster@123.123.123.123`,
97
+ `user@[68.185.127.196]`,
98
+ `ipv4@[85.129.96.247]`,
99
+ `valid@[79.208.229.53]`,
100
+ `valid@[255.255.255.255]`,
101
+ `valid@[255.0.55.2]`,
102
+ `valid@[255.0.55.2]`,
103
+
104
+ // do not support ipv6
105
+ `hgrebert0@[IPv6:4dc8:ac7:ce79:8878:1290:6098:5c50:1f25]`,
106
+ `bshapiro4@[IPv6:3669:c709:e981:4884:59a3:75d1:166b:9ae]`,
107
+ `jsmith@[IPv6:2001:db8::1]`,
108
+ `postmaster@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370:7334]`,
109
+ `postmaster@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370:192.168.1.1]`,
110
+
111
+ // microsoft test cases
112
+ `plainaddress`,
113
+ `#@%^%#$@#$@#.com`,
114
+ `@domain.com`,
115
+ `Joe Smith &lt;email@domain.com&gt;`,
116
+ `email.domain.com`,
117
+ `email@domain@domain.com`,
118
+ `.email@domain.com`,
119
+ `email.@domain.com`,
120
+ `email..email@domain.com`,
121
+ `あいうえお@domain.com`,
122
+ `email@domain.com (Joe Smith)`,
123
+ `email@domain`,
124
+ `email@-domain.com`,
125
+ `email@111.222.333.44444`,
126
+ `email@domain..com`,
127
+ `Abc.example.com`,
128
+ `A@b@c@example.com`,
129
+ `colin..hacks@domain.com`,
130
+ `a"b(c)d,e:f;g<h>i[j\k]l@example.com`,
131
+ `just"not"right@example.com`,
132
+ `this is"not\allowed@example.com`,
133
+ `this\ still\"not\\allowed@example.com`,
134
+
135
+ // random
136
+ `i_like_underscore@but_its_not_allowed_in_this_part.example.com`,
137
+ `QA[icon]CHOCOLATE[icon]@test.com`,
138
+ `invalid@-start.com`,
139
+ `invalid@end.com-`,
140
+ `a.b@c.d`,
141
+ `invalid@[1.1.1.-1]`,
142
+ `invalid@[68.185.127.196.55]`,
143
+ `temp@[192.168.1]`,
144
+ `temp@[9.18.122.]`,
145
+ `double..point@test.com`,
146
+ `asdad@test..com`,
147
+ `asdad@hghg...sd...au`,
148
+ `asdad@hghg........au`,
149
+ `invalid@[256.2.2.48]`,
150
+ `invalid@[256.2.2.48]`,
151
+ `invalid@[999.465.265.1]`,
152
+ `jkibbey4@[IPv6:82c4:19a8::70a9:2aac:557::ea69:d985:28d]`,
153
+ `mlivesay3@[9952:143f:b4df:2179:49a1:5e82:b92e:6b6]`,
154
+ `gbacher0@[IPv6:bc37:4d3f:5048:2e26:37cc:248e:df8e:2f7f:af]`,
155
+ `invalid@[IPv6:5348:4ed3:5d38:67fb:e9b:acd2:c13:192.168.256.1]`,
156
+ `test@.com`,
157
+ `aaaaaaaaaaaaaaalongemailthatcausesregexDoSvulnerability@test.c`,
158
+ ];
159
+ const emailSchema = z.string().email();
160
+
161
+ expect(
162
+ validEmails.every((email) => {
163
+ return emailSchema.safeParse(email).success;
164
+ })
165
+ ).toBe(true);
166
+ expect(
167
+ invalidEmails.every((email) => {
168
+ return emailSchema.safeParse(email).success === false;
169
+ })
170
+ ).toBe(true);
171
+ });
172
+
173
+ test("base64 validations", () => {
174
+ const validBase64Strings = [
175
+ "SGVsbG8gV29ybGQ=", // "Hello World"
176
+ "VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==", // "This is an encoded string"
177
+ "TWFueSBoYW5kcyBtYWtlIGxpZ2h0IHdvcms=", // "Many hands make light work"
178
+ "UGF0aWVuY2UgaXMgdGhlIGtleSB0byBzdWNjZXNz", // "Patience is the key to success"
179
+ "QmFzZTY0IGVuY29kaW5nIGlzIGZ1bg==", // "Base64 encoding is fun"
180
+ "MTIzNDU2Nzg5MA==", // "1234567890"
181
+ "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo=", // "abcdefghijklmnopqrstuvwxyz"
182
+ "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVo=", // "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
183
+ "ISIkJSMmJyonKCk=", // "!\"#$%&'()*"
184
+ "", // Empty string is technically a valid base64
185
+ ];
186
+
187
+ for (const str of validBase64Strings) {
188
+ expect(str + z.string().base64().safeParse(str).success).toBe(`${str}true`);
189
+ }
190
+
191
+ const invalidBase64Strings = [
192
+ "12345", // Not padded correctly, not a multiple of 4 characters
193
+ "SGVsbG8gV29ybGQ", // Missing padding
194
+ "VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw", // Missing padding
195
+ "!UGF0aWVuY2UgaXMgdGhlIGtleSB0byBzdWNjZXNz", // Invalid character '!'
196
+ "?QmFzZTY0IGVuY29kaW5nIGlzIGZ1bg==", // Invalid character '?'
197
+ ".MTIzND2Nzg5MC4=", // Invalid character '.'
198
+ "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVo", // Missing padding
199
+ ];
200
+
201
+ for (const str of invalidBase64Strings) {
202
+ expect(str + z.string().base64().safeParse(str).success).toBe(`${str}false`);
203
+ }
204
+ });
205
+
206
+ test("base64url validations", () => {
207
+ const base64url = z.string().base64url();
208
+
209
+ const validBase64URLStrings = [
210
+ "SGVsbG8gV29ybGQ", // "Hello World"
211
+
212
+ "VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw", // "This is an encoded string"
213
+
214
+ "TWFueSBoYW5kcyBtYWtlIGxpZ2h0IHdvcms", // "Many hands make light work"
215
+
216
+ "UGF0aWVuY2UgaXMgdGhlIGtleSB0byBzdWNjZXNz", // "Patience is the key to success"
217
+ "QmFzZTY0IGVuY29kaW5nIGlzIGZ1bg", // "Base64 encoding is fun"
218
+
219
+ "MTIzNDU2Nzg5MA", // "1234567890"
220
+
221
+ "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo", // "abcdefghijklmnopqrstuvwxyz"
222
+
223
+ "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVo", // "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
224
+
225
+ "ISIkJSMmJyonKCk", // "!\"#$%&'()*"
226
+
227
+ "", // Empty string is technically valid base64url
228
+ "w7_Dv8O-w74K", // ÿÿþþ
229
+ "123456",
230
+ ];
231
+
232
+ for (const str of validBase64URLStrings) {
233
+ expect(str + base64url.safeParse(str).success).toBe(`${str}true`);
234
+ }
235
+
236
+ const invalidBase64URLStrings = [
237
+ "w7/Dv8O+w74K", // Has + and / characters (is base64)
238
+ "12345", // Invalid length (not a multiple of 4 characters when adding allowed number of padding characters)
239
+ "12345===", // Not padded correctly
240
+ "!UGF0aWVuY2UgaXMgdGhlIGtleSB0byBzdWNjZXNz", // Invalid character '!'
241
+ "?QmFzZTY0IGVuY29kaW5nIGlzIGZ1bg==", // Invalid character '?'
242
+ ".MTIzND2Nzg5MC4=", // Invalid character '.'
243
+
244
+ // disallow valid padding
245
+ "SGVsbG8gV29ybGQ=", // "Hello World" with padding
246
+ "VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==", // "This is an encoded string" with padding
247
+ "TWFueSBoYW5kcyBtYWtlIGxpZ2h0IHdvcms=", // "Many hands make light work" with padding
248
+ "QmFzZTY0IGVuY29kaW5nIGlzIGZ1bg==", // "Base64 encoding is fun" with padding
249
+ "MTIzNDU2Nzg5MA==", // "1234567890" with padding
250
+ "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo=", // "abcdefghijklmnopqrstuvwxyz with padding"
251
+ "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVo=", // "ABCDEFGHIJKLMNOPQRSTUVWXYZ" with padding
252
+ "ISIkJSMmJyonKCk=", // "!\"#$%&'()*" with padding
253
+ ];
254
+
255
+ for (const str of invalidBase64URLStrings) {
256
+ expect(str + base64url.safeParse(str).success).toBe(`${str}false`);
257
+ }
258
+ });
259
+
260
+ test("big base64 and base64url", () => {
261
+ const bigbase64 = randomBytes(1024 * 1024 * 10).toString("base64");
262
+ z.base64().parse(bigbase64);
263
+ const bigbase64url = randomBytes(1024 * 1024 * 10).toString("base64url");
264
+ z.base64url().parse(bigbase64url);
265
+ });
266
+
267
+ function makeJwt(header: object, payload: object) {
268
+ const headerBase64 = Buffer.from(JSON.stringify(header)).toString("base64url");
269
+ const payloadBase64 = Buffer.from(JSON.stringify(payload)).toString("base64url");
270
+ const signature = "signature"; // Placeholder for the signature
271
+ return `${headerBase64}.${payloadBase64}.${signature}`;
272
+ }
273
+
274
+ test("jwt token", () => {
275
+ const jwt = z.string().jwt();
276
+ expect(() => jwt.parse("invalid")).toThrow();
277
+ expect(() => jwt.parse("invalid.invalid")).toThrow();
278
+ expect(() => jwt.parse("invalid.invalid.invalid")).toThrow();
279
+
280
+ // Valid JWTs
281
+ const es256jwt = z.string().jwt({ alg: "ES256" });
282
+ const d1 = makeJwt({ typ: "JWT", alg: "ES256" }, {});
283
+ jwt.parse(d1);
284
+ es256jwt.parse(d1);
285
+
286
+ // Invalid header
287
+ const d2 = makeJwt({}, {});
288
+ expect(() => jwt.parse(d2)).toThrow();
289
+
290
+ // Wrong algorithm
291
+ const d3 = makeJwt({ typ: "JWT", alg: "RS256" }, {});
292
+ expect(() => es256jwt.parse(d3)).toThrow();
293
+
294
+ // missing typ is fine
295
+ const d4 = makeJwt({ alg: "HS256" }, {});
296
+ jwt.parse(d4);
297
+
298
+ // type isn't JWT
299
+ const d5 = makeJwt({ typ: "SUP", alg: "HS256" }, { foo: "bar" });
300
+ expect(() => jwt.parse(d5)).toThrow();
301
+ });
302
+
303
+ test("url validations", () => {
304
+ const url = z.string().url();
305
+ url.parse("http://google.com");
306
+ url.parse("https://google.com/asdf?asdf=ljk3lk4&asdf=234#asdf");
307
+ url.parse("https://anonymous:flabada@developer.mozilla.org/en-US/docs/Web/API/URL/password");
308
+ url.parse("https://localhost");
309
+ url.parse("https://my.local");
310
+ url.parse("http://aslkfjdalsdfkjaf");
311
+ url.parse("http://localhost");
312
+
313
+ url.parse("c:");
314
+
315
+ expect(() => url.parse("asdf")).toThrow();
316
+ expect(() => url.parse("https:/")).toThrow();
317
+ expect(() => url.parse("asdfj@lkjsdf.com")).toThrow();
318
+ expect(() => url.parse("https://")).toThrow();
319
+ });
320
+
321
+ test("httpurl", () => {
322
+ const httpUrl = z.url({
323
+ protocol: /^https?$/,
324
+ hostname: z.regexes.domain,
325
+ // /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/
326
+ });
327
+
328
+ httpUrl.parse("https://example.com");
329
+ httpUrl.parse("http://example.com");
330
+ // ports
331
+ httpUrl.parse("https://example.com:8080");
332
+ httpUrl.parse("http://example.com:8080");
333
+ // subdomains
334
+ httpUrl.parse("https://sub.example.com");
335
+ httpUrl.parse("http://sub.example.com");
336
+ // paths
337
+ httpUrl.parse("https://example.com/path/to/resource");
338
+ httpUrl.parse("http://example.com/path/to/resource");
339
+ // query parameters
340
+ httpUrl.parse("https://example.com/path?query=param");
341
+ httpUrl.parse("http://example.com/path?query=param");
342
+ // fragment identifiers
343
+ httpUrl.parse("https://example.com/path#fragment");
344
+ httpUrl.parse("http://example.com/path#fragment");
345
+ // fails
346
+ expect(() => httpUrl.parse("ftp://example.com")).toThrow();
347
+ expect(() => httpUrl.parse("shttp://example.com")).toThrow();
348
+ expect(() => httpUrl.parse("httpz://example.com")).toThrow();
349
+ expect(() => httpUrl.parse("http://")).toThrow();
350
+ expect(() => httpUrl.parse("http://localhost")).toThrow();
351
+ expect(() => httpUrl.parse("http://-asdf.com")).toThrow();
352
+ expect(() =>
353
+ httpUrl.parse(
354
+ "http://asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf.com"
355
+ )
356
+ ).toThrow();
357
+ expect(() => httpUrl.parse("http://asdf.c")).toThrow();
358
+ expect(() => httpUrl.parse("mailto:asdf@lckj.com")).toThrow();
359
+ });
360
+
361
+ test("url error overrides", () => {
362
+ try {
363
+ z.string().url().parse("https");
364
+ } catch (err) {
365
+ expect((err as z.ZodError).issues[0].message).toEqual("Invalid URL");
366
+ }
367
+ try {
368
+ z.string().url("badurl").parse("https");
369
+ } catch (err) {
370
+ expect((err as z.ZodError).issues[0].message).toEqual("badurl");
371
+ }
372
+ try {
373
+ z.string().url({ message: "badurl" }).parse("https");
374
+ } catch (err) {
375
+ expect((err as z.ZodError).issues[0].message).toEqual("badurl");
376
+ }
377
+ });
378
+
379
+ test("emoji validations", () => {
380
+ const emoji = z.string().emoji();
381
+
382
+ emoji.parse("👋👋👋👋");
383
+ emoji.parse("🍺👩‍🚀🫡");
384
+ emoji.parse("💚💙💜💛❤️");
385
+ emoji.parse("🐛🗝🐏🍡🎦🚢🏨💫🎌☘🗡😹🔒🎬➡️🍹🗂🚨⚜🕑〽️🚦🌊🍴💍🍌💰😳🌺🍃");
386
+ emoji.parse("🇹🇷🤽🏿‍♂️");
387
+ emoji.parse(
388
+ "😀😁😂🤣😃😄😅😆😉😊😋😎😍😘🥰😗😙😚☺️☺🙂🤗🤩🤔🤨😐😑😶🙄😏😣😥😮🤐😯😪😫😴😌😛😜😝🤤😒😓😔😕🙃🤑😲☹️☹🙁😖😞😟😤😢😭😦😧😨😩🤯😬😰😱🥵🥶😳🤪😵😡😠🤬😷🤒🤕🤢🤮🤧😇🤠🥳🥴🥺🤥🤫🤭🧐🤓😈👿🤡👹👺💀☠️☠👻👽👾🤖💩😺😸😹😻😼😽🙀😿😾🙈🙉🙊🏻🏼🏽🏾🏿👶👶🏻👶🏼👶🏽👶🏾👶🏿🧒🧒🏻🧒🏼🧒🏽🧒🏾🧒🏿👦👦🏻👦🏼👦🏽👦🏾👦🏿👧👧🏻👧🏼👧🏽👧🏾👧🏿🧑🧑🏻🧑🏼🧑🏽🧑🏾🧑🏿👨👨🏻👨🏼👨🏽👨🏾👨🏿👩👩🏻👩🏼👩🏽👩🏾👩🏿🧓🧓🏻🧓🏼🧓🏽🧓🏾🧓🏿👴👴🏻👴🏼👴🏽👴🏾👴🏿👵👵🏻👵🏼👵🏽👵🏾👵🏿👨‍⚕️👨‍⚕👨🏻‍⚕️👨🏻‍⚕👨🏼‍⚕️👨🏼‍⚕👨🏽‍⚕️👨🏽‍⚕👨🏾‍⚕️👨🏾‍⚕👨🏿‍⚕️👨🏿‍⚕👩‍⚕️👩‍⚕👩🏻‍⚕️👩🏻‍⚕👩🏼‍⚕️👩🏼‍⚕👩🏽‍⚕️👩🏽‍⚕👩🏾‍⚕️👩🏾‍⚕👩🏿‍⚕️👩🏿‍⚕👨‍🎓👨🏻‍🎓👨🏼‍🎓👨🏽‍🎓👨🏾‍🎓👨🏿‍🎓👩‍🎓👩🏻‍🎓👩🏼‍🎓👩🏽‍🎓👩🏾‍🎓👩🏿‍🎓👨‍🏫👨🏻‍🏫👨🏼‍🏫👨🏽‍🏫👨🏾‍🏫👨🏿‍🏫👩‍🏫👩🏻‍🏫👩🏼‍🏫👩🏽‍🏫👩🏾‍🏫👩🏿‍🏫👨‍⚖️👨‍⚖👨🏻‍⚖️👨🏻‍⚖👨🏼‍⚖️👨🏼‍⚖👨🏽‍⚖️👨🏽‍⚖👨🏾‍⚖️👨🏾‍⚖👨🏿‍⚖️👨🏿‍⚖👩‍⚖️👩‍⚖👩🏻‍⚖️👩🏻‍⚖👩🏼‍⚖️👩🏼‍⚖👩🏽‍⚖️👩🏽‍⚖👩🏾‍⚖️👩🏾‍⚖👩🏿‍⚖️👩🏿‍⚖👨‍🌾👨🏻‍🌾👨🏼‍🌾👨🏽‍🌾👨🏾‍🌾👨🏿‍🌾👩‍🌾👩🏻‍🌾👩🏼‍🌾👩🏽‍🌾👩🏾‍🌾👩🏿‍🌾👨‍🍳👨🏻‍🍳👨🏼‍🍳👨🏽‍🍳👨🏾‍🍳👨🏿‍🍳👩‍🍳👩🏻‍🍳👩🏼‍🍳👩🏽‍🍳👩🏾‍🍳👩🏿‍🍳👨‍🔧👨🏻‍🔧👨🏼‍🔧👨🏽‍🔧👨🏾‍🔧👨🏿‍🔧👩‍🔧👩🏻‍🔧👩🏼‍🔧👩🏽‍🔧👩🏾‍🔧👩🏿‍🔧👨‍🏭👨🏻‍🏭👨🏼‍🏭👨🏽‍🏭👨🏾‍🏭👨🏿‍🏭👩‍🏭👩🏻‍🏭👩🏼‍🏭👩🏽‍🏭👩🏾‍🏭👩🏿‍🏭👨‍💼👨🏻‍💼👨🏼‍💼👨🏽‍💼👨🏾‍💼👨🏿‍💼👩‍💼👩🏻‍💼👩🏼‍💼👩🏽‍💼👩🏾‍💼👩🏿‍💼👨‍🔬👨🏻‍🔬👨🏼‍🔬👨🏽‍🔬👨🏾‍🔬👨🏿‍🔬👩‍🔬👩🏻‍🔬👩🏼‍🔬👩🏽‍🔬👩🏾‍🔬👩🏿‍🔬👨‍💻👨🏻‍💻👨🏼‍💻👨🏽‍💻👨🏾‍💻👨🏿‍💻👩‍💻👩🏻‍💻👩🏼‍💻👩🏽‍💻👩🏾‍💻👩🏿‍💻👨‍🎤👨🏻‍🎤👨🏼‍🎤👨🏽‍🎤👨🏾‍🎤👨🏿‍🎤👩‍🎤👩🏻‍🎤👩🏼‍🎤👩🏽‍🎤👩🏾‍🎤👩🏿‍🎤👨‍🎨👨🏻‍🎨👨🏼‍🎨👨🏽‍🎨👨🏾‍🎨👨🏿‍🎨👩‍🎨👩🏻‍🎨👩🏼‍🎨👩🏽‍🎨👩🏾‍🎨👩🏿‍🎨👨‍✈️👨‍✈👨🏻‍✈️👨🏻‍✈👨🏼‍✈️👨🏼‍✈👨🏽‍✈️👨🏽‍✈👨🏾‍✈️👨🏾‍✈👨🏿‍✈️👨🏿‍✈👩‍✈️👩‍✈👩🏻‍✈️👩🏻‍✈👩🏼‍✈️👩🏼‍✈👩🏽‍✈️👩🏽‍✈👩🏾‍✈️👩🏾‍✈👩🏿‍✈️👩🏿‍✈👨‍🚀👨🏻‍🚀👨🏼‍🚀👨🏽‍🚀👨🏾‍🚀👨🏿‍🚀👩‍🚀👩🏻‍🚀👩🏼‍🚀👩🏽‍🚀👩🏾‍🚀👩🏿‍🚀👨‍🚒👨🏻‍🚒👨🏼‍🚒👨🏽‍🚒👨🏾‍🚒👨🏿‍🚒👩‍🚒👩🏻‍🚒👩🏼‍🚒👩🏽‍🚒👩🏾‍🚒👩🏿‍🚒👮👮🏻👮🏼👮🏽👮🏾👮🏿👮‍♂️👮‍♂👮🏻‍♂️👮🏻‍♂👮🏼‍♂️👮🏼‍♂👮🏽‍♂️👮🏽‍♂👮🏾‍♂️👮🏾‍♂👮🏿‍♂️👮🏿‍♂👮‍♀️👮‍♀👮🏻‍♀️👮🏻‍♀👮🏼‍♀️👮🏼‍♀👮🏽‍♀️👮🏽‍♀👮🏾‍♀️👮🏾‍♀👮🏿‍♀️👮🏿‍♀🕵️🕵🕵🏻🕵🏼🕵🏽🕵🏾🕵🏿🕵️‍♂️🕵‍♂️🕵️‍♂🕵‍♂🕵🏻‍♂️🕵🏻‍♂🕵🏼‍♂️🕵🏼‍♂🕵🏽‍♂️🕵🏽‍♂🕵🏾‍♂️🕵🏾‍♂🕵🏿‍♂️🕵🏿‍♂🕵️‍♀️🕵‍♀️🕵️‍♀🕵‍♀🕵🏻‍♀️🕵🏻‍♀🕵🏼‍♀️🕵🏼‍♀🕵🏽‍♀️🕵🏽‍♀🕵🏾‍♀️🕵🏾‍♀🕵🏿‍♀️🕵🏿‍♀💂💂🏻💂🏼💂🏽💂🏾💂🏿💂‍♂️💂‍♂💂🏻‍♂️💂🏻‍♂💂🏼‍♂️💂🏼‍♂💂🏽‍♂️💂🏽‍♂💂🏾‍♂️💂🏾‍♂💂🏿‍♂️💂🏿‍♂💂‍♀️💂‍♀💂🏻‍♀️💂🏻‍♀💂🏼‍♀️💂🏼‍♀💂🏽‍♀️💂🏽‍♀💂🏾‍♀️💂🏾‍♀💂🏿‍♀️💂🏿‍♀👷👷🏻👷🏼👷🏽👷🏾👷🏿👷‍♂️👷‍♂👷🏻‍♂️👷🏻‍♂👷🏼‍♂️👷🏼‍♂👷🏽‍♂️👷🏽‍♂👷🏾‍♂️👷🏾‍♂👷🏿‍♂️👷🏿‍♂👷‍♀️👷‍♀👷🏻‍♀️👷🏻‍♀👷🏼‍♀️👷🏼‍♀👷🏽‍♀️👷🏽‍♀👷🏾‍♀️👷🏾‍♀👷🏿‍♀️👷🏿‍♀🤴🤴🏻🤴🏼🤴🏽🤴🏾🤴🏿👸👸🏻👸🏼👸🏽👸🏾👸🏿👳👳🏻👳🏼👳🏽👳🏾👳🏿👳‍♂️👳‍♂👳🏻‍♂️👳🏻‍♂👳🏼‍♂️👳🏼‍♂👳🏽‍♂️👳🏽‍♂👳🏾‍♂️👳🏾‍♂👳🏿‍♂️👳🏿‍♂👳‍♀️👳‍♀👳🏻‍♀️👳🏻‍♀👳🏼‍♀️👳🏼‍♀👳🏽‍♀️👳🏽‍♀👳🏾‍♀️👳🏾‍♀👳🏿‍♀️👳🏿‍♀👲👲🏻👲🏼👲🏽👲🏾👲🏿🧕🧕🏻🧕🏼🧕🏽🧕🏾🧕🏿🧔🧔🏻🧔🏼🧔🏽🧔🏾🧔🏿👱👱🏻👱🏼👱🏽👱🏾👱🏿👱‍♂️👱‍♂👱🏻‍♂️👱🏻‍♂👱🏼‍♂️👱🏼‍♂👱🏽‍♂️👱🏽‍♂👱🏾‍♂️👱����‍♂👱🏿‍♂️👱🏿‍♂👱‍♀️👱‍♀👱🏻‍♀️👱🏻‍♀👱🏼‍♀️👱🏼‍♀👱🏽‍♀️👱🏽‍♀👱🏾‍♀️👱🏾‍♀👱🏿‍♀️👱🏿‍♀👨‍🦰👨🏻‍🦰👨🏼‍🦰👨🏽‍🦰👨🏾‍🦰👨🏿‍🦰👩‍🦰👩🏻‍🦰👩🏼‍🦰👩🏽‍🦰👩🏾‍🦰👩🏿‍🦰👨‍🦱👨🏻‍🦱👨🏼‍🦱👨🏽‍🦱👨🏾‍🦱👨🏿‍🦱👩‍🦱👩🏻‍🦱👩🏼‍🦱👩🏽‍🦱👩🏾‍🦱👩🏿‍🦱👨‍🦲👨🏻‍🦲👨🏼‍🦲👨🏽‍🦲👨🏾‍🦲👨🏿‍🦲👩‍🦲👩🏻‍🦲👩🏼‍🦲👩🏽‍🦲👩🏾‍🦲👩🏿‍🦲👨‍🦳👨🏻‍🦳👨🏼‍🦳👨🏽‍🦳👨🏾‍🦳👨🏿‍🦳👩‍🦳👩🏻‍🦳👩🏼‍🦳👩🏽‍🦳👩🏾‍🦳👩🏿‍🦳🤵🤵🏻🤵🏼🤵🏽🤵🏾🤵🏿👰👰🏻👰🏼👰🏽👰🏾👰🏿🤰🤰🏻🤰🏼🤰🏽🤰🏾🤰🏿🤱🤱🏻🤱🏼🤱🏽🤱🏾🤱🏿👼👼🏻👼🏼👼🏽👼🏾👼🏿🎅🎅🏻🎅🏼🎅🏽🎅🏾🎅🏿🤶🤶🏻🤶🏼🤶🏽🤶🏾🤶🏿🦸🦸🏻🦸🏼🦸🏽🦸🏾🦸🏿🦸‍♀️🦸‍♀🦸🏻‍♀️🦸🏻‍♀🦸🏼‍♀️🦸🏼‍♀🦸🏽‍♀️🦸🏽‍♀🦸🏾‍♀️🦸🏾‍♀🦸🏿‍♀️🦸🏿‍♀🦸‍♂️🦸‍♂🦸🏻‍♂️🦸🏻‍♂🦸🏼‍♂️🦸🏼‍♂🦸🏽‍♂️🦸🏽‍♂🦸🏾‍♂️🦸🏾‍♂🦸🏿‍♂️🦸🏿‍♂🦹🦹🏻🦹🏼🦹🏽🦹🏾🦹🏿🦹‍♀️🦹‍♀🦹🏻‍♀️🦹🏻‍♀🦹🏼‍♀️🦹🏼‍♀🦹🏽‍♀️🦹🏽‍♀🦹🏾‍♀️🦹🏾‍♀🦹🏿‍♀️🦹🏿‍♀🦹‍♂️🦹‍♂🦹🏻‍♂️🦹🏻‍♂🦹🏼‍♂️🦹🏼‍♂🦹🏽‍♂️🦹🏽‍♂🦹🏾‍♂️🦹🏾‍♂🦹🏿‍♂️🦹🏿‍♂🧙🧙🏻🧙🏼🧙🏽🧙🏾🧙🏿🧙‍♀️🧙‍♀🧙🏻‍♀️🧙🏻‍♀🧙🏼‍♀️🧙🏼‍♀🧙🏽‍♀️🧙🏽‍♀🧙🏾‍♀️🧙🏾‍♀🧙🏿‍♀️🧙🏿‍♀🧙‍♂️🧙‍♂🧙🏻‍♂️🧙🏻‍♂🧙🏼‍♂️🧙🏼‍♂🧙🏽‍♂️🧙🏽‍♂🧙🏾‍♂️🧙🏾‍♂🧙🏿‍♂️🧙🏿‍♂🧚🧚🏻🧚🏼🧚🏽🧚🏾🧚🏿🧚‍♀️🧚‍♀🧚🏻‍♀️🧚🏻‍♀🧚🏼‍♀️🧚🏼‍♀🧚🏽‍♀️🧚🏽‍♀🧚🏾‍♀️🧚🏾‍♀🧚🏿‍♀️🧚🏿‍♀🧚‍♂️🧚‍♂🧚🏻‍♂️🧚🏻‍♂🧚🏼‍♂️🧚🏼‍♂🧚🏽‍♂️🧚🏽‍♂🧚🏾‍♂️🧚🏾‍♂🧚🏿‍♂️🧚🏿‍♂🧛🧛🏻🧛🏼🧛🏽🧛🏾🧛🏿🧛‍♀️🧛‍♀🧛🏻‍♀️🧛🏻‍♀🧛🏼‍♀️🧛🏼‍♀🧛🏽‍♀️🧛🏽‍♀🧛🏾‍♀️🧛🏾‍♀🧛🏿‍♀️🧛🏿‍♀🧛‍♂️🧛‍♂🧛🏻‍♂️🧛🏻‍♂🧛🏼‍♂️🧛🏼‍♂🧛🏽‍♂️🧛🏽‍♂🧛🏾‍♂️🧛🏾‍♂🧛🏿‍♂️🧛🏿‍♂🧜🧜🏻🧜🏼🧜🏽🧜🏾🧜🏿🧜‍♀️🧜‍♀🧜🏻‍♀️🧜🏻‍♀🧜🏼‍♀️🧜🏼‍♀🧜🏽‍♀️🧜🏽‍♀🧜🏾‍♀️🧜🏾‍♀🧜🏿‍♀️🧜🏿‍♀🧜‍♂️🧜‍♂🧜🏻‍♂️🧜🏻‍♂🧜🏼‍♂️🧜🏼‍♂🧜🏽‍♂️🧜🏽‍♂🧜🏾‍♂️🧜🏾‍♂🧜🏿‍♂️🧜🏿‍♂🧝🧝🏻🧝🏼🧝🏽🧝🏾🧝🏿🧝‍♀️🧝‍♀🧝🏻‍♀️🧝🏻‍♀🧝🏼‍♀️🧝🏼‍♀🧝🏽‍♀️🧝🏽‍♀🧝🏾‍♀️🧝🏾‍♀🧝🏿‍♀️🧝🏿‍♀🧝‍♂️🧝‍♂🧝🏻‍♂️🧝🏻‍♂🧝🏼‍♂️🧝🏼‍♂🧝🏽‍♂️🧝🏽‍♂🧝🏾‍♂️🧝🏾‍♂🧝🏿‍♂️🧝🏿‍♂🧞🧞‍♀️🧞‍♀🧞‍♂️🧞‍♂🧟🧟‍♀️🧟‍♀🧟‍♂️🧟‍♂🙍🙍🏻🙍🏼🙍🏽🙍🏾🙍🏿🙍‍♂️🙍‍♂🙍🏻‍♂️🙍🏻‍♂🙍🏼‍♂️🙍🏼‍♂🙍🏽‍♂️🙍🏽‍♂🙍🏾‍♂️🙍🏾‍♂🙍🏿‍♂️🙍🏿‍♂🙍‍♀️🙍‍♀🙍🏻‍♀️🙍🏻‍♀🙍🏼‍♀️🙍🏼‍♀🙍🏽‍♀️🙍🏽‍♀🙍🏾‍♀️🙍🏾‍♀🙍🏿‍♀️🙍🏿‍♀🙎🙎🏻🙎🏼🙎🏽🙎🏾🙎🏿🙎‍♂️🙎‍♂🙎🏻‍♂️🙎🏻‍♂🙎🏼‍♂️🙎🏼‍♂🙎🏽‍♂️🙎🏽‍♂🙎🏾‍♂️🙎🏾‍♂🙎🏿‍♂️🙎🏿‍♂🙎‍♀️🙎‍♀🙎🏻‍♀️🙎🏻‍♀🙎🏼‍♀️🙎🏼‍♀🙎🏽‍♀️🙎🏽‍♀🙎🏾‍♀️🙎🏾‍♀🙎🏿‍♀️🙎🏿‍♀🙅🙅🏻🙅🏼🙅🏽🙅🏾🙅🏿🙅‍♂️🙅‍♂🙅🏻‍♂️🙅🏻‍♂🙅🏼‍♂️🙅🏼‍♂🙅🏽‍♂️🙅🏽‍♂🙅🏾‍♂️🙅🏾‍♂🙅🏿‍♂���🙅🏿‍♂🙅‍♀️🙅‍♀🙅🏻‍♀️🙅🏻‍♀🙅🏼‍♀️🙅🏼‍♀🙅🏽‍♀️🙅🏽‍♀🙅🏾‍♀️🙅🏾‍♀🙅🏿‍♀️🙅🏿‍♀🙆🙆🏻🙆🏼🙆🏽🙆🏾🙆🏿🙆‍♂️🙆‍♂🙆🏻‍♂️🙆🏻‍♂🙆🏼‍♂️🙆🏼‍♂🙆🏽‍♂️🙆🏽‍♂🙆🏾‍♂️🙆🏾‍♂🙆🏿‍♂️🙆🏿‍♂🙆‍♀️🙆‍♀🙆🏻‍♀️🙆🏻‍♀🙆🏼‍♀️🙆🏼‍♀🙆🏽‍♀️🙆🏽‍♀🙆🏾‍♀️🙆🏾‍♀🙆🏿‍♀️🙆🏿‍♀💁💁🏻💁🏼💁🏽💁🏾💁🏿💁‍♂️💁‍♂💁🏻‍♂️💁🏻‍♂💁🏼‍♂️💁🏼‍♂💁🏽‍♂️💁🏽‍♂💁🏾‍♂️💁🏾‍♂💁🏿‍♂️💁🏿‍♂💁‍♀️💁‍♀💁🏻‍♀️💁🏻‍♀💁🏼‍♀️💁🏼‍♀💁🏽‍♀️💁🏽‍♀💁🏾‍♀️💁🏾‍♀💁🏿‍♀️💁🏿‍♀🙋🙋🏻🙋🏼🙋🏽🙋🏾🙋🏿🙋‍♂️🙋‍♂🙋🏻‍♂️🙋🏻‍♂🙋🏼‍♂️🙋🏼‍♂🙋🏽‍♂️🙋🏽‍♂🙋🏾‍♂️🙋🏾‍♂🙋🏿‍♂️🙋🏿‍♂🙋‍♀️🙋‍♀🙋🏻‍♀️🙋🏻‍♀🙋🏼‍♀️🙋🏼‍♀🙋🏽‍♀️🙋🏽‍♀🙋🏾‍♀️🙋🏾‍♀🙋🏿‍♀️🙋🏿‍♀🙇🙇🏻🙇🏼🙇🏽🙇🏾🙇🏿🙇‍♂️🙇‍♂🙇🏻‍♂️🙇🏻‍♂🙇🏼‍♂️🙇🏼‍♂🙇🏽‍♂️🙇🏽‍♂🙇🏾‍♂️🙇🏾‍♂🙇🏿‍♂️🙇🏿‍♂🙇‍♀️🙇‍♀🙇🏻‍♀️🙇🏻‍♀🙇🏼‍♀️🙇🏼‍♀🙇🏽‍♀️🙇🏽‍♀🙇🏾‍♀️🙇🏾‍♀🙇🏿‍♀️🙇🏿‍♀🤦🤦🏻🤦🏼🤦🏽🤦🏾🤦🏿🤦‍♂️🤦‍♂🤦🏻‍♂️🤦🏻‍♂🤦🏼‍♂️🤦🏼‍♂🤦🏽‍♂️🤦🏽‍♂🤦🏾‍♂️🤦🏾‍♂🤦🏿‍♂️🤦🏿‍♂🤦‍♀️🤦‍♀🤦🏻‍♀️🤦🏻‍♀🤦🏼‍♀️🤦🏼‍♀🤦🏽‍♀️🤦🏽‍♀🤦🏾‍♀️🤦🏾‍♀🤦🏿‍♀️🤦🏿‍♀🤷🤷🏻🤷🏼🤷🏽🤷🏾🤷🏿🤷‍♂️🤷‍♂🤷🏻‍♂️🤷🏻‍♂🤷🏼‍♂️🤷🏼‍♂🤷🏽‍♂️🤷🏽‍♂🤷🏾‍♂️🤷🏾‍♂🤷🏿‍♂️🤷🏿‍♂🤷‍♀️🤷‍♀🤷🏻‍♀️🤷🏻‍♀🤷🏼‍♀️🤷🏼‍♀🤷🏽‍♀️🤷🏽‍♀🤷🏾‍♀️🤷🏾‍♀🤷🏿‍♀️🤷🏿‍♀💆💆🏻💆🏼💆🏽💆🏾💆🏿💆‍♂️💆‍♂💆🏻‍♂️💆🏻‍♂💆🏼‍♂️💆🏼‍♂💆🏽‍♂️💆🏽‍♂💆🏾‍♂️💆🏾‍♂💆🏿‍♂️💆🏿‍♂💆‍♀️💆‍♀💆🏻‍♀️💆🏻‍♀💆🏼‍♀️💆🏼‍♀💆🏽‍♀️💆🏽‍♀💆🏾‍♀️💆🏾‍♀💆🏿‍♀️💆🏿‍♀💇💇🏻💇🏼💇🏽💇🏾💇🏿💇‍♂️💇‍♂💇🏻‍♂️💇🏻‍♂💇🏼‍♂️💇🏼‍♂💇🏽‍♂️💇🏽‍♂💇🏾‍♂️💇🏾‍♂💇🏿‍♂️💇🏿‍♂💇‍♀️💇‍♀💇🏻‍♀️💇🏻‍♀💇🏼‍♀️💇🏼‍♀💇🏽‍♀️💇🏽‍♀💇🏾‍♀️💇🏾‍♀💇🏿‍♀️💇🏿‍♀🚶🚶🏻🚶🏼🚶🏽🚶🏾🚶🏿🚶‍♂️🚶‍♂🚶🏻‍♂️🚶🏻‍♂🚶🏼‍♂️🚶🏼‍♂🚶🏽‍♂️🚶🏽‍♂🚶🏾‍♂️🚶🏾‍♂🚶🏿‍♂️🚶🏿‍♂🚶‍♀️🚶‍♀🚶🏻‍♀️🚶🏻‍♀🚶🏼‍♀️🚶🏼‍♀🚶🏽‍♀️🚶🏽‍♀🚶🏾‍♀️🚶🏾‍♀🚶🏿‍♀️🚶🏿‍♀🏃🏃🏻🏃🏼🏃🏽🏃🏾🏃🏿🏃‍♂️🏃‍♂🏃🏻‍♂️🏃🏻‍♂🏃🏼‍♂️🏃🏼‍♂🏃🏽‍♂️🏃🏽‍♂🏃🏾‍♂️🏃🏾‍♂🏃🏿‍♂️🏃🏿‍♂🏃‍♀️🏃‍♀🏃🏻‍♀️🏃🏻‍♀🏃🏼‍♀️🏃🏼‍♀🏃🏽‍♀️🏃🏽‍♀🏃🏾‍♀️🏃🏾‍♀🏃🏿‍♀️🏃🏿‍♀💃💃🏻💃🏼💃🏽💃🏾💃🏿🕺🕺🏻🕺🏼🕺🏽🕺🏾🕺🏿👯👯‍♂️👯‍♂👯‍♀️👯‍♀🧖🧖🏻🧖🏼🧖🏽🧖🏾🧖🏿🧖‍♀️🧖‍♀🧖🏻‍♀️🧖🏻‍♀🧖🏼‍♀️🧖🏼‍♀🧖🏽‍♀️🧖🏽‍♀🧖🏾‍♀️🧖🏾‍♀🧖🏿‍♀️🧖🏿‍♀🧖‍♂️🧖‍♂🧖🏻‍♂️🧖🏻‍♂🧖🏼‍♂️🧖🏼‍♂🧖🏽‍♂️🧖🏽‍♂🧖🏾‍♂️🧖🏾‍♂🧖🏿‍♂️🧖🏿‍♂🧗🧗🏻🧗🏼🧗🏽🧗🏾🧗🏿🧗‍♀️🧗‍♀🧗🏻‍♀️🧗🏻‍♀🧗🏼‍♀️🧗🏼‍♀🧗🏽‍♀️🧗🏽‍♀🧗🏾‍♀️🧗🏾‍♀🧗🏿‍♀️🧗🏿‍♀🧗‍♂️🧗‍♂🧗🏻‍♂️🧗🏻‍♂🧗🏼‍♂️🧗🏼‍♂🧗🏽‍♂️🧗🏽‍♂🧗🏾‍♂️🧗🏾‍♂🧗🏿‍♂️���🏿‍♂🧘🧘🏻🧘🏼🧘🏽🧘🏾🧘🏿🧘‍♀️🧘‍♀🧘🏻‍♀️🧘🏻‍♀🧘🏼‍♀️🧘🏼‍♀🧘🏽‍♀️🧘🏽‍♀🧘🏾‍♀️🧘🏾‍♀🧘🏿‍♀️🧘🏿‍♀🧘‍♂️🧘‍♂🧘🏻‍♂️🧘🏻‍♂🧘🏼‍♂️🧘🏼‍♂🧘🏽‍♂️🧘🏽‍♂🧘🏾‍♂️🧘🏾‍♂🧘🏿‍♂️🧘🏿‍♂🛀🛀🏻🛀🏼🛀🏽🛀🏾🛀🏿🛌🛌🏻🛌🏼🛌🏽🛌🏾🛌🏿🕴️🕴🕴🏻🕴🏼🕴🏽🕴🏾🕴🏿🗣️🗣👤👥🤺🏇🏇🏻🏇🏼🏇🏽🏇🏾🏇🏿⛷️⛷🏂🏂🏻🏂🏼🏂🏽🏂🏾🏂🏿🏌️🏌🏌🏻🏌🏼🏌🏽🏌🏾🏌🏿🏌️‍♂️🏌‍♂️🏌️‍♂🏌‍♂🏌🏻‍♂️🏌🏻‍♂🏌🏼‍♂️🏌🏼‍♂🏌🏽‍♂️🏌🏽‍♂🏌🏾‍♂️🏌🏾‍♂🏌🏿‍♂️🏌🏿‍♂🏌️‍♀️🏌‍♀️🏌️‍♀🏌‍♀🏌🏻‍♀️🏌🏻‍♀🏌🏼‍♀️🏌🏼‍♀🏌🏽‍♀️🏌🏽‍♀🏌🏾‍♀️🏌🏾‍♀🏌🏿‍♀️🏌🏿‍♀🏄🏄🏻🏄🏼🏄🏽🏄🏾🏄🏿🏄‍♂️🏄‍♂🏄🏻‍♂️🏄🏻‍♂🏄🏼‍♂️🏄🏼‍♂🏄🏽‍♂️🏄🏽‍♂🏄🏾‍♂️🏄🏾‍♂🏄🏿‍♂️🏄🏿‍♂🏄‍♀️🏄‍♀🏄🏻‍♀️🏄🏻‍♀🏄🏼‍♀️🏄🏼‍♀🏄🏽‍♀️🏄🏽‍♀🏄🏾‍♀️🏄🏾‍♀🏄🏿‍♀️🏄🏿‍♀🚣🚣🏻🚣🏼🚣🏽🚣🏾🚣🏿🚣‍♂️🚣‍♂🚣🏻‍♂️🚣🏻‍♂🚣🏼‍♂️🚣🏼‍♂🚣🏽‍♂️🚣🏽‍♂🚣🏾‍♂️🚣🏾‍♂🚣🏿‍♂️🚣🏿‍♂🚣‍♀️🚣‍♀🚣🏻‍♀️🚣🏻‍♀🚣🏼‍♀️🚣🏼‍♀🚣🏽‍♀️🚣🏽‍♀🚣🏾‍♀️🚣🏾‍♀🚣🏿‍♀️🚣🏿‍♀🏊🏊🏻🏊🏼🏊🏽🏊🏾🏊🏿🏊‍♂️🏊‍♂🏊🏻‍♂️🏊🏻‍♂🏊🏼‍♂️🏊🏼‍♂🏊🏽‍♂️🏊🏽‍♂🏊🏾‍♂️🏊🏾‍♂🏊🏿‍♂️🏊🏿‍♂🏊‍♀️🏊‍♀🏊🏻‍♀️🏊🏻‍♀🏊🏼‍♀️🏊🏼‍♀🏊🏽‍♀️🏊🏽‍♀🏊🏾‍♀️🏊🏾‍♀🏊🏿‍♀️🏊🏿‍♀⛹️⛹⛹🏻⛹🏼⛹🏽⛹🏾⛹🏿⛹️‍♂️⛹‍♂️⛹️‍♂⛹‍♂⛹🏻‍♂️⛹🏻‍♂⛹🏼‍♂️⛹🏼‍♂⛹🏽‍♂️⛹🏽‍♂⛹🏾‍♂️⛹🏾‍♂⛹🏿‍♂️⛹🏿‍♂⛹️‍♀️⛹‍♀️⛹️‍♀⛹‍♀⛹🏻‍♀️⛹🏻‍♀⛹🏼‍♀️⛹🏼‍♀⛹🏽‍♀️⛹🏽‍♀⛹🏾‍♀️⛹🏾‍♀⛹🏿‍♀️⛹🏿‍♀🏋️🏋🏋🏻🏋🏼🏋🏽🏋🏾🏋🏿🏋️‍♂️🏋‍♂️🏋️‍♂🏋‍♂🏋🏻‍♂️🏋🏻‍♂🏋🏼‍♂️🏋🏼‍♂🏋🏽‍♂️🏋🏽‍♂🏋🏾‍♂️🏋🏾‍♂🏋🏿‍♂️🏋🏿‍♂🏋️‍♀️🏋‍♀️🏋️‍♀🏋‍♀🏋🏻‍♀️🏋🏻‍♀🏋🏼‍♀️🏋🏼‍♀🏋🏽‍♀️🏋🏽‍♀🏋🏾‍♀️🏋🏾‍♀🏋🏿‍♀️🏋🏿‍♀🚴🚴🏻🚴🏼🚴🏽🚴🏾🚴🏿🚴‍♂️🚴‍♂🚴🏻‍♂️🚴🏻‍♂🚴🏼‍♂️🚴🏼‍♂🚴🏽‍♂️🚴🏽‍♂🚴🏾‍♂️🚴🏾‍♂🚴🏿‍♂️🚴🏿‍♂🚴‍♀️🚴‍♀🚴🏻‍♀️🚴🏻‍♀🚴🏼‍♀️🚴🏼‍♀🚴🏽‍♀️🚴🏽‍♀🚴🏾‍♀️🚴🏾‍♀🚴🏿‍♀️🚴🏿‍♀🚵🚵🏻🚵🏼🚵🏽🚵🏾🚵🏿🚵‍♂️🚵‍♂🚵🏻‍♂️🚵🏻‍♂🚵🏼‍♂️🚵🏼‍♂🚵🏽‍♂️🚵🏽‍♂🚵🏾‍♂️🚵🏾‍♂🚵🏿‍♂️🚵🏿‍♂🚵‍♀️🚵‍♀🚵🏻‍♀️🚵🏻‍♀🚵🏼‍♀️🚵🏼‍♀🚵🏽‍♀️🚵🏽‍♀🚵🏾‍♀️🚵🏾‍♀🚵🏿‍♀️🚵🏿‍♀🏎️🏎🏍️🏍🤸🤸🏻🤸🏼🤸🏽🤸🏾🤸🏿🤸‍♂️🤸‍♂🤸🏻‍♂️🤸🏻‍♂🤸🏼‍♂️🤸🏼‍♂🤸🏽‍♂️🤸🏽‍♂🤸🏾‍♂️🤸🏾‍♂🤸🏿‍♂️🤸🏿‍♂🤸‍♀️🤸‍♀🤸🏻‍♀️🤸🏻‍♀🤸🏼‍♀️🤸🏼‍♀🤸🏽‍♀️🤸🏽‍♀🤸🏾‍♀️🤸🏾‍♀🤸🏿‍♀️🤸🏿‍♀🤼🤼‍♂️🤼‍♂🤼‍♀️🤼‍♀🤽🤽🏻🤽🏼🤽🏽🤽🏾🤽🏿🤽‍♂️🤽‍♂🤽🏻‍♂️🤽🏻‍♂🤽🏼‍♂️🤽🏼‍♂🤽🏽‍♂️🤽🏽‍♂🤽🏾‍♂️🤽🏾‍♂🤽🏿‍♂️🤽🏿‍♂🤽‍♀️🤽‍♀🤽🏻‍♀️🤽🏻‍♀🤽🏼‍♀️🤽🏼‍♀🤽🏽‍♀️🤽🏽‍♀🤽🏾‍♀️🤽🏾‍♀🤽🏿‍♀️🤽🏿‍♀🤾🤾🏻🤾🏼🤾🏽🤾🏾🤾🏿🤾‍♂️🤾‍♂🤾🏻‍♂️🤾🏻‍♂🤾🏼‍♂️🤾🏼‍♂🤾🏽‍♂️🤾🏽‍♂🤾🏾‍♂️🤾🏾‍♂🤾🏿‍♂️🤾🏿���♂🤾‍♀️🤾‍♀🤾🏻‍♀️🤾🏻‍♀🤾🏼‍♀️🤾🏼‍♀🤾🏽‍♀️🤾🏽‍♀🤾🏾‍♀️🤾🏾‍♀🤾🏿‍♀️🤾🏿‍♀🤹🤹🏻🤹🏼🤹🏽🤹🏾🤹🏿🤹‍♂️🤹‍♂🤹🏻‍♂️🤹🏻‍♂🤹🏼‍♂️🤹🏼‍♂🤹🏽‍♂️🤹🏽‍♂🤹🏾‍♂️🤹🏾‍♂🤹🏿‍♂️🤹🏿‍♂🤹‍♀️🤹‍♀🤹🏻‍♀️🤹🏻‍♀🤹🏼‍♀️🤹🏼‍♀🤹🏽‍♀️🤹🏽‍♀🤹🏾‍♀️🤹🏾‍♀🤹🏿‍♀️🤹🏿‍♀👫👬👭💏👩‍❤️‍💋‍👨👩‍❤‍💋‍👨👨‍❤️‍💋‍👨👨‍❤‍💋‍👨👩‍❤️‍💋‍👩👩‍❤‍💋‍👩💑👩‍❤️‍👨👩‍❤‍👨👨‍❤️‍👨👨‍❤‍👨👩‍❤️‍👩👩‍❤‍👩👪👨‍👩‍👦👨‍👩‍👧👨‍👩‍👧‍👦👨‍👩‍👦‍👦👨‍👩‍👧‍👧👨‍👨‍👦👨‍👨‍👧👨‍👨‍👧‍👦👨‍👨‍👦‍👦👨‍👨‍👧‍👧👩‍👩‍👦👩‍👩‍👧👩‍👩‍👧‍👦👩‍👩‍👦‍👦👩‍👩‍👧‍👧👨‍👦👨‍👦‍👦👨‍👧👨‍👧‍👦👨‍👧‍👧👩‍👦👩‍👦‍👦👩‍👧👩‍👧‍👦👩‍👧‍👧🤳🤳🏻🤳🏼🤳🏽🤳🏾🤳🏿💪💪🏻💪🏼💪🏽💪🏾💪🏿🦵🦵🏻🦵🏼🦵🏽🦵🏾🦵🏿🦶🦶🏻🦶🏼🦶🏽🦶🏾🦶🏿👈👈🏻👈🏼👈🏽👈🏾👈🏿👉👉🏻👉🏼👉🏽👉🏾👉🏿☝️☝☝🏻☝🏼☝🏽☝🏾☝🏿👆👆🏻👆🏼👆🏽👆🏾👆🏿🖕🖕🏻🖕🏼🖕🏽🖕🏾🖕🏿👇👇🏻👇🏼👇🏽👇🏾👇🏿✌️✌✌🏻✌🏼✌🏽✌🏾✌🏿🤞🤞🏻🤞🏼🤞🏽🤞🏾🤞🏿🖖🖖🏻🖖🏼🖖🏽🖖🏾🖖🏿🤘🤘🏻🤘🏼🤘🏽🤘🏾🤘🏿🤙🤙🏻🤙🏼🤙🏽🤙🏾🤙🏿🖐️🖐🖐🏻🖐🏼🖐🏽🖐🏾🖐🏿✋✋🏻✋🏼✋🏽✋🏾✋🏿👌👌🏻👌🏼👌🏽👌🏾👌🏿👍👍🏻👍🏼👍🏽👍🏾👍🏿👎👎🏻👎🏼👎🏽👎🏾👎🏿✊✊🏻✊🏼✊🏽✊🏾✊🏿👊👊🏻👊🏼👊🏽👊🏾👊🏿🤛🤛🏻🤛🏼🤛🏽🤛🏾🤛🏿🤜🤜🏻🤜🏼🤜🏽🤜🏾🤜🏿🤚🤚🏻🤚🏼🤚🏽🤚🏾🤚🏿👋👋🏻👋🏼👋🏽👋🏾👋🏿🤟🤟🏻🤟🏼🤟🏽🤟🏾🤟🏿✍️✍✍🏻✍🏼✍🏽✍🏾✍🏿👏👏🏻👏🏼👏🏽👏🏾👏🏿👐👐🏻👐🏼👐🏽👐🏾👐🏿🙌🙌🏻🙌🏼🙌🏽🙌🏾🙌🏿🤲🤲🏻🤲🏼🤲🏽🤲🏾🤲🏿🙏🙏🏻🙏🏼🙏🏽🙏🏾🙏🏿🤝💅💅🏻💅🏼💅🏽💅🏾💅🏿👂👂🏻👂🏼👂🏽👂🏾👂🏿👃👃🏻👃🏼👃🏽👃🏾👃🏿🦰🦱🦲🦳👣👀👁️👁👁️‍🗨️👁‍🗨️👁️‍🗨👁‍🗨🧠🦴🦷👅👄💋💘❤️❤💓💔💕💖💗💙💚💛🧡💜🖤💝💞💟❣️❣💌💤💢💣💥💦💨💫💬🗨️🗨🗯️🗯💭🕳️🕳👓🕶️🕶🥽🥼👔👕👖🧣🧤🧥🧦👗👘👙👚👛👜👝🛍️🛍🎒👞👟🥾🥿👠👡👢👑👒🎩🎓🧢⛑️⛑📿💄💍💎🐵🐒🦍🐶🐕🐩🐺🦊🦝🐱🐈🦁🐯🐅🐆🐴🐎🦄🦓🦌🐮🐂🐃🐄🐷🐖🐗🐽🐏🐑🐐🐪🐫🦙🦒🐘🦏🦛🐭🐁🐀🐹🐰🐇🐿️🐿🦔🦇🐻🐨🐼🦘🦡🐾🦃🐔🐓🐣🐤🐥🐦🐧🕊️🕊🦅🦆🦢🦉🦚🦜🐸🐊🐢🦎🐍🐲🐉🦕🦖🐳🐋🐬🐟🐠🐡🦈🐙🐚🦀🦞🦐🦑🐌🦋🐛🐜🐝🐞🦗🕷️🕷🕸️🕸🦂🦟🦠💐🌸💮🏵️🏵🌹🥀🌺🌻🌼🌷🌱🌲🌳🌴🌵🌾🌿☘️☘🍀🍁🍂🍃🍇🍈🍉🍊🍋🍌🍍🥭🍎🍏🍐🍑🍒🍓🥝🍅🥥🥑🍆🥔🥕🌽🌶️🌶🥒🥬🥦🍄🥜🌰🍞🥐🥖🥨🥯🥞🧀🍖🍗🥩🥓🍔🍟🍕🌭🥪🌮🌯🥙🥚🍳🥘🍲🥣🥗🍿🧂🥫🍱🍘🍙🍚🍛🍜🍝🍠🍢🍣🍤🍥🥮🍡🥟🥠🥡🍦🍧🍨🍩🍪🎂🍰🧁🥧🍫🍬🍭🍮🍯🍼🥛☕🍵🍶🍾🍷🍸🍹🍺🍻🥂🥃🥤🥢🍽️🍽🍴🥄🔪🏺🌍🌎🌏🌐🗺️🗺🗾🧭🏔️🏔⛰️⛰🌋🗻🏕️🏕🏖️🏖🏜️🏜🏝️🏝🏞️🏞🏟️🏟🏛️🏛🏗️🏗🧱🏘️🏘🏚️🏚🏠🏡🏢🏣🏤🏥🏦🏨🏩🏪🏫🏬🏭🏯🏰💒🗼🗽⛪🕌🕍⛩️⛩🕋⛲⛺🌁🌃🏙️🏙🌄🌅🌆🌇🌉♨️♨🌌🎠🎡🎢💈🎪🚂🚃🚄🚅🚆🚇🚈🚉🚊🚝🚞🚋🚌🚍🚎🚐🚑🚒🚓🚔🚕🚖🚗🚘🚙🚚🚛🚜🚲🛴🛹🛵🚏🛣️🛣🛤️🛤🛢️🛢⛽🚨🚥🚦🛑🚧⚓⛵🛶🚤🛳️🛳⛴️⛴🛥️🛥🚢✈️✈🛩️🛩🛫🛬💺🚁🚟🚠🚡🛰️🛰🚀🛸🛎️🛎🧳⌛⏳⌚⏰⏱️⏱⏲️⏲🕰️🕰🕛🕧🕐🕜🕑🕝🕒🕞🕓🕟🕔🕠🕕🕡🕖🕢🕗🕣🕘🕤🕙🕥🕚🕦🌑🌒🌓🌔🌕🌖🌗🌘🌙🌚🌛🌜🌡️🌡☀️☀🌝🌞⭐🌟🌠☁️☁⛅⛈️⛈🌤️🌤🌥️🌥🌦️🌦🌧️🌧🌨️🌨🌩️🌩🌪️🌪🌫️🌫🌬️🌬🌀🌈🌂☂️☂☔⛱️⛱⚡❄️❄☃️☃⛄☄️☄🔥💧🌊🎃🎄🎆🎇🧨✨🎈🎉🎊🎋🎍🎎🎏🎐🎑🧧🎀🎁🎗️🎗🎟️🎟🎫🎖️🎖🏆🏅🥇🥈🥉⚽⚾🥎🏀🏐🏈🏉🎾🥏🎳🏏🏑🏒🥍🏓🏸🥊🥋🥅⛳⛸️⛸🎣🎽🎿🛷🥌🎯🎱🔮🧿🎮🕹️🕹🎰🎲🧩🧸♠️♠♥️♥♦️♦♣️♣♟️♟🃏🀄🎴🎭🖼️🖼🎨🧵🧶🔇🔈🔉🔊📢📣📯🔔🔕🎼🎵🎶🎙️🎙🎚️🎚🎛️🎛🎤🎧📻🎷🎸🎹🎺🎻🥁📱📲☎️☎📞📟📠🔋🔌💻🖥️🖥🖨️🖨⌨️⌨🖱️🖱🖲️🖲💽💾💿📀🧮🎥🎞️🎞📽️📽🎬📺📷📸📹📼🔍🔎🕯️🕯💡🔦🏮📔📕📖📗📘📙📚📓📒📃📜📄📰🗞️🗞📑🔖🏷️🏷💰💴💵💶💷💸💳🧾💹💱💲✉️✉📧📨📩📤📥📦📫📪📬📭📮🗳️🗳✏️✏✒️✒🖋️🖋🖊️🖊🖌️🖌🖍️🖍📝💼📁📂🗂️🗂📅📆🗒️🗒🗓️🗓📇📈📉📊📋📌📍📎🖇️🖇📏📐✂️✂🗃️🗃🗄️🗄🗑️🗑🔒🔓🔏🔐🔑🗝️🗝🔨⛏️⛏⚒️⚒🛠️🛠🗡️🗡⚔️⚔🔫🏹🛡️🛡🔧🔩⚙️⚙🗜️🗜⚖️⚖🔗⛓️⛓🧰🧲⚗️⚗🧪🧫🧬🔬🔭📡💉💊🚪🛏️🛏🛋️🛋🚽🚿🛁🧴🧷🧹🧺🧻🧼🧽🧯🛒🚬⚰️⚰⚱️⚱🗿🏧🚮🚰♿🚹🚺🚻🚼🚾🛂🛃🛄🛅⚠️⚠🚸⛔🚫🚳🚭🚯🚱🚷📵🔞☢️☢☣️☣⬆️⬆↗️↗➡️➡↘️↘⬇️⬇↙️↙⬅️⬅↖️↖↕️↕↔️↔↩️↩↪️↪⤴️⤴⤵️⤵🔃🔄🔙🔚🔛🔜🔝🛐⚛️⚛🕉️🕉✡️✡☸️☸☯️☯✝️✝☦️☦☪️☪☮️☮🕎🔯♈♉♊♋♌♍♎♏♐♑♒♓⛎🔀🔁🔂▶️▶⏩⏭️⏭⏯️⏯◀️◀⏪⏮️⏮🔼⏫🔽⏬⏸️⏸⏹️⏹⏺️⏺⏏️⏏🎦🔅🔆📶📳📴♀️♀♂️♂⚕️⚕♾️♾♻️♻⚜️⚜🔱📛🔰⭕✅☑️☑✔️✔✖️✖❌❎➕➖➗➰➿〽️〽✳️✳✴️✴❇️❇‼️‼⁉️⁉❓❔❕❗〰️〰©️©®️®™️™#️⃣#⃣*️⃣*⃣0️⃣0⃣1️⃣1⃣2️⃣2⃣3️⃣3⃣4️⃣4⃣5️⃣5⃣6️⃣6⃣7️⃣7⃣8️⃣8⃣9️⃣9⃣🔟💯🔠🔡🔢🔣🔤🅰️🅰🆎🅱️🅱🆑🆒🆓ℹ️ℹ🆔Ⓜ️Ⓜ🆕🆖🅾️🅾🆗🅿️🅿🆘🆙🆚🈁🈂️🈂🈷️🈷🈶🈯🉐🈹🈚🈲🉑🈸🈴🈳㊗️㊗㊙️㊙🈺🈵▪️▪▫️▫◻️◻◼️◼◽◾⬛⬜🔶🔷🔸🔹🔺🔻💠🔘🔲🔳⚪⚫🔴🔵🏁🚩🎌🏴🏳️🏳🏳️‍🌈🏳‍🌈🏴‍☠️🏴‍☠🇦🇨🇦🇩🇦🇪🇦🇫🇦🇬🇦🇮🇦🇱🇦🇲🇦🇴🇦🇶🇦🇷🇦🇸🇦🇹🇦🇺🇦🇼🇦🇽🇦🇿🇧🇦🇧🇧🇧🇩🇧🇪🇧🇫🇧🇬🇧🇭🇧🇮🇧🇯🇧🇱🇧🇲🇧🇳🇧🇴🇧🇶🇧🇷🇧🇸🇧🇹🇧🇻🇧🇼🇧🇾🇧🇿🇨🇦🇨🇨🇨🇩🇨🇫🇨🇬🇨🇭🇨🇮🇨🇰🇨🇱🇨🇲🇨🇳🇨🇴🇨🇵🇨🇷🇨🇺🇨🇻🇨🇼🇨🇽🇨🇾🇨🇿🇩🇪🇩🇬🇩🇯🇩🇰🇩🇲🇩🇴🇩🇿🇪🇦🇪🇨🇪🇪🇪🇬🇪🇭🇪🇷🇪🇸🇪🇹🇪🇺🇫🇮🇫🇯🇫🇰🇫🇲🇫🇴🇫🇷🇬🇦🇬🇧🇬🇩🇬🇪🇬🇫🇬🇬🇬🇭🇬🇮🇬🇱🇬🇲🇬🇳🇬🇵🇬🇶🇬🇷🇬🇸🇬🇹🇬🇺🇬🇼🇬🇾🇭🇰🇭🇲🇭🇳🇭🇷🇭🇹🇭🇺🇮🇨🇮🇩🇮🇪🇮🇱🇮🇲🇮🇳🇮🇴🇮🇶🇮🇷🇮🇸🇮🇹🇯🇪🇯🇲🇯🇴🇯🇵🇰🇪🇰🇬🇰🇭🇰🇮🇰🇲🇰🇳🇰🇵🇰🇷🇰🇼🇰🇾🇰🇿🇱🇦🇱🇧🇱🇨🇱🇮🇱🇰🇱🇷🇱🇸🇱🇹🇱🇺🇱🇻🇱🇾🇲🇦🇲🇨🇲🇩🇲🇪🇲🇫🇲🇬🇲🇭🇲🇰🇲🇱🇲🇲🇲🇳🇲🇴🇲🇵🇲🇶🇲🇷🇲🇸🇲🇹🇲🇺🇲🇻🇲🇼🇲🇽🇲🇾🇲🇿🇳🇦🇳🇨🇳🇪🇳🇫🇳🇬🇳🇮🇳🇱🇳🇴🇳🇵🇳🇷🇳🇺🇳🇿🇴🇲🇵🇦🇵🇪🇵🇫🇵🇬🇵🇭🇵🇰🇵🇱🇵🇲🇵🇳🇵🇷🇵🇸🇵🇹🇵🇼🇵🇾🇶🇦🇷🇪🇷🇴🇷🇸🇷🇺🇷🇼🇸🇦🇸🇧🇸🇨🇸🇩🇸🇪🇸🇬🇸🇭🇸🇮🇸🇯🇸🇰🇸🇱🇸🇲🇸🇳🇸🇴🇸🇷🇸🇸🇸🇹🇸🇻🇸🇽🇸🇾🇸🇿🇹🇦🇹🇨🇹🇩🇹🇫🇹🇬🇹🇭🇹🇯🇹🇰🇹🇱🇹🇲🇹🇳🇹🇴🇹🇷🇹🇹🇹🇻🇹🇼🇹🇿🇺🇦🇺🇬🇺🇲🇺🇳🇺🇸🇺🇾🇺🇿🇻🇦🇻🇨🇻🇪🇻🇬🇻🇮🇻🇳🇻🇺🇼🇫🇼🇸🇽🇰🇾🇪🇾🇹🇿🇦🇿🇲🇿🇼🏴󠁧󠁢󠁥󠁮󠁧󠁿🏴󠁧󠁢󠁳󠁣󠁴��🏴󠁧󠁢󠁷󠁬󠁳󠁿"
389
+ );
390
+ expect(() => emoji.parse(":-)")).toThrow();
391
+ expect(() => emoji.parse("😀 is an emoji")).toThrow();
392
+ expect(() => emoji.parse("😀stuff")).toThrow();
393
+ expect(() => emoji.parse("stuff😀")).toThrow();
394
+ });
395
+
396
+ test("nanoid", () => {
397
+ const nanoid = z.string().nanoid("custom error");
398
+ nanoid.parse("lfNZluvAxMkf7Q8C5H-QS");
399
+ nanoid.parse("mIU_4PJWikaU8fMbmkouz");
400
+ nanoid.parse("Hb9ZUtUa2JDm_dD-47EGv");
401
+ nanoid.parse("5Noocgv_8vQ9oPijj4ioQ");
402
+ const result = nanoid.safeParse("Xq90uDyhddC53KsoASYJGX");
403
+ expect(result).toMatchObject({ success: false });
404
+
405
+ expect(result.error!.issues[0].message).toEqual("custom error");
406
+ expect(result.error).toMatchInlineSnapshot(`
407
+ [ZodError: [
408
+ {
409
+ "origin": "string",
410
+ "code": "invalid_format",
411
+ "format": "nanoid",
412
+ "pattern": "/^[a-zA-Z0-9_-]{21}$/",
413
+ "path": [],
414
+ "message": "custom error"
415
+ }
416
+ ]]
417
+ `);
418
+ });
419
+
420
+ test("bad nanoid", () => {
421
+ const nanoid = z.string().nanoid("custom error");
422
+ nanoid.parse("ySh_984wpDUu7IQRrLXAp");
423
+ const result = nanoid.safeParse("invalid nanoid");
424
+ expect(result).toMatchObject({ success: false });
425
+
426
+ expect(result.error!.issues[0].message).toEqual("custom error");
427
+ expect(result.error).toMatchInlineSnapshot(`
428
+ [ZodError: [
429
+ {
430
+ "origin": "string",
431
+ "code": "invalid_format",
432
+ "format": "nanoid",
433
+ "pattern": "/^[a-zA-Z0-9_-]{21}$/",
434
+ "path": [],
435
+ "message": "custom error"
436
+ }
437
+ ]]
438
+ `);
439
+ });
440
+
441
+ test("good uuid", () => {
442
+ const uuid = z.string().uuid("custom error");
443
+ const goodUuids = [
444
+ "9491d710-3185-1e06-bea0-6a2f275345e0",
445
+ "9491d710-3185-2e06-bea0-6a2f275345e0",
446
+ "9491d710-3185-3e06-bea0-6a2f275345e0",
447
+ "9491d710-3185-4e06-bea0-6a2f275345e0",
448
+ "9491d710-3185-5e06-bea0-6a2f275345e0",
449
+ "9491d710-3185-5e06-aea0-6a2f275345e0",
450
+ "9491d710-3185-5e06-8ea0-6a2f275345e0",
451
+ "9491d710-3185-5e06-9ea0-6a2f275345e0",
452
+ "00000000-0000-0000-0000-000000000000",
453
+ ];
454
+
455
+ for (const goodUuid of goodUuids) {
456
+ const result = uuid.safeParse(goodUuid);
457
+ expect(result.success).toEqual(true);
458
+ }
459
+ });
460
+
461
+ test(`bad uuid`, () => {
462
+ const uuid = z.string().uuid("custom error");
463
+ for (const badUuid of [
464
+ "9491d710-3185-0e06-bea0-6a2f275345e0",
465
+ "9491d710-3185-5e06-0ea0-6a2f275345e0",
466
+ "d89e7b01-7598-ed11-9d7a-0022489382fd", // new sequential id
467
+ "b3ce60f8-e8b9-40f5-1150-172ede56ff74", // Variant 0 - RFC 4122: Reserved, NCS backward compatibility
468
+ "92e76bf9-28b3-4730-cd7f-cb6bc51f8c09", // Variant 2 - RFC 4122: Reserved, Microsoft Corporation backward compatibility
469
+ "invalid uuid",
470
+ "9491d710-3185-4e06-bea0-6a2f275345e0X",
471
+ "ffffffff-ffff-ffff-ffff-ffffffffffff",
472
+ ]) {
473
+ const result = uuid.safeParse(badUuid);
474
+ expect(result).toMatchObject({ success: false });
475
+ expect(result.error?.issues[0].message).toEqual("custom error");
476
+ }
477
+ });
478
+
479
+ test("good guid", () => {
480
+ const guid = z.string().guid("custom error");
481
+ for (const goodGuid of [
482
+ "9491d710-3185-4e06-bea0-6a2f275345e0",
483
+ "d89e7b01-7598-ed11-9d7a-0022489382fd", // new sequential id
484
+ "b3ce60f8-e8b9-40f5-1150-172ede56ff74", // Variant 0 - RFC 4122: Reserved, NCS backward compatibility
485
+ "92e76bf9-28b3-4730-cd7f-cb6bc51f8c09", // Variant 2 - RFC 4122: Reserved, Microsoft Corporation backward compatibility
486
+ "00000000-0000-0000-0000-000000000000",
487
+ "ffffffff-ffff-ffff-ffff-ffffffffffff",
488
+ ]) {
489
+ const result = guid.safeParse(goodGuid);
490
+ expect(result.success).toEqual(true);
491
+ }
492
+ });
493
+
494
+ test("bad guid", () => {
495
+ const guid = z.string().guid("custom error");
496
+ for (const badGuid of ["9491d710-3185-4e06-bea0-6a2f275345e0X"]) {
497
+ const result = guid.safeParse(badGuid);
498
+ expect(result).toMatchObject({ success: false });
499
+ expect(result.error?.issues[0].message).toEqual("custom error");
500
+ }
501
+ });
502
+
503
+ test("cuid", () => {
504
+ const cuid = z.string().cuid();
505
+ cuid.parse("ckopqwooh000001la8mbi2im9");
506
+ const result = cuid.safeParse("cifjhdsfhsd-invalid-cuid");
507
+ expect(result).toMatchObject({ success: false });
508
+
509
+ expect(result.error!.issues[0].message).toEqual("Invalid cuid");
510
+ expect(result.error).toMatchInlineSnapshot(`
511
+ [ZodError: [
512
+ {
513
+ "origin": "string",
514
+ "code": "invalid_format",
515
+ "format": "cuid",
516
+ "pattern": "/^[cC][^\\\\s-]{8,}$/",
517
+ "path": [],
518
+ "message": "Invalid cuid"
519
+ }
520
+ ]]
521
+ `);
522
+ });
523
+
524
+ test("cuid2", () => {
525
+ const cuid2 = z.string().cuid2();
526
+ const validStrings = [
527
+ "a", // short string
528
+ "tz4a98xxat96iws9zmbrgj3a", // normal string
529
+ "kf5vz6ssxe4zjcb409rjgo747tc5qjazgptvotk6", // longer than require("@paralleldrive/cuid2").bigLength
530
+ ];
531
+ for (const s of validStrings) {
532
+ cuid2.parse(s);
533
+ }
534
+
535
+ const invalidStrings = [
536
+ "", // empty string
537
+ "tz4a98xxat96iws9zMbrgj3a", // include uppercase
538
+ "tz4a98xxat96iws-zmbrgj3a", // involve symbols
539
+ ];
540
+ const results = invalidStrings.map((s) => cuid2.safeParse(s));
541
+ expect(results.every((r) => !r.success)).toEqual(true);
542
+ if (!results[0].success) {
543
+ expect(results[0].error.issues[0].message).toEqual("Invalid cuid2");
544
+ }
545
+ });
546
+
547
+ test("ulid", () => {
548
+ const ulid = z.string().ulid();
549
+ ulid.parse("01ARZ3NDEKTSV4RRFFQ69G5FAV");
550
+ const result = ulid.safeParse("invalidulid");
551
+ expect(result).toMatchObject({ success: false });
552
+ const tooLong = "01ARZ3NDEKTSV4RRFFQ69G5FAVA";
553
+ expect(ulid.safeParse(tooLong)).toMatchObject({ success: false });
554
+
555
+ const caseInsensitive = ulid.safeParse("01arZ3nDeKTsV4RRffQ69G5FAV");
556
+ expect(caseInsensitive.success).toEqual(true);
557
+
558
+ expect(result.error!.issues[0].message).toEqual("Invalid ULID");
559
+ expect(result.error).toMatchInlineSnapshot(`
560
+ [ZodError: [
561
+ {
562
+ "origin": "string",
563
+ "code": "invalid_format",
564
+ "format": "ulid",
565
+ "pattern": "/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/",
566
+ "path": [],
567
+ "message": "Invalid ULID"
568
+ }
569
+ ]]
570
+ `);
571
+ });
572
+
573
+ test("xid", () => {
574
+ const xid = z.string().xid();
575
+ xid.parse("9m4e2mr0ui3e8a215n4g");
576
+ const result = xid.safeParse("invalidxid");
577
+ expect(result).toMatchObject({ success: false });
578
+
579
+ expect(result.error!.issues[0].message).toEqual("Invalid XID");
580
+ expect(result.error).toMatchInlineSnapshot(`
581
+ [ZodError: [
582
+ {
583
+ "origin": "string",
584
+ "code": "invalid_format",
585
+ "format": "xid",
586
+ "pattern": "/^[0-9a-vA-V]{20}$/",
587
+ "path": [],
588
+ "message": "Invalid XID"
589
+ }
590
+ ]]
591
+ `);
592
+ });
593
+
594
+ test("ksuid", () => {
595
+ const ksuid = z.string().ksuid();
596
+ ksuid.parse("0o0t9hkGxgFLtd3lmJ4TSTeY0Vb");
597
+ const result = ksuid.safeParse("invalidksuid");
598
+ expect(result).toMatchObject({ success: false });
599
+ const tooLong = "0o0t9hkGxgFLtd3lmJ4TSTeY0VbA";
600
+ expect(ksuid.safeParse(tooLong)).toMatchObject({ success: false });
601
+ expect(result.error!.issues).toMatchInlineSnapshot(`
602
+ [
603
+ {
604
+ "code": "invalid_format",
605
+ "format": "ksuid",
606
+ "message": "Invalid KSUID",
607
+ "origin": "string",
608
+ "path": [],
609
+ "pattern": "/^[A-Za-z0-9]{27}$/",
610
+ },
611
+ ]
612
+ `);
613
+ });
614
+
615
+ test("regex", () => {
616
+ z.string()
617
+ .regex(/^moo+$/)
618
+ .parse("mooooo");
619
+ expect(() => z.string().uuid().parse("purr")).toThrow();
620
+ });
621
+
622
+ test("regexp error message", () => {
623
+ const result = z
624
+ .string()
625
+ .regex(/^moo+$/)
626
+ .safeParse("boooo");
627
+ expect(result.error!.issues).toMatchInlineSnapshot(`
628
+ [
629
+ {
630
+ "code": "invalid_format",
631
+ "format": "regex",
632
+ "message": "Invalid string: must match pattern /^moo+$/",
633
+ "origin": "string",
634
+ "path": [],
635
+ "pattern": "/^moo+$/",
636
+ },
637
+ ]
638
+ `);
639
+
640
+ expect(() => z.string().uuid().parse("purr")).toThrow();
641
+ });
642
+
643
+ test("regexp error custom message", () => {
644
+ const result = z
645
+ .string()
646
+ .regex(/^moo+$/, { message: "Custom error message" })
647
+ .safeParse("boooo");
648
+ expect(result.error!.issues).toMatchInlineSnapshot(`
649
+ [
650
+ {
651
+ "code": "invalid_format",
652
+ "format": "regex",
653
+ "message": "Custom error message",
654
+ "origin": "string",
655
+ "path": [],
656
+ "pattern": "/^moo+$/",
657
+ },
658
+ ]
659
+ `);
660
+
661
+ expect(() => z.string().uuid().parse("purr")).toThrow();
662
+ });
663
+
664
+ test("regex lastIndex reset", () => {
665
+ const schema = z.string().regex(/^\d+$/g);
666
+ expect(schema.safeParse("123").success).toEqual(true);
667
+ expect(schema.safeParse("123").success).toEqual(true);
668
+ expect(schema.safeParse("123").success).toEqual(true);
669
+ expect(schema.safeParse("123").success).toEqual(true);
670
+ expect(schema.safeParse("123").success).toEqual(true);
671
+ });
672
+
673
+ test("format", () => {
674
+ expect(z.string().email().format).toEqual("email");
675
+ expect(z.string().url().format).toEqual("url");
676
+ expect(z.string().jwt().format).toEqual("jwt");
677
+ expect(z.string().emoji().format).toEqual("emoji");
678
+ expect(z.string().guid().format).toEqual("guid");
679
+ expect(z.string().uuid().format).toEqual("uuid");
680
+ expect(z.string().uuidv4().format).toEqual("uuid");
681
+ expect(z.string().uuidv6().format).toEqual("uuid");
682
+ expect(z.string().uuidv7().format).toEqual("uuid");
683
+ expect(z.string().nanoid().format).toEqual("nanoid");
684
+ expect(z.string().guid().format).toEqual("guid");
685
+ expect(z.string().cuid().format).toEqual("cuid");
686
+ expect(z.string().cuid2().format).toEqual("cuid2");
687
+ expect(z.string().ulid().format).toEqual("ulid");
688
+ expect(z.string().base64().format).toEqual("base64");
689
+ // expect(z.string().jsonString().format).toEqual("json_string");
690
+ // expect(z.string().json().format).toEqual("json_string");
691
+ expect(z.string().xid().format).toEqual("xid");
692
+ expect(z.string().ksuid().format).toEqual("ksuid");
693
+ // expect(z.string().ip().format).toEqual("ip");
694
+ expect(z.string().ipv4().format).toEqual("ipv4");
695
+ expect(z.string().ipv6().format).toEqual("ipv6");
696
+ expect(z.string().e164().format).toEqual("e164");
697
+ expect(z.string().datetime().format).toEqual("datetime");
698
+ expect(z.string().date().format).toEqual("date");
699
+ expect(z.string().time().format).toEqual("time");
700
+ expect(z.string().duration().format).toEqual("duration");
701
+ });
702
+
703
+ test("min max getters", () => {
704
+ expect(z.string().min(5).minLength).toEqual(5);
705
+ expect(z.string().min(5).min(10).minLength).toEqual(10);
706
+ expect(z.string().minLength).toEqual(null);
707
+
708
+ expect(z.string().max(5).maxLength).toEqual(5);
709
+ expect(z.string().max(5).max(1).maxLength).toEqual(1);
710
+ expect(z.string().max(5).max(10).maxLength).toEqual(5);
711
+ expect(z.string().maxLength).toEqual(null);
712
+ });
713
+
714
+ test("trim", () => {
715
+ expect(z.string().trim().min(2).parse(" 12 ")).toEqual("12");
716
+
717
+ // ordering of methods is respected
718
+ expect(z.string().min(2).trim().parse(" 1 ")).toEqual("1");
719
+ expect(() => z.string().trim().min(2).parse(" 1 ")).toThrow();
720
+ });
721
+
722
+ test("lowerCase", () => {
723
+ expect(z.string().toLowerCase().parse("ASDF")).toEqual("asdf");
724
+ expect(z.string().toUpperCase().parse("asdf")).toEqual("ASDF");
725
+ });
726
+
727
+ // test("IP validation", () => {
728
+ // const ipSchema = z.string().ip();
729
+
730
+ // // General IP validation (accepts both v4 and v6)
731
+ // expect(ipSchema.safeParse("114.71.82.94").success).toBe(true);
732
+ // expect(ipSchema.safeParse("0.0.0.0").success).toBe(true);
733
+ // expect(ipSchema.safeParse("37.85.236.115").success).toBe(true);
734
+ // expect(ipSchema.safeParse("1e5e:e6c8:daac:514b:114b:e360:d8c0:682c").success).toBe(true);
735
+ // expect(ipSchema.safeParse("9d4:c956:420f:5788:4339:9b3b:2418:75c3").success).toBe(true);
736
+ // expect(ipSchema.safeParse("a6ea::2454:a5ce:94.105.123.75").success).toBe(true);
737
+ // expect(ipSchema.safeParse("474f:4c83::4e40:a47:ff95:0cda").success).toBe(true);
738
+ // expect(ipSchema.safeParse("d329:0:25b4:db47:a9d1:0:4926:0000").success).toBe(true);
739
+ // expect(ipSchema.safeParse("e48:10fb:1499:3e28:e4b6:dea5:4692:912c").success).toBe(true);
740
+
741
+ // expect(ipSchema.safeParse("d329:1be4:25b4:db47:a9d1:dc71:4926:992c:14af").success).toBe(false);
742
+ // expect(ipSchema.safeParse("d5e7:7214:2b78::3906:85e6:53cc:709:32ba").success).toBe(false);
743
+ // expect(ipSchema.safeParse("8f69::c757:395e:976e::3441").success).toBe(false);
744
+ // expect(ipSchema.safeParse("54cb::473f:d516:0.255.256.22").success).toBe(false);
745
+ // expect(ipSchema.safeParse("54cb::473f:d516:192.168.1").success).toBe(false);
746
+ // expect(ipSchema.safeParse("256.0.4.4").success).toBe(false);
747
+ // expect(ipSchema.safeParse("-1.0.555.4").success).toBe(false);
748
+ // expect(ipSchema.safeParse("0.0.0.0.0").success).toBe(false);
749
+ // expect(ipSchema.safeParse("1.1.1").success).toBe(false);
750
+ // });
751
+
752
+ test("IPv4 validation", () => {
753
+ const ipv4 = z.string().ipv4();
754
+
755
+ // Valid IPv4 addresses
756
+ expect(ipv4.safeParse("114.71.82.94").success).toBe(true);
757
+ expect(ipv4.safeParse("0.0.0.0").success).toBe(true);
758
+ expect(ipv4.safeParse("37.85.236.115").success).toBe(true);
759
+ expect(ipv4.safeParse("192.168.0.1").success).toBe(true);
760
+ expect(ipv4.safeParse("255.255.255.255").success).toBe(true);
761
+ expect(ipv4.safeParse("1.2.3.4").success).toBe(true);
762
+
763
+ // Invalid IPv4 addresses
764
+ expect(ipv4.safeParse("256.0.4.4").success).toBe(false);
765
+ expect(ipv4.safeParse("-1.0.555.4").success).toBe(false);
766
+ expect(ipv4.safeParse("0.0.0.0.0").success).toBe(false);
767
+ expect(ipv4.safeParse("1.1.1").success).toBe(false);
768
+ expect(ipv4.safeParse("1e5e:e6c8:daac:514b:114b:e360:d8c0:682c").success).toBe(false);
769
+ expect(ipv4.safeParse("a6ea::2454:a5ce:94.105.123.75").success).toBe(false);
770
+ expect(ipv4.safeParse("not an ip").success).toBe(false);
771
+ expect(ipv4.safeParse("1.2.3").success).toBe(false);
772
+ expect(ipv4.safeParse("1.2.3.4.5").success).toBe(false);
773
+ expect(ipv4.safeParse("1.2.3.256").success).toBe(false);
774
+
775
+ // Test specific error
776
+ expect(() => ipv4.parse("6097:adfa:6f0b:220d:db08:5021:6191:7990")).toThrow();
777
+ });
778
+
779
+ test("IPv6 validation", () => {
780
+ const ipv6 = z.string().ipv6();
781
+
782
+ // Valid IPv6 addresses
783
+ expect(ipv6.safeParse("1e5e:e6c8:daac:514b:114b:e360:d8c0:682c").success).toBe(true);
784
+ expect(ipv6.safeParse("9d4:c956:420f:5788:4339:9b3b:2418:75c3").success).toBe(true);
785
+ expect(ipv6.safeParse("a6ea::2454:a5ce:94.105.123.75").success).toBe(true);
786
+ expect(ipv6.safeParse("474f:4c83::4e40:a47:ff95:0cda").success).toBe(true);
787
+ expect(ipv6.safeParse("d329:0:25b4:db47:a9d1:0:4926:0000").success).toBe(true);
788
+ expect(ipv6.safeParse("e48:10fb:1499:3e28:e4b6:dea5:4692:912c").success).toBe(true);
789
+ expect(ipv6.safeParse("::1").success).toBe(true);
790
+ expect(ipv6.safeParse("2001:db8::").success).toBe(true);
791
+ expect(ipv6.safeParse("2001:0db8:85a3:0000:0000:8a2e:0370:7334").success).toBe(true);
792
+ expect(ipv6.safeParse("2001:db8::192.168.0.1").success).toBe(true);
793
+ expect(ipv6.safeParse("::ffff:192.168.0.1").success).toBe(true);
794
+ expect(ipv6.safeParse("::ffff:c000:0280").success).toBe(true); // IPv4-mapped IPv6 address
795
+ expect(ipv6.safeParse("64:ff9b::192.168.0.1").success).toBe(true); // IPv4/IPv6 translation
796
+
797
+ // Invalid IPv6 addresses
798
+ expect(ipv6.safeParse("d329:1be4:25b4:db47:a9d1:dc71:4926:992c:14af").success).toBe(false);
799
+ expect(ipv6.safeParse("d5e7:7214:2b78::3906:85e6:53cc:709:32ba").success).toBe(false);
800
+ expect(ipv6.safeParse("8f69::c757:395e:976e::3441").success).toBe(false);
801
+ expect(ipv6.safeParse("54cb::473f:d516:0.255.256.22").success).toBe(false);
802
+ expect(ipv6.safeParse("54cb::473f:d516:192.168.1").success).toBe(false);
803
+ expect(ipv6.safeParse("114.71.82.94").success).toBe(false);
804
+ expect(ipv6.safeParse("not an ip").success).toBe(false);
805
+ expect(ipv6.safeParse("g123::1234:5678").success).toBe(false);
806
+
807
+ // Test specific error
808
+ expect(() => ipv6.parse("254.164.77.1")).toThrow();
809
+ });
810
+
811
+ test("CIDR v4 validation", () => {
812
+ const cidrV4 = z.string().cidrv4();
813
+
814
+ // Valid CIDR v4 addresses
815
+ expect(cidrV4.safeParse("192.168.0.0/24").success).toBe(true);
816
+ expect(cidrV4.safeParse("10.0.0.0/8").success).toBe(true);
817
+ expect(cidrV4.safeParse("172.16.0.0/12").success).toBe(true);
818
+ expect(cidrV4.safeParse("0.0.0.0/0").success).toBe(true);
819
+ expect(cidrV4.safeParse("255.255.255.255/32").success).toBe(true);
820
+
821
+ // Invalid CIDR v4 addresses
822
+ expect(cidrV4.safeParse("192.168.0.0").success).toBe(false); // Missing prefix
823
+ expect(cidrV4.safeParse("192.168.0.0/33").success).toBe(false); // Invalid prefix length
824
+ expect(cidrV4.safeParse("256.0.0.0/24").success).toBe(false); // Invalid IP
825
+ expect(cidrV4.safeParse("192.168.0.0/-1").success).toBe(false); // Negative prefix length
826
+ expect(cidrV4.safeParse("not a cidr").success).toBe(false); // Invalid format
827
+ });
828
+
829
+ test("CIDR v6 validation", () => {
830
+ const cidrV6 = z.string().cidrv6();
831
+
832
+ // Valid CIDR v6 addresses
833
+ expect(cidrV6.safeParse("2001:db8::/32").success).toBe(true);
834
+ expect(cidrV6.safeParse("::/0").success).toBe(true);
835
+ expect(cidrV6.safeParse("fe80::/10").success).toBe(true);
836
+ expect(cidrV6.safeParse("::1/128").success).toBe(true);
837
+ expect(cidrV6.safeParse("2001:0db8:85a3::/64").success).toBe(true);
838
+
839
+ // Invalid CIDR v6 addresses
840
+ expect(cidrV6.safeParse("2001:db8::").success).toBe(false); // Missing prefix
841
+ expect(cidrV6.safeParse("2001:db8::/129").success).toBe(false); // Invalid prefix length
842
+ expect(cidrV6.safeParse("2001:db8::/abc").success).toBe(false); // Invalid prefix format
843
+ expect(cidrV6.safeParse("not a cidr").success).toBe(false); // Invalid format
844
+ expect(cidrV6.safeParse("192.168.0.0/24").success).toBe(false); // IPv4 CIDR in v6 validation
845
+ });
846
+
847
+ test("E.164 validation", () => {
848
+ const e164Number = z.string().e164();
849
+ expect(e164Number.safeParse("+1555555").success).toBe(true);
850
+
851
+ const validE164Numbers = [
852
+ "+1555555", // min-length (7 digits + '+')
853
+ "+15555555",
854
+ "+155555555",
855
+ "+1555555555",
856
+ "+15555555555",
857
+ "+155555555555",
858
+ "+1555555555555",
859
+ "+15555555555555",
860
+ "+155555555555555",
861
+ "+105555555555555",
862
+ "+100555555555555", // max-length (15 digits + '+')
863
+ ];
864
+
865
+ const invalidE164Numbers = [
866
+ "", // empty
867
+ "+", // only plus sign
868
+ "-", // wrong sign
869
+ " 555555555", // starts with space
870
+ "555555555", // missing plus sign
871
+ "+1 555 555 555", // space after plus sign
872
+ "+1555 555 555", // space between numbers
873
+ "+1555+555", // multiple plus signs
874
+ "+1555555555555555", // too long
875
+ "+115abc55", // non numeric characters in number part
876
+ "+1555555 ", // space after number
877
+ ];
878
+
879
+ expect(validE164Numbers.every((number) => e164Number.safeParse(number).success)).toBe(true);
880
+ expect(invalidE164Numbers.every((number) => e164Number.safeParse(number).success === false)).toBe(true);
881
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/stringbool.test.ts ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+
4
+ test("z.stringbool", () => {
5
+ const a = z.stringbool();
6
+ type a = z.infer<typeof a>;
7
+ expectTypeOf<a>().toEqualTypeOf<boolean>();
8
+ type a_in = z.input<typeof a>;
9
+ expectTypeOf<a_in>().toEqualTypeOf<string>();
10
+
11
+ expect(z.parse(a, "true")).toEqual(true);
12
+ expect(z.parse(a, "yes")).toEqual(true);
13
+ expect(z.parse(a, "1")).toEqual(true);
14
+ expect(z.parse(a, "on")).toEqual(true);
15
+ expect(z.parse(a, "y")).toEqual(true);
16
+ expect(z.parse(a, "enabled")).toEqual(true);
17
+ expect(z.parse(a, "TRUE")).toEqual(true);
18
+
19
+ expect(z.parse(a, "false")).toEqual(false);
20
+ expect(z.parse(a, "no")).toEqual(false);
21
+ expect(z.parse(a, "0")).toEqual(false);
22
+ expect(z.parse(a, "off")).toEqual(false);
23
+ expect(z.parse(a, "n")).toEqual(false);
24
+ expect(z.parse(a, "disabled")).toEqual(false);
25
+ expect(z.parse(a, "FALSE")).toEqual(false);
26
+
27
+ expect(z.safeParse(a, "other")).toMatchObject({ success: false });
28
+ expect(z.safeParse(a, "")).toMatchObject({ success: false });
29
+ expect(z.safeParse(a, undefined)).toMatchObject({ success: false });
30
+ expect(z.safeParse(a, {})).toMatchObject({ success: false });
31
+ expect(z.safeParse(a, true)).toMatchObject({ success: false });
32
+ expect(z.safeParse(a, false)).toMatchObject({ success: false });
33
+ });
34
+
35
+ test("custom values", () => {
36
+ const b = z.stringbool({
37
+ truthy: ["y"],
38
+ falsy: ["N"],
39
+ });
40
+ expect(z.parse(b, "y")).toEqual(true);
41
+ expect(z.parse(b, "Y")).toEqual(true);
42
+ expect(z.parse(b, "n")).toEqual(false);
43
+ expect(z.parse(b, "N")).toEqual(false);
44
+ expect(z.safeParse(b, "true")).toMatchObject({ success: false });
45
+ expect(z.safeParse(b, "false")).toMatchObject({ success: false });
46
+ });
47
+
48
+ test("custom values - case sensitive", () => {
49
+ const c = z.stringbool({
50
+ truthy: ["y"],
51
+ falsy: ["N"],
52
+ case: "sensitive",
53
+ });
54
+ expect(z.parse(c, "y")).toEqual(true);
55
+ expect(z.safeParse(c, "Y")).toMatchObject({ success: false });
56
+ expect(z.parse(c, "N")).toEqual(false);
57
+ expect(z.safeParse(c, "n")).toMatchObject({ success: false });
58
+ expect(z.safeParse(c, "TRUE")).toMatchObject({ success: false });
59
+ });
60
+
61
+ // test custom error messages
62
+ test("z.stringbool with custom error messages", () => {
63
+ const a = z.stringbool("wrong!");
64
+
65
+ expect(() => a.parse("")).toThrowError("wrong!");
66
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/template-literal.test.ts ADDED
@@ -0,0 +1,758 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+
4
+ const empty = z.templateLiteral([]);
5
+ const hello = z.templateLiteral(["hello"]);
6
+ const world = z.templateLiteral(["", z.literal("world")]);
7
+ const one = z.templateLiteral([1]);
8
+ const two = z.templateLiteral(["", z.literal(2)]);
9
+ const truee = z.templateLiteral([true]);
10
+ const anotherTrue = z.templateLiteral(["", z.literal(true)]);
11
+ const falsee = z.templateLiteral([false]);
12
+ const anotherFalse = z.templateLiteral(["", z.literal(false)]);
13
+ const nulll = z.templateLiteral([null]);
14
+ const anotherNull = z.templateLiteral(["", z.null()]);
15
+ const undefinedd = z.templateLiteral([undefined]);
16
+ const anotherUndefined = z.templateLiteral(["", z.undefined()]);
17
+ const anyString = z.templateLiteral(["", z.string()]);
18
+ const lazyString = z.templateLiteral(["", z.lazy(() => z.string())]);
19
+ const anyNumber = z.templateLiteral(["", z.number()]);
20
+ const anyInt = z.templateLiteral(["", z.number().int()]);
21
+ // const anyFiniteNumber = z.templateLiteral(["", z.number().finite()]);
22
+ // const anyNegativeNumber = z.templateLiteral(["", z.number().negative()]);
23
+ // const anyPositiveNumber = z.templateLiteral(["", z.number().positive()]);
24
+ // const zeroButInADumbWay = z.templateLiteral(["", z.number().nonnegative().nonpositive()]);
25
+ // const finiteButInADumbWay = z.templateLiteral(["", z.number().min(5).max(10)]);
26
+ const bool = z.templateLiteral(["", z.boolean()]);
27
+ const bigone = z.templateLiteral(["", z.literal(BigInt(1))]);
28
+ const anyBigint = z.templateLiteral(["", z.bigint()]);
29
+ const nullableYo = z.templateLiteral(["", z.nullable(z.literal("yo"))]);
30
+ const nullableString = z.templateLiteral(["", z.nullable(z.string())]);
31
+ const optionalYeah = z.templateLiteral(["", z.literal("yeah").optional()]);
32
+
33
+ const optionalString = z.templateLiteral(["", z.string().optional()]);
34
+ const optionalNumber = z.templateLiteral(["", z.number().optional()]);
35
+ const nullishBruh = z.templateLiteral(["", z.literal("bruh").nullish()]);
36
+ const nullishString = z.templateLiteral(["", z.string().nullish()]);
37
+ const cuid = z.templateLiteral(["", z.string().cuid()]);
38
+ const cuidZZZ = z.templateLiteral(["", z.string().cuid(), "ZZZ"]);
39
+ const cuid2 = z.templateLiteral(["", z.string().cuid2()]);
40
+ const datetime = z.templateLiteral(["", z.string().datetime()]);
41
+ const email = z.templateLiteral(["", z.string().email()]);
42
+ // const ip = z.templateLiteral(["", z.string().ip()]);
43
+ const ipv4 = z.templateLiteral(["", z.string().ipv4()]);
44
+ const ipv6 = z.templateLiteral(["", z.string().ipv6()]);
45
+ const ulid = z.templateLiteral(["", z.string().ulid()]);
46
+ const uuid = z.templateLiteral(["", z.string().uuid()]);
47
+ const stringAToZ = z.templateLiteral(["", z.string().regex(/^[a-z]+$/)]);
48
+ const stringStartsWith = z.templateLiteral(["", z.string().startsWith("hello")]);
49
+ const stringEndsWith = z.templateLiteral(["", z.string().endsWith("world")]);
50
+ const stringMax5 = z.templateLiteral(["", z.string().max(5)]);
51
+ const stringMin5 = z.templateLiteral(["", z.string().min(5)]);
52
+ const stringLen5 = z.templateLiteral(["", z.string().length(5)]);
53
+ const stringMin5Max10 = z.templateLiteral(["", z.string().min(5).max(10)]);
54
+ const stringStartsWithMax5 = z.templateLiteral(["", z.string().startsWith("hello").max(5)]);
55
+ const brandedString = z.templateLiteral(["", z.string().min(1).brand("myBrand")]);
56
+ // const anything = z.templateLiteral(["", z.any()]);
57
+
58
+ const url = z.templateLiteral(["https://", z.string().regex(/\w+/), ".", z.enum(["com", "net"])]);
59
+
60
+ const measurement = z.templateLiteral([
61
+ "",
62
+ z.number().finite(),
63
+ z.enum(["px", "em", "rem", "vh", "vw", "vmin", "vmax"]).optional(),
64
+ ]);
65
+
66
+ const connectionString = z.templateLiteral([
67
+ "mongodb://",
68
+ z
69
+ .templateLiteral([
70
+ "",
71
+ z.string().regex(/\w+/).describe("username"),
72
+ ":",
73
+ z.string().regex(/\w+/).describe("password"),
74
+ "@",
75
+ ])
76
+ .optional(),
77
+ z.string().regex(/\w+/).describe("host"),
78
+ ":",
79
+ z.number().finite().int().positive().describe("port"),
80
+ z
81
+ .templateLiteral([
82
+ "/",
83
+ z.string().regex(/\w+/).optional().describe("defaultauthdb"),
84
+ z
85
+ .templateLiteral([
86
+ "?",
87
+ z
88
+ .string()
89
+ .regex(/^\w+=\w+(&\w+=\w+)*$/)
90
+ .optional()
91
+ .describe("options"),
92
+ ])
93
+ .optional(),
94
+ ])
95
+ .optional(),
96
+ ]);
97
+
98
+ test("template literal type inference", () => {
99
+ expectTypeOf<z.infer<typeof empty>>().toEqualTypeOf<``>();
100
+ expectTypeOf<z.infer<typeof hello>>().toEqualTypeOf<`hello`>();
101
+ expectTypeOf<z.infer<typeof world>>().toEqualTypeOf<`world`>();
102
+ expectTypeOf<z.infer<typeof one>>().toEqualTypeOf<`1`>();
103
+ expectTypeOf<z.infer<typeof two>>().toEqualTypeOf<`2`>();
104
+ expectTypeOf<z.infer<typeof truee>>().toEqualTypeOf<`true`>();
105
+ expectTypeOf<z.infer<typeof anotherTrue>>().toEqualTypeOf<`true`>();
106
+ expectTypeOf<z.infer<typeof falsee>>().toEqualTypeOf<`false`>();
107
+ expectTypeOf<z.infer<typeof anotherFalse>>().toEqualTypeOf<`false`>();
108
+ expectTypeOf<z.infer<typeof nulll>>().toEqualTypeOf<`null`>();
109
+ expectTypeOf<z.infer<typeof anotherNull>>().toEqualTypeOf<`null`>();
110
+ expectTypeOf<z.infer<typeof undefinedd>>().toEqualTypeOf<``>();
111
+ expectTypeOf<z.infer<typeof anotherUndefined>>().toEqualTypeOf<``>();
112
+ expectTypeOf<z.infer<typeof anyString>>().toEqualTypeOf<string>();
113
+ expectTypeOf<z.infer<typeof lazyString>>().toEqualTypeOf<string>();
114
+ expectTypeOf<z.infer<typeof anyNumber>>().toEqualTypeOf<`${number}`>();
115
+ expectTypeOf<z.infer<typeof anyInt>>().toEqualTypeOf<`${number}`>();
116
+ // expectTypeOf<z.infer<typeof anyFiniteNumber>>().toEqualTypeOf<`${number}`>();
117
+ // expectTypeOf<z.infer<typeof anyNegativeNumber>>().toEqualTypeOf<`${number}`>();
118
+ // expectTypeOf<z.infer<typeof anyPositiveNumber>>().toEqualTypeOf<`${number}`>();
119
+ // expectTypeOf<z.infer<typeof zeroButInADumbWay>>().toEqualTypeOf<`${number}`>();
120
+ // expectTypeOf<z.infer<typeof finiteButInADumbWay>>().toEqualTypeOf<`${number}`>();
121
+ expectTypeOf<z.infer<typeof bool>>().toEqualTypeOf<`true` | `false`>();
122
+ expectTypeOf<z.infer<typeof bigone>>().toEqualTypeOf<`${bigint}`>();
123
+ expectTypeOf<z.infer<typeof anyBigint>>().toEqualTypeOf<`${bigint}`>();
124
+ expectTypeOf<z.infer<typeof nullableYo>>().toEqualTypeOf<`yo` | `null`>();
125
+ expectTypeOf<z.infer<typeof nullableString>>().toEqualTypeOf<string>();
126
+ expectTypeOf<z.infer<typeof optionalYeah>>().toEqualTypeOf<`yeah` | ``>();
127
+ expectTypeOf<z.infer<typeof optionalString>>().toEqualTypeOf<string>();
128
+ expectTypeOf<z.infer<typeof optionalNumber>>().toEqualTypeOf<`${number}` | ``>();
129
+ expectTypeOf<z.infer<typeof nullishBruh>>().toEqualTypeOf<`bruh` | `null` | ``>();
130
+ expectTypeOf<z.infer<typeof nullishString>>().toEqualTypeOf<string>();
131
+ expectTypeOf<z.infer<typeof cuid>>().toEqualTypeOf<string>();
132
+ expectTypeOf<z.infer<typeof cuidZZZ>>().toEqualTypeOf<`${string}ZZZ`>();
133
+ expectTypeOf<z.infer<typeof cuid2>>().toEqualTypeOf<string>();
134
+ expectTypeOf<z.infer<typeof datetime>>().toEqualTypeOf<string>();
135
+ expectTypeOf<z.infer<typeof email>>().toEqualTypeOf<string>();
136
+ // expectTypeOf<z.infer<typeof ip>>().toEqualTypeOf<string>();
137
+ expectTypeOf<z.infer<typeof ipv4>>().toEqualTypeOf<string>();
138
+ expectTypeOf<z.infer<typeof ipv6>>().toEqualTypeOf<string>();
139
+ expectTypeOf<z.infer<typeof ulid>>().toEqualTypeOf<string>();
140
+ expectTypeOf<z.infer<typeof uuid>>().toEqualTypeOf<string>();
141
+ expectTypeOf<z.infer<typeof stringAToZ>>().toEqualTypeOf<string>();
142
+ expectTypeOf<z.infer<typeof stringStartsWith>>().toEqualTypeOf<string>();
143
+ expectTypeOf<z.infer<typeof stringEndsWith>>().toEqualTypeOf<string>();
144
+ expectTypeOf<z.infer<typeof stringMax5>>().toEqualTypeOf<string>();
145
+ expectTypeOf<z.infer<typeof stringMin5>>().toEqualTypeOf<string>();
146
+ expectTypeOf<z.infer<typeof stringLen5>>().toEqualTypeOf<string>();
147
+ expectTypeOf<z.infer<typeof stringMin5Max10>>().toEqualTypeOf<string>();
148
+ expectTypeOf<z.infer<typeof stringStartsWithMax5>>().toEqualTypeOf<string>();
149
+ expectTypeOf<z.infer<typeof brandedString>>().toEqualTypeOf<`${string & z.core.$brand<"myBrand">}`>();
150
+
151
+ // expectTypeOf<z.infer<typeof anything>>().toEqualTypeOf<`${any}`>();
152
+
153
+ expectTypeOf<z.infer<typeof url>>().toEqualTypeOf<`https://${string}.com` | `https://${string}.net`>();
154
+
155
+ expectTypeOf<z.infer<typeof measurement>>().toEqualTypeOf<
156
+ | `${number}`
157
+ | `${number}px`
158
+ | `${number}em`
159
+ | `${number}rem`
160
+ | `${number}vh`
161
+ | `${number}vw`
162
+ | `${number}vmin`
163
+ | `${number}vmax`
164
+ >();
165
+
166
+ expectTypeOf<z.infer<typeof connectionString>>().toEqualTypeOf<
167
+ | `mongodb://${string}:${number}`
168
+ | `mongodb://${string}:${number}/${string}`
169
+ | `mongodb://${string}:${number}/${string}?${string}`
170
+ | `mongodb://${string}:${string}@${string}:${number}`
171
+ | `mongodb://${string}:${string}@${string}:${number}/${string}`
172
+ | `mongodb://${string}:${string}@${string}:${number}/${string}?${string}`
173
+ >();
174
+ });
175
+
176
+ test("template literal unsupported args", () => {
177
+ expect(() =>
178
+ // @ts-expect-error
179
+ z.templateLiteral([z.object({})])
180
+ ).toThrow();
181
+ expect(() =>
182
+ // @ts-expect-error
183
+ z.templateLiteral([z.array(z.object({}))])
184
+ ).toThrow();
185
+ expect(() =>
186
+ // @ts-expect-error
187
+ z.templateLiteral([z.union([z.object({}), z.string()])])
188
+ ).toThrow();
189
+ // @ts-expect-error
190
+ expect(() => z.templateLiteral([z.date()])).toThrow();
191
+ expect(() =>
192
+ // @ts-expect-error
193
+ z.templateLiteral([z.custom<object>((_) => true)])
194
+ ).toThrow();
195
+ expect(() =>
196
+ z.templateLiteral([
197
+ // @ts-expect-error
198
+ z.discriminatedUnion("discriminator", [z.object({}), z.object({})]),
199
+ ])
200
+ ).toThrow();
201
+ expect(() =>
202
+ // @ts-expect-error
203
+ z.templateLiteral([z.function()])
204
+ ).toThrow();
205
+ expect(() =>
206
+ // @ts-expect-error
207
+ z.templateLiteral([z.instanceof(class MyClass {})])
208
+ ).toThrow();
209
+ expect(() =>
210
+ // @ts-expect-error
211
+ z.templateLiteral([z.intersection(z.object({}), z.object({}))])
212
+ ).toThrow();
213
+ expect(() =>
214
+ // @ts-expect-error
215
+ z.templateLiteral([z.map(z.string(), z.string())])
216
+ ).toThrow();
217
+ expect(() =>
218
+ // @ts-expect-error
219
+ z.templateLiteral([z.nullable(z.object({}))])
220
+ ).toThrow();
221
+ expect(() =>
222
+ // @ts-expect-error
223
+ z.templateLiteral([z.optional(z.object({}))])
224
+ ).toThrow();
225
+ expect(() =>
226
+ // @ts-expect-error
227
+ z.templateLiteral([z.promise()])
228
+ ).toThrow();
229
+ expect(() =>
230
+ // @ts-expect-error
231
+ z.templateLiteral([z.record(z.unknown())])
232
+ ).toThrow();
233
+ expect(() =>
234
+ // @ts-expect-error
235
+ z.templateLiteral([z.set(z.string())])
236
+ ).toThrow();
237
+ expect(() =>
238
+ // @ts-expect-error
239
+ z.templateLiteral([z.symbol()])
240
+ ).toThrow();
241
+ expect(() =>
242
+ // @ts-expect-error
243
+ z.templateLiteral([z.tuple([z.string()])])
244
+ ).toThrow();
245
+ expect(() =>
246
+ // @ts-expect-error
247
+ z.templateLiteral([z.unknown()])
248
+ ).toThrow();
249
+ expect(() =>
250
+ // @ts-expect-error
251
+ z.templateLiteral([z.void()])
252
+ ).toThrow();
253
+
254
+ expect(() =>
255
+ // @ts-expect-error
256
+ z.templateLiteral([z.never()])
257
+ ).toThrow();
258
+ // @ts-expect-error
259
+ expect(() => z.templateLiteral([z.nan()])).toThrow();
260
+ expect(() =>
261
+ // @ts-expect-error
262
+ z.templateLiteral([z.pipe(z.string(), z.string())])
263
+ ).toThrow();
264
+ expect(() =>
265
+ // @ts-expect-error
266
+ z.templateLiteral([z.preprocess(() => true, z.boolean())])
267
+ ).toThrow();
268
+ expect(() =>
269
+ // @ts-expect-error
270
+ z.templateLiteral([z.object({}).brand("brand")])
271
+ ).toThrow();
272
+
273
+ // these constraints aren't enforced but they shouldn't throw
274
+ z.templateLiteral([z.number().multipleOf(2)]);
275
+ z.templateLiteral([z.string().emoji()]);
276
+ z.templateLiteral([z.string().url()]);
277
+ z.templateLiteral([z.string().url()]);
278
+ z.templateLiteral([z.string().trim()]);
279
+ z.templateLiteral([z.string().includes("train")]);
280
+ z.templateLiteral([z.string().toLowerCase()]);
281
+ z.templateLiteral([z.string().toUpperCase()]);
282
+ });
283
+
284
+ test("template literal parsing - success - basic cases", () => {
285
+ expect(() => z.templateLiteral([]).parse(7)).toThrow();
286
+
287
+ empty.parse("");
288
+ hello.parse("hello");
289
+ world.parse("world");
290
+ one.parse("1");
291
+ two.parse("2");
292
+ truee.parse("true");
293
+ anotherTrue.parse("true");
294
+ falsee.parse("false");
295
+ anotherFalse.parse("false");
296
+ nulll.parse("null");
297
+ anotherNull.parse("null");
298
+ undefinedd.parse("undefined");
299
+ anotherUndefined.parse("undefined");
300
+ anyString.parse("blahblahblah");
301
+ anyString.parse("");
302
+ lazyString.parse("blahblahblah");
303
+ lazyString.parse("");
304
+ anyNumber.parse("123");
305
+ anyNumber.parse("1.23");
306
+ anyNumber.parse("0");
307
+ anyNumber.parse("-1.23");
308
+ anyNumber.parse("-123");
309
+ // anyNumber.parse("Infinity");
310
+ // anyNumber.parse("-Infinity");
311
+ anyInt.parse("123");
312
+ // anyInt.parse("-123");
313
+ // anyFiniteNumber.parse("123");
314
+ // anyFiniteNumber.parse("1.23");
315
+ // anyFiniteNumber.parse("0");
316
+ // anyFiniteNumber.parse("-1.23");
317
+ // anyFiniteNumber.parse("-123");
318
+ // anyNegativeNumber.parse("-123");
319
+ // anyNegativeNumber.parse("-1.23");
320
+ // anyNegativeNumber.parse("-Infinity");
321
+ // anyPositiveNumber.parse("123");
322
+ // anyPositiveNumber.parse("1.23");
323
+ // anyPositiveNumber.parse("Infinity");
324
+ // zeroButInADumbWay.parse("0");
325
+ // zeroButInADumbWay.parse("00000");
326
+ // finiteButInADumbWay.parse("5");
327
+ // finiteButInADumbWay.parse("10");
328
+ // finiteButInADumbWay.parse("6.66");
329
+ bool.parse("true");
330
+ bool.parse("false");
331
+ bigone.parse("1");
332
+ anyBigint.parse("123456");
333
+ anyBigint.parse("0");
334
+ // anyBigint.parse("-123456");
335
+ nullableYo.parse("yo");
336
+ nullableYo.parse("null");
337
+ nullableString.parse("abc");
338
+ nullableString.parse("null");
339
+ optionalYeah.parse("yeah");
340
+ optionalYeah.parse("");
341
+ optionalString.parse("abc");
342
+ optionalString.parse("");
343
+ optionalNumber.parse("123");
344
+ optionalNumber.parse("1.23");
345
+ optionalNumber.parse("0");
346
+ optionalNumber.parse("-1.23");
347
+ optionalNumber.parse("-123");
348
+ // optionalNumber.parse("Infinity");
349
+ // optionalNumber.parse("-Infinity");
350
+ nullishBruh.parse("bruh");
351
+ nullishBruh.parse("null");
352
+ nullishBruh.parse("");
353
+ cuid.parse("cjld2cyuq0000t3rmniod1foy");
354
+ cuidZZZ.parse("cjld2cyuq0000t3rmniod1foyZZZ");
355
+ cuid2.parse("tz4a98xxat96iws9zmbrgj3a");
356
+ datetime.parse(new Date().toISOString());
357
+ email.parse("info@example.com");
358
+ // ip.parse("213.174.246.205");
359
+ // ip.parse("c359:f57c:21e5:39eb:1187:e501:f936:b452");
360
+ ipv4.parse("213.174.246.205");
361
+ ipv6.parse("c359:f57c:21e5:39eb:1187:e501:f936:b452");
362
+ ulid.parse("01GW3D2QZJBYB6P1Z1AE997VPW");
363
+ uuid.parse("808989fd-3a6e-4af2-b607-737323a176f6");
364
+ stringAToZ.parse("asudgaskhdgashd");
365
+ stringStartsWith.parse("hello world");
366
+ stringEndsWith.parse("hello world");
367
+ stringMax5.parse("hello");
368
+ stringMin5.parse("hello");
369
+ stringLen5.parse("hello");
370
+ stringMin5Max10.parse("hello worl");
371
+ stringStartsWithMax5.parse("hello");
372
+ brandedString.parse("branded string");
373
+ });
374
+
375
+ test("template literal parsing - failure - basic cases", () => {
376
+ expect(() => empty.parse("a")).toThrow();
377
+ expect(() => hello.parse("hello!")).toThrow();
378
+ expect(() => hello.parse("!hello")).toThrow();
379
+ expect(() => world.parse("world!")).toThrow();
380
+ expect(() => world.parse("!world")).toThrow();
381
+ expect(() => one.parse("2")).toThrow();
382
+ expect(() => one.parse("12")).toThrow();
383
+ expect(() => one.parse("21")).toThrow();
384
+ expect(() => two.parse("1")).toThrow();
385
+ expect(() => two.parse("21")).toThrow();
386
+ expect(() => two.parse("12")).toThrow();
387
+ expect(() => truee.parse("false")).toThrow();
388
+ expect(() => truee.parse("1true")).toThrow();
389
+ expect(() => truee.parse("true1")).toThrow();
390
+ expect(() => anotherTrue.parse("false")).toThrow();
391
+ expect(() => anotherTrue.parse("1true")).toThrow();
392
+ expect(() => anotherTrue.parse("true1")).toThrow();
393
+ expect(() => falsee.parse("true")).toThrow();
394
+ expect(() => falsee.parse("1false")).toThrow();
395
+ expect(() => falsee.parse("false1")).toThrow();
396
+ expect(() => anotherFalse.parse("true")).toThrow();
397
+ expect(() => anotherFalse.parse("1false")).toThrow();
398
+ expect(() => anotherFalse.parse("false1")).toThrow();
399
+ expect(() => nulll.parse("123")).toThrow();
400
+ expect(() => nulll.parse("null1")).toThrow();
401
+ expect(() => nulll.parse("1null")).toThrow();
402
+ expect(() => anotherNull.parse("123")).toThrow();
403
+ expect(() => anotherNull.parse("null1")).toThrow();
404
+ expect(() => anotherNull.parse("1null")).toThrow();
405
+ expect(() => undefinedd.parse("123")).toThrow();
406
+ expect(() => undefinedd.parse("undefined1")).toThrow();
407
+ expect(() => undefinedd.parse("1undefined")).toThrow();
408
+ expect(() => anotherUndefined.parse("123")).toThrow();
409
+ expect(() => anotherUndefined.parse("undefined1")).toThrow();
410
+ expect(() => anotherUndefined.parse("1undefined")).toThrow();
411
+ expect(() => anyNumber.parse("2a")).toThrow();
412
+ expect(() => anyNumber.parse("a2")).toThrow();
413
+ expect(() => anyNumber.parse("-2a")).toThrow();
414
+ expect(() => anyNumber.parse("a-2")).toThrow();
415
+ expect(() => anyNumber.parse("2.5a")).toThrow();
416
+ expect(() => anyNumber.parse("a2.5")).toThrow();
417
+ expect(() => anyNumber.parse("Infinitya")).toThrow();
418
+ expect(() => anyNumber.parse("aInfinity")).toThrow();
419
+ expect(() => anyNumber.parse("-Infinitya")).toThrow();
420
+ expect(() => anyNumber.parse("a-Infinity")).toThrow();
421
+ expect(() => anyNumber.parse("2e5")).toThrow();
422
+ expect(() => anyNumber.parse("2e-5")).toThrow();
423
+ expect(() => anyNumber.parse("2e+5")).toThrow();
424
+ expect(() => anyNumber.parse("-2e5")).toThrow();
425
+ expect(() => anyNumber.parse("-2e-5")).toThrow();
426
+ expect(() => anyNumber.parse("-2e+5")).toThrow();
427
+ expect(() => anyNumber.parse("2.1e5")).toThrow();
428
+ expect(() => anyNumber.parse("2.1e-5")).toThrow();
429
+ expect(() => anyNumber.parse("2.1e+5")).toThrow();
430
+ expect(() => anyNumber.parse("-2.1e5")).toThrow();
431
+ expect(() => anyNumber.parse("-2.1e-5")).toThrow();
432
+ expect(() => anyNumber.parse("-2.1e+5")).toThrow();
433
+ expect(() => anyNumber.parse("-Infinity")).toThrow();
434
+ expect(() => anyNumber.parse("Infinity")).toThrow();
435
+ expect(() => anyInt.parse("1.23")).toThrow();
436
+ expect(() => anyInt.parse("-1.23")).toThrow();
437
+ expect(() => anyInt.parse("d1")).toThrow();
438
+ expect(() => anyInt.parse("1d")).toThrow();
439
+ // expect(() => anyFiniteNumber.parse("Infinity")).toThrow();
440
+ // expect(() => anyFiniteNumber.parse("-Infinity")).toThrow();
441
+ // expect(() => anyFiniteNumber.parse("123a")).toThrow();
442
+ // expect(() => anyFiniteNumber.parse("a123")).toThrow();
443
+ // expect(() => anyNegativeNumber.parse("0")).toThrow();
444
+ // expect(() => anyNegativeNumber.parse("1")).toThrow();
445
+ // expect(() => anyNegativeNumber.parse("Infinity")).toThrow();
446
+ // expect(() => anyPositiveNumber.parse("0")).toThrow();
447
+ // expect(() => anyPositiveNumber.parse("-1")).toThrow();
448
+ // expect(() => anyPositiveNumber.parse("-Infinity")).toThrow();
449
+ // expect(() => zeroButInADumbWay.parse("1")).toThrow();
450
+ // expect(() => zeroButInADumbWay.parse("-1")).toThrow();
451
+ // expect(() => finiteButInADumbWay.parse("Infinity")).toThrow();
452
+ // expect(() => finiteButInADumbWay.parse("-Infinity")).toThrow();
453
+ // expect(() => finiteButInADumbWay.parse("-5")).toThrow();
454
+ // expect(() => finiteButInADumbWay.parse("10a")).toThrow();
455
+ // expect(() => finiteButInADumbWay.parse("a10")).toThrow();
456
+ expect(() => bool.parse("123")).toThrow();
457
+ expect(() => bigone.parse("2")).toThrow();
458
+ expect(() => bigone.parse("c1")).toThrow();
459
+ expect(() => anyBigint.parse("1.23")).toThrow();
460
+ expect(() => anyBigint.parse("-1.23")).toThrow();
461
+ expect(() => anyBigint.parse("c123")).toThrow();
462
+ expect(() => nullableYo.parse("yo1")).toThrow();
463
+ expect(() => nullableYo.parse("1yo")).toThrow();
464
+ expect(() => nullableYo.parse("null1")).toThrow();
465
+ expect(() => nullableYo.parse("1null")).toThrow();
466
+ expect(() => optionalYeah.parse("yeah1")).toThrow();
467
+ expect(() => optionalYeah.parse("1yeah")).toThrow();
468
+ expect(() => optionalYeah.parse("undefined")).toThrow();
469
+ expect(() => optionalNumber.parse("123a")).toThrow();
470
+ expect(() => optionalNumber.parse("a123")).toThrow();
471
+ // expect(() => optionalNumber.parse("Infinitya")).toThrow();
472
+ // expect(() => optionalNumber.parse("aInfinity")).toThrow();
473
+ expect(() => nullishBruh.parse("bruh1")).toThrow();
474
+ expect(() => nullishBruh.parse("1bruh")).toThrow();
475
+ expect(() => nullishBruh.parse("null1")).toThrow();
476
+ expect(() => nullishBruh.parse("1null")).toThrow();
477
+ expect(() => nullishBruh.parse("undefined")).toThrow();
478
+ expect(() => cuid.parse("bjld2cyuq0000t3rmniod1foy")).toThrow();
479
+ expect(() => cuid.parse("cjld2cyu")).toThrow();
480
+ expect(() => cuid.parse("cjld2 cyu")).toThrow();
481
+ expect(() => cuid.parse("cjld2cyuq0000t3rmniod1foy ")).toThrow();
482
+ expect(() => cuid.parse("1cjld2cyuq0000t3rmniod1foy")).toThrow();
483
+ expect(() => cuidZZZ.parse("cjld2cyuq0000t3rmniod1foy")).toThrow();
484
+ expect(() => cuidZZZ.parse("cjld2cyuq0000t3rmniod1foyZZY")).toThrow();
485
+ expect(() => cuidZZZ.parse("cjld2cyuq0000t3rmniod1foyZZZ1")).toThrow();
486
+ expect(() => cuidZZZ.parse("1cjld2cyuq0000t3rmniod1foyZZZ")).toThrow();
487
+ expect(() => cuid2.parse("A9z4a98xxat96iws9zmbrgj3a")).toThrow();
488
+ expect(() => cuid2.parse("tz4a98xxat96iws9zmbrgj3!")).toThrow();
489
+ expect(() => datetime.parse("2022-01-01 00:00:00")).toThrow();
490
+ expect(() => email.parse("info@example.com@")).toThrow();
491
+ // expect(() => ip.parse("213.174.246:205")).toThrow();
492
+ // expect(() => ip.parse("c359.f57c:21e5:39eb:1187:e501:f936:b452")).toThrow();
493
+ expect(() => ipv4.parse("1213.174.246.205")).toThrow();
494
+ expect(() => ipv4.parse("c359:f57c:21e5:39eb:1187:e501:f936:b452")).toThrow();
495
+ expect(() => ipv6.parse("c359:f57c:21e5:39eb:1187:e501:f936:b4521")).toThrow();
496
+ expect(() => ipv6.parse("213.174.246.205")).toThrow();
497
+ expect(() => ulid.parse("01GW3D2QZJBYB6P1Z1AE997VPW!")).toThrow();
498
+ expect(() => uuid.parse("808989fd-3a6e-4af2-b607-737323a176f6Z")).toThrow();
499
+ expect(() => uuid.parse("Z808989fd-3a6e-4af2-b607-737323a176f6")).toThrow();
500
+ expect(() => stringAToZ.parse("asdasdasd1")).toThrow();
501
+ expect(() => stringAToZ.parse("1asdasdasd")).toThrow();
502
+ expect(() => stringStartsWith.parse("ahello")).toThrow();
503
+ expect(() => stringEndsWith.parse("worlda")).toThrow();
504
+ expect(() => stringMax5.parse("123456")).toThrow();
505
+ expect(() => stringMin5.parse("1234")).toThrow();
506
+ expect(() => stringLen5.parse("123456")).toThrow();
507
+ expect(() => stringLen5.parse("1234")).toThrow();
508
+ expect(() => stringMin5Max10.parse("1234")).toThrow();
509
+ expect(() => stringMin5Max10.parse("12345678901")).toThrow();
510
+
511
+ // the "startswith" overrides the max length
512
+ // expect(() => stringStartsWithMax5.parse("hello1")).toThrow();
513
+ expect(() => stringStartsWithMax5.parse("1hell")).toThrow();
514
+ expect(() => brandedString.parse("")).toThrow();
515
+ });
516
+
517
+ test("regexes", () => {
518
+ expect(empty._zod.pattern.source).toMatchInlineSnapshot(`"^$"`);
519
+ expect(hello._zod.pattern.source).toMatchInlineSnapshot(`"^hello$"`);
520
+ expect(world._zod.pattern.source).toMatchInlineSnapshot(`"^(world)$"`);
521
+ expect(one._zod.pattern.source).toMatchInlineSnapshot(`"^1$"`);
522
+ expect(two._zod.pattern.source).toMatchInlineSnapshot(`"^(2)$"`);
523
+ expect(truee._zod.pattern.source).toMatchInlineSnapshot(`"^true$"`);
524
+ expect(anotherTrue._zod.pattern.source).toMatchInlineSnapshot(`"^(true)$"`);
525
+ expect(falsee._zod.pattern.source).toMatchInlineSnapshot(`"^false$"`);
526
+ expect(anotherFalse._zod.pattern.source).toMatchInlineSnapshot(`"^(false)$"`);
527
+ expect(nulll._zod.pattern.source).toMatchInlineSnapshot(`"^null$"`);
528
+ expect(anotherNull._zod.pattern.source).toMatchInlineSnapshot(`"^null$"`);
529
+ expect(undefinedd._zod.pattern.source).toMatchInlineSnapshot(`"^undefined$"`);
530
+ expect(anotherUndefined._zod.pattern.source).toMatchInlineSnapshot(`"^undefined$"`);
531
+ expect(anyString._zod.pattern.source).toMatchInlineSnapshot(`"^[\\s\\S]{0,}$"`);
532
+ expect(lazyString._zod.pattern.source).toMatchInlineSnapshot(`"^[\\s\\S]{0,}$"`);
533
+ expect(anyNumber._zod.pattern.source).toMatchInlineSnapshot(`"^-?\\d+(?:\\.\\d+)?$"`);
534
+ expect(anyInt._zod.pattern.source).toMatchInlineSnapshot(`"^\\d+$"`);
535
+ // expect(anyFiniteNumber._zod.pattern.source).toMatchInlineSnapshot(`"^-?\\d+(?:\\.\\d+)?$"`);
536
+ // expect(anyNegativeNumber._zod.pattern.source).toMatchInlineSnapshot(`"^-?\\d+(?:\\.\\d+)?$"`);
537
+ // expect(anyPositiveNumber._zod.pattern.source).toMatchInlineSnapshot(`"^-?\\d+(?:\\.\\d+)?$"`);
538
+ // expect(zeroButInADumbWay._zod.pattern.source).toMatchInlineSnapshot(`"^-?\\d+(?:\\.\\d+)?$"`);
539
+ // expect(finiteButInADumbWay._zod.pattern.source).toMatchInlineSnapshot(`"^-?\\d+(?:\\.\\d+)?$"`);
540
+ expect(bool._zod.pattern.source).toMatchInlineSnapshot(`"^true|false$"`);
541
+ expect(bigone._zod.pattern.source).toMatchInlineSnapshot(`"^(1)$"`);
542
+ expect(anyBigint._zod.pattern.source).toMatchInlineSnapshot(`"^\\d+n?$"`);
543
+ expect(nullableYo._zod.pattern.source).toMatchInlineSnapshot(`"^((yo)|null)$"`);
544
+ expect(nullableString._zod.pattern.source).toMatchInlineSnapshot(`"^([\\s\\S]{0,}|null)$"`);
545
+ expect(optionalYeah._zod.pattern.source).toMatchInlineSnapshot(`"^((yeah))?$"`);
546
+ expect(optionalString._zod.pattern.source).toMatchInlineSnapshot(`"^([\\s\\S]{0,})?$"`);
547
+ expect(optionalNumber._zod.pattern.source).toMatchInlineSnapshot(`"^(-?\\d+(?:\\.\\d+)?)?$"`);
548
+ expect(nullishBruh._zod.pattern.source).toMatchInlineSnapshot(`"^(((bruh)|null))?$"`);
549
+ expect(nullishString._zod.pattern.source).toMatchInlineSnapshot(`"^(([\\s\\S]{0,}|null))?$"`);
550
+ expect(cuid._zod.pattern.source).toMatchInlineSnapshot(`"^[cC][^\\s-]{8,}$"`);
551
+ expect(cuidZZZ._zod.pattern.source).toMatchInlineSnapshot(`"^[cC][^\\s-]{8,}ZZZ$"`);
552
+ expect(cuid2._zod.pattern.source).toMatchInlineSnapshot(`"^[0-9a-z]+$"`);
553
+ expect(datetime._zod.pattern.source).toMatchInlineSnapshot(
554
+ `"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"`
555
+ );
556
+ expect(email._zod.pattern.source).toMatchInlineSnapshot(
557
+ `"^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"`
558
+ );
559
+ // expect(ip._zod.pattern.source).toMatchInlineSnapshot(
560
+ // `"^(^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$)|(^(([a-fA-F0-9]{1,4}:){7}|::([a-fA-F0-9]{1,4}:){0,6}|([a-fA-F0-9]{1,4}:){1}:([a-fA-F0-9]{1,4}:){0,5}|([a-fA-F0-9]{1,4}:){2}:([a-fA-F0-9]{1,4}:){0,4}|([a-fA-F0-9]{1,4}:){3}:([a-fA-F0-9]{1,4}:){0,3}|([a-fA-F0-9]{1,4}:){4}:([a-fA-F0-9]{1,4}:){0,2}|([a-fA-F0-9]{1,4}:){5}:([a-fA-F0-9]{1,4}:){0,1})([a-fA-F0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$)$"`
561
+ // );
562
+ expect(ipv4._zod.pattern.source).toMatchInlineSnapshot(
563
+ `"^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$"`
564
+ );
565
+ expect(ipv6._zod.pattern.source).toMatchInlineSnapshot(
566
+ `"^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$"`
567
+ );
568
+ expect(ulid._zod.pattern.source).toMatchInlineSnapshot(`"^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$"`);
569
+ expect(uuid._zod.pattern.source).toMatchInlineSnapshot(
570
+ `"^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$"`
571
+ );
572
+ expect(stringAToZ._zod.pattern.source).toMatchInlineSnapshot(`"^[a-z]+$"`);
573
+ expect(stringStartsWith._zod.pattern.source).toMatchInlineSnapshot(`"^hello.*$"`);
574
+ expect(stringEndsWith._zod.pattern.source).toMatchInlineSnapshot(`"^.*world$"`);
575
+ expect(stringMax5._zod.pattern.source).toMatchInlineSnapshot(`"^[\\s\\S]{0,5}$"`);
576
+ expect(stringMin5._zod.pattern.source).toMatchInlineSnapshot(`"^[\\s\\S]{5,}$"`);
577
+ expect(stringLen5._zod.pattern.source).toMatchInlineSnapshot(`"^[\\s\\S]{5,5}$"`);
578
+ expect(stringMin5Max10._zod.pattern.source).toMatchInlineSnapshot(`"^[\\s\\S]{5,10}$"`);
579
+ expect(brandedString._zod.pattern.source).toMatchInlineSnapshot(`"^[\\s\\S]{1,}$"`);
580
+ expect(url._zod.pattern.source).toMatchInlineSnapshot(`"^https:\\/\\/\\w+\\.(com|net)$"`);
581
+ expect(measurement._zod.pattern.source).toMatchInlineSnapshot(`"^-?\\d+(?:\\.\\d+)?((px|em|rem|vh|vw|vmin|vmax))?$"`);
582
+ expect(connectionString._zod.pattern.source).toMatchInlineSnapshot(
583
+ `"^mongodb:\\/\\/(\\w+:\\w+@)?\\w+:\\d+(\\/(\\w+)?(\\?(\\w+=\\w+(&\\w+=\\w+)*)?)?)?$"`
584
+ );
585
+ });
586
+
587
+ test("template literal parsing - success - complex cases", () => {
588
+ url.parse("https://example.com");
589
+ url.parse("https://speedtest.net");
590
+
591
+ // measurement.parse(1);
592
+ // measurement.parse(1.1);
593
+ // measurement.parse(0);
594
+ // measurement.parse(-1.1);
595
+ // measurement.parse(-1);
596
+ measurement.parse("1");
597
+ measurement.parse("1.1");
598
+ measurement.parse("0");
599
+ measurement.parse("-1");
600
+ measurement.parse("-1.1");
601
+ measurement.parse("1px");
602
+ measurement.parse("1.1px");
603
+ measurement.parse("0px");
604
+ measurement.parse("-1px");
605
+ measurement.parse("-1.1px");
606
+ measurement.parse("1em");
607
+ measurement.parse("1.1em");
608
+ measurement.parse("0em");
609
+ measurement.parse("-1em");
610
+ measurement.parse("-1.1em");
611
+ measurement.parse("1rem");
612
+ measurement.parse("1.1rem");
613
+ measurement.parse("0rem");
614
+ measurement.parse("-1rem");
615
+ measurement.parse("-1.1rem");
616
+ measurement.parse("1vh");
617
+ measurement.parse("1.1vh");
618
+ measurement.parse("0vh");
619
+ measurement.parse("-1vh");
620
+ measurement.parse("-1.1vh");
621
+ measurement.parse("1vw");
622
+ measurement.parse("1.1vw");
623
+ measurement.parse("0vw");
624
+ measurement.parse("-1vw");
625
+ measurement.parse("-1.1vw");
626
+ measurement.parse("1vmin");
627
+ measurement.parse("1.1vmin");
628
+ measurement.parse("0vmin");
629
+ measurement.parse("-1vmin");
630
+ measurement.parse("-1.1vmin");
631
+ measurement.parse("1vmax");
632
+ measurement.parse("1.1vmax");
633
+ measurement.parse("0vmax");
634
+ measurement.parse("-1vmax");
635
+ measurement.parse("-1.1vmax");
636
+
637
+ connectionString.parse("mongodb://host:1234");
638
+ connectionString.parse("mongodb://host:1234/");
639
+ connectionString.parse("mongodb://host:1234/defaultauthdb");
640
+ connectionString.parse("mongodb://host:1234/defaultauthdb?authSource=admin");
641
+ connectionString.parse("mongodb://host:1234/defaultauthdb?authSource=admin&connectTimeoutMS=300000");
642
+ connectionString.parse("mongodb://host:1234/?authSource=admin");
643
+ connectionString.parse("mongodb://host:1234/?authSource=admin&connectTimeoutMS=300000");
644
+ connectionString.parse("mongodb://username:password@host:1234");
645
+ connectionString.parse("mongodb://username:password@host:1234/");
646
+ connectionString.parse("mongodb://username:password@host:1234/defaultauthdb");
647
+ connectionString.parse("mongodb://username:password@host:1234/defaultauthdb?authSource=admin");
648
+ connectionString.parse(
649
+ "mongodb://username:password@host:1234/defaultauthdb?authSource=admin&connectTimeoutMS=300000"
650
+ );
651
+ connectionString.parse("mongodb://username:password@host:1234/?authSource=admin");
652
+ connectionString.parse("mongodb://username:password@host:1234/?authSource=admin&connectTimeoutMS=300000");
653
+ });
654
+
655
+ test("template literal parsing - failure - complex cases", () => {
656
+ expect(() => url.parse("http://example.com")).toThrow();
657
+ expect(() => url.parse("https://.com")).toThrow();
658
+ expect(() => url.parse("https://examplecom")).toThrow();
659
+ expect(() => url.parse("https://example.org")).toThrow();
660
+ expect(() => url.parse("https://example.net.il")).toThrow();
661
+
662
+ expect(() => measurement.parse("1.1.1")).toThrow();
663
+ expect(() => measurement.parse("Infinity")).toThrow();
664
+ expect(() => measurement.parse("-Infinity")).toThrow();
665
+ expect(() => measurement.parse("NaN")).toThrow();
666
+ expect(() => measurement.parse("1%")).toThrow();
667
+
668
+ expect(() => connectionString.parse("mongod://host:1234")).toThrow();
669
+ expect(() => connectionString.parse("mongodb://:1234")).toThrow();
670
+ expect(() => connectionString.parse("mongodb://host1234")).toThrow();
671
+ expect(() => connectionString.parse("mongodb://host:d234")).toThrow();
672
+ expect(() => connectionString.parse("mongodb://host:12.34")).toThrow();
673
+ expect(() => connectionString.parse("mongodb://host:-1234")).toThrow();
674
+ expect(() => connectionString.parse("mongodb://host:-12.34")).toThrow();
675
+ expect(() => connectionString.parse("mongodb://host:")).toThrow();
676
+ expect(() => connectionString.parse("mongodb://:password@host:1234")).toThrow();
677
+ expect(() => connectionString.parse("mongodb://usernamepassword@host:1234")).toThrow();
678
+ expect(() => connectionString.parse("mongodb://username:@host:1234")).toThrow();
679
+ expect(() => connectionString.parse("mongodb://@host:1234")).toThrow();
680
+ expect(() => connectionString.parse("mongodb://host:1234/defaultauthdb?authSourceadmin")).toThrow();
681
+ expect(() => connectionString.parse("mongodb://host:1234/?authSourceadmin")).toThrow();
682
+ expect(() => connectionString.parse("mongodb://host:1234/defaultauthdb?&authSource=admin")).toThrow();
683
+ expect(() => connectionString.parse("mongodb://host:1234/?&authSource=admin")).toThrow();
684
+ });
685
+
686
+ test("template literal parsing - failure - issue format", () => {
687
+ expect(anotherNull.safeParse("1null")).toMatchInlineSnapshot(`
688
+ {
689
+ "error": [ZodError: [
690
+ {
691
+ "code": "invalid_format",
692
+ "format": "template_literal",
693
+ "pattern": "^null$",
694
+ "path": [],
695
+ "message": "Invalid input"
696
+ }
697
+ ]],
698
+ "success": false,
699
+ }
700
+ `);
701
+ expect(cuidZZZ.safeParse("1cjld2cyuq0000t3rmniod1foyZZZ")).toMatchInlineSnapshot(`
702
+ {
703
+ "error": [ZodError: [
704
+ {
705
+ "code": "invalid_format",
706
+ "format": "template_literal",
707
+ "pattern": "^[cC][^\\\\s-]{8,}ZZZ$",
708
+ "path": [],
709
+ "message": "Invalid input"
710
+ }
711
+ ]],
712
+ "success": false,
713
+ }
714
+ `);
715
+ expect(stringMin5Max10.safeParse("1234")).toMatchInlineSnapshot(`
716
+ {
717
+ "error": [ZodError: [
718
+ {
719
+ "code": "invalid_format",
720
+ "format": "template_literal",
721
+ "pattern": "^[\\\\s\\\\S]{5,10}$",
722
+ "path": [],
723
+ "message": "Invalid input"
724
+ }
725
+ ]],
726
+ "success": false,
727
+ }
728
+ `);
729
+ expect(connectionString.safeParse("mongodb://host:1234/defaultauthdb?authSourceadmin")).toMatchInlineSnapshot(`
730
+ {
731
+ "error": [ZodError: [
732
+ {
733
+ "code": "invalid_format",
734
+ "format": "template_literal",
735
+ "pattern": "^mongodb:\\\\/\\\\/(\\\\w+:\\\\w+@)?\\\\w+:\\\\d+(\\\\/(\\\\w+)?(\\\\?(\\\\w+=\\\\w+(&\\\\w+=\\\\w+)*)?)?)?$",
736
+ "path": [],
737
+ "message": "Invalid input"
738
+ }
739
+ ]],
740
+ "success": false,
741
+ }
742
+ `);
743
+
744
+ expect(stringStartsWithMax5.safeParse("1hell")).toMatchInlineSnapshot(`
745
+ {
746
+ "error": [ZodError: [
747
+ {
748
+ "code": "invalid_format",
749
+ "format": "template_literal",
750
+ "pattern": "^hello.*$",
751
+ "path": [],
752
+ "message": "Invalid input"
753
+ }
754
+ ]],
755
+ "success": false,
756
+ }
757
+ `);
758
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts ADDED
@@ -0,0 +1,2314 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { describe, expect, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+ // import * as zCore from "zod/v4/core";
4
+
5
+ describe("toJSONSchema", () => {
6
+ test("primitive types", () => {
7
+ expect(z.toJSONSchema(z.string())).toMatchInlineSnapshot(`
8
+ {
9
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
10
+ "type": "string",
11
+ }
12
+ `);
13
+ expect(z.toJSONSchema(z.number())).toMatchInlineSnapshot(`
14
+ {
15
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
16
+ "type": "number",
17
+ }
18
+ `);
19
+ expect(z.toJSONSchema(z.boolean())).toMatchInlineSnapshot(`
20
+ {
21
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
22
+ "type": "boolean",
23
+ }
24
+ `);
25
+ expect(z.toJSONSchema(z.null())).toMatchInlineSnapshot(`
26
+ {
27
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
28
+ "type": "null",
29
+ }
30
+ `);
31
+ expect(z.toJSONSchema(z.undefined(), { unrepresentable: "any" })).toMatchInlineSnapshot(`
32
+ {
33
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
34
+ }
35
+ `);
36
+ expect(z.toJSONSchema(z.any())).toMatchInlineSnapshot(`
37
+ {
38
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
39
+ }
40
+ `);
41
+ expect(z.toJSONSchema(z.unknown())).toMatchInlineSnapshot(`
42
+ {
43
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
44
+ }
45
+ `);
46
+ expect(z.toJSONSchema(z.never())).toMatchInlineSnapshot(`
47
+ {
48
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
49
+ "not": {},
50
+ }
51
+ `);
52
+ expect(z.toJSONSchema(z.email())).toMatchInlineSnapshot(`
53
+ {
54
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
55
+ "format": "email",
56
+ "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$",
57
+ "type": "string",
58
+ }
59
+ `);
60
+ expect(z.toJSONSchema(z.iso.datetime())).toMatchInlineSnapshot(`
61
+ {
62
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
63
+ "format": "date-time",
64
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
65
+ "type": "string",
66
+ }
67
+ `);
68
+ expect(z.toJSONSchema(z.iso.date())).toMatchInlineSnapshot(`
69
+ {
70
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
71
+ "format": "date",
72
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$",
73
+ "type": "string",
74
+ }
75
+ `);
76
+ expect(z.toJSONSchema(z.iso.time())).toMatchInlineSnapshot(`
77
+ {
78
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
79
+ "format": "time",
80
+ "pattern": "^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?$",
81
+ "type": "string",
82
+ }
83
+ `);
84
+ expect(z.toJSONSchema(z.iso.duration())).toMatchInlineSnapshot(`
85
+ {
86
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
87
+ "format": "duration",
88
+ "pattern": "^P(?:(\\d+W)|(?!.*W)(?=\\d|T\\d)(\\d+Y)?(\\d+M)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+([.,]\\d+)?S)?)?)$",
89
+ "type": "string",
90
+ }
91
+ `);
92
+ expect(z.toJSONSchema(z.ipv4())).toMatchInlineSnapshot(`
93
+ {
94
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
95
+ "format": "ipv4",
96
+ "pattern": "^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$",
97
+ "type": "string",
98
+ }
99
+ `);
100
+ expect(z.toJSONSchema(z.ipv6())).toMatchInlineSnapshot(`
101
+ {
102
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
103
+ "format": "ipv6",
104
+ "pattern": "^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$",
105
+ "type": "string",
106
+ }
107
+ `);
108
+ expect(z.toJSONSchema(z.uuid())).toMatchInlineSnapshot(`
109
+ {
110
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
111
+ "format": "uuid",
112
+ "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$",
113
+ "type": "string",
114
+ }
115
+ `);
116
+ expect(z.toJSONSchema(z.guid())).toMatchInlineSnapshot(`
117
+ {
118
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
119
+ "format": "uuid",
120
+ "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$",
121
+ "type": "string",
122
+ }
123
+ `);
124
+ expect(z.toJSONSchema(z.url())).toMatchInlineSnapshot(`
125
+ {
126
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
127
+ "format": "uri",
128
+ "type": "string",
129
+ }
130
+ `);
131
+ expect(z.toJSONSchema(z.base64())).toMatchInlineSnapshot(`
132
+ {
133
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
134
+ "contentEncoding": "base64",
135
+ "format": "base64",
136
+ "pattern": "^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$",
137
+ "type": "string",
138
+ }
139
+ `);
140
+ expect(z.toJSONSchema(z.cuid())).toMatchInlineSnapshot(`
141
+ {
142
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
143
+ "format": "cuid",
144
+ "pattern": "^[cC][^\\s-]{8,}$",
145
+ "type": "string",
146
+ }
147
+ `);
148
+ // expect(z.toJSONSchema(z.regex(/asdf/))).toMatchInlineSnapshot();
149
+ expect(z.toJSONSchema(z.emoji())).toMatchInlineSnapshot(`
150
+ {
151
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
152
+ "format": "emoji",
153
+ "pattern": "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",
154
+ "type": "string",
155
+ }
156
+ `);
157
+ expect(z.toJSONSchema(z.nanoid())).toMatchInlineSnapshot(`
158
+ {
159
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
160
+ "format": "nanoid",
161
+ "pattern": "^[a-zA-Z0-9_-]{21}$",
162
+ "type": "string",
163
+ }
164
+ `);
165
+ expect(z.toJSONSchema(z.cuid2())).toMatchInlineSnapshot(`
166
+ {
167
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
168
+ "format": "cuid2",
169
+ "pattern": "^[0-9a-z]+$",
170
+ "type": "string",
171
+ }
172
+ `);
173
+ expect(z.toJSONSchema(z.ulid())).toMatchInlineSnapshot(`
174
+ {
175
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
176
+ "format": "ulid",
177
+ "pattern": "^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$",
178
+ "type": "string",
179
+ }
180
+ `);
181
+ // expect(z.toJSONSchema(z.cidr())).toMatchInlineSnapshot();
182
+ expect(z.toJSONSchema(z.number())).toMatchInlineSnapshot(`
183
+ {
184
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
185
+ "type": "number",
186
+ }
187
+ `);
188
+ expect(z.toJSONSchema(z.int())).toMatchInlineSnapshot(`
189
+ {
190
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
191
+ "maximum": 9007199254740991,
192
+ "minimum": -9007199254740991,
193
+ "type": "integer",
194
+ }
195
+ `);
196
+ expect(z.toJSONSchema(z.int32())).toMatchInlineSnapshot(`
197
+ {
198
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
199
+ "maximum": 2147483647,
200
+ "minimum": -2147483648,
201
+ "type": "integer",
202
+ }
203
+ `);
204
+ expect(z.toJSONSchema(z.float32())).toMatchInlineSnapshot(`
205
+ {
206
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
207
+ "maximum": 3.4028234663852886e+38,
208
+ "minimum": -3.4028234663852886e+38,
209
+ "type": "number",
210
+ }
211
+ `);
212
+ expect(z.toJSONSchema(z.float64())).toMatchInlineSnapshot(`
213
+ {
214
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
215
+ "maximum": 1.7976931348623157e+308,
216
+ "minimum": -1.7976931348623157e+308,
217
+ "type": "number",
218
+ }
219
+ `);
220
+ expect(z.toJSONSchema(z.jwt())).toMatchInlineSnapshot(`
221
+ {
222
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
223
+ "format": "jwt",
224
+ "type": "string",
225
+ }
226
+ `);
227
+ });
228
+
229
+ test("unsupported schema types", () => {
230
+ expect(() => z.toJSONSchema(z.bigint())).toThrow("BigInt cannot be represented in JSON Schema");
231
+ expect(() => z.toJSONSchema(z.int64())).toThrow("BigInt cannot be represented in JSON Schema");
232
+ expect(() => z.toJSONSchema(z.symbol())).toThrow("Symbols cannot be represented in JSON Schema");
233
+ expect(() => z.toJSONSchema(z.void())).toThrow("Void cannot be represented in JSON Schema");
234
+ expect(() => z.toJSONSchema(z.undefined())).toThrow("Undefined cannot be represented in JSON Schema");
235
+ expect(() => z.toJSONSchema(z.date())).toThrow("Date cannot be represented in JSON Schema");
236
+ expect(() => z.toJSONSchema(z.map(z.string(), z.number()))).toThrow("Map cannot be represented in JSON Schema");
237
+ expect(() => z.toJSONSchema(z.set(z.string()))).toThrow("Set cannot be represented in JSON Schema");
238
+ expect(() => z.toJSONSchema(z.custom(() => true))).toThrow("Custom types cannot be represented in JSON Schema");
239
+
240
+ // Transform
241
+ const transformSchema = z.string().transform((val) => Number.parseInt(val));
242
+ expect(() => z.toJSONSchema(transformSchema)).toThrow("Transforms cannot be represented in JSON Schema");
243
+
244
+ // Static catch values
245
+ const staticCatchSchema = z.string().catch(() => "sup");
246
+ expect(z.toJSONSchema(staticCatchSchema)).toMatchInlineSnapshot(`
247
+ {
248
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
249
+ "default": "sup",
250
+ "type": "string",
251
+ }
252
+ `);
253
+
254
+ // Dynamic catch values
255
+ const dynamicCatchSchema = z.string().catch((ctx) => `${ctx.issues.length}`);
256
+ expect(() => z.toJSONSchema(dynamicCatchSchema)).toThrow("Dynamic catch values are not supported in JSON Schema");
257
+ });
258
+
259
+ test("string formats", () => {
260
+ expect(z.toJSONSchema(z.string().email())).toMatchInlineSnapshot(`
261
+ {
262
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
263
+ "format": "email",
264
+ "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$",
265
+ "type": "string",
266
+ }
267
+ `);
268
+ expect(z.toJSONSchema(z.string().uuid())).toMatchInlineSnapshot(`
269
+ {
270
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
271
+ "format": "uuid",
272
+ "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$",
273
+ "type": "string",
274
+ }
275
+ `);
276
+ expect(z.toJSONSchema(z.iso.datetime())).toMatchInlineSnapshot(`
277
+ {
278
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
279
+ "format": "date-time",
280
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
281
+ "type": "string",
282
+ }
283
+ `);
284
+
285
+ expect(z.toJSONSchema(z.iso.date())).toMatchInlineSnapshot(`
286
+ {
287
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
288
+ "format": "date",
289
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$",
290
+ "type": "string",
291
+ }
292
+ `);
293
+ expect(z.toJSONSchema(z.iso.time())).toMatchInlineSnapshot(`
294
+ {
295
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
296
+ "format": "time",
297
+ "pattern": "^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?$",
298
+ "type": "string",
299
+ }
300
+ `);
301
+ expect(z.toJSONSchema(z.iso.duration())).toMatchInlineSnapshot(`
302
+ {
303
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
304
+ "format": "duration",
305
+ "pattern": "^P(?:(\\d+W)|(?!.*W)(?=\\d|T\\d)(\\d+Y)?(\\d+M)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+([.,]\\d+)?S)?)?)$",
306
+ "type": "string",
307
+ }
308
+ `);
309
+ // expect(z.toJSONSchema(z.string().ip())).toMatchInlineSnapshot(`
310
+ // {
311
+ // "pattern": /\\(\\^\\(\\?:\\(\\?:25\\[0-5\\]\\|2\\[0-4\\]\\[0-9\\]\\|1\\[0-9\\]\\[0-9\\]\\|\\[1-9\\]\\[0-9\\]\\|\\[0-9\\]\\)\\\\\\.\\)\\{3\\}\\(\\?:25\\[0-5\\]\\|2\\[0-4\\]\\[0-9\\]\\|1\\[0-9\\]\\[0-9\\]\\|\\[1-9\\]\\[0-9\\]\\|\\[0-9\\]\\)\\$\\)\\|\\(\\^\\(\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{7\\}\\|::\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{0,6\\}\\|\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{1\\}:\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{0,5\\}\\|\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{2\\}:\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{0,4\\}\\|\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{3\\}:\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{0,3\\}\\|\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{4\\}:\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{0,2\\}\\|\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{5\\}:\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{0,1\\}\\)\\(\\[a-fA-F0-9\\]\\{1,4\\}\\|\\(\\(\\(25\\[0-5\\]\\)\\|\\(2\\[0-4\\]\\[0-9\\]\\)\\|\\(1\\[0-9\\]\\{2\\}\\)\\|\\(\\[0-9\\]\\{1,2\\}\\)\\)\\\\\\.\\)\\{3\\}\\(\\(25\\[0-5\\]\\)\\|\\(2\\[0-4\\]\\[0-9\\]\\)\\|\\(1\\[0-9\\]\\{2\\}\\)\\|\\(\\[0-9\\]\\{1,2\\}\\)\\)\\)\\$\\)/,
312
+ // "type": "string",
313
+ // }
314
+ // `);
315
+ expect(z.toJSONSchema(z.ipv4())).toMatchInlineSnapshot(`
316
+ {
317
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
318
+ "format": "ipv4",
319
+ "pattern": "^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$",
320
+ "type": "string",
321
+ }
322
+ `);
323
+
324
+ expect(z.toJSONSchema(z.ipv6())).toMatchInlineSnapshot(`
325
+ {
326
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
327
+ "format": "ipv6",
328
+ "pattern": "^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$",
329
+ "type": "string",
330
+ }
331
+ `);
332
+
333
+ expect(z.toJSONSchema(z.base64())).toMatchInlineSnapshot(`
334
+ {
335
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
336
+ "contentEncoding": "base64",
337
+ "format": "base64",
338
+ "pattern": "^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$",
339
+ "type": "string",
340
+ }
341
+ `);
342
+ expect(z.toJSONSchema(z.url())).toMatchInlineSnapshot(`
343
+ {
344
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
345
+ "format": "uri",
346
+ "type": "string",
347
+ }
348
+ `);
349
+ expect(z.toJSONSchema(z.guid())).toMatchInlineSnapshot(`
350
+ {
351
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
352
+ "format": "uuid",
353
+ "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$",
354
+ "type": "string",
355
+ }
356
+ `);
357
+ expect(z.toJSONSchema(z.string().regex(/asdf/))).toMatchInlineSnapshot(`
358
+ {
359
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
360
+ "pattern": "asdf",
361
+ "type": "string",
362
+ }
363
+ `);
364
+ });
365
+
366
+ test("string patterns", () => {
367
+ expect(
368
+ z.toJSONSchema(
369
+ z
370
+ .string()
371
+ .startsWith("hello")
372
+ .includes("cruel")
373
+ .includes("dark", { position: 10 })
374
+ .endsWith("world")
375
+ .regex(/stuff/)
376
+ )
377
+ ).toMatchInlineSnapshot(`
378
+ {
379
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
380
+ "allOf": [
381
+ {
382
+ "pattern": "^hello.*",
383
+ },
384
+ {
385
+ "pattern": "cruel",
386
+ },
387
+ {
388
+ "pattern": "^.{10}dark",
389
+ },
390
+ {
391
+ "pattern": ".*world$",
392
+ },
393
+ {
394
+ "pattern": "stuff",
395
+ },
396
+ ],
397
+ "type": "string",
398
+ }
399
+ `);
400
+
401
+ expect(
402
+ z.toJSONSchema(
403
+ z
404
+ .string()
405
+ .startsWith("hello")
406
+ .includes("cruel")
407
+ .includes("dark", { position: 10 })
408
+ .endsWith("world")
409
+ .regex(/stuff/),
410
+ {
411
+ target: "draft-7",
412
+ }
413
+ )
414
+ ).toMatchInlineSnapshot(`
415
+ {
416
+ "$schema": "http://json-schema.org/draft-07/schema#",
417
+ "allOf": [
418
+ {
419
+ "pattern": "^hello.*",
420
+ "type": "string",
421
+ },
422
+ {
423
+ "pattern": "cruel",
424
+ "type": "string",
425
+ },
426
+ {
427
+ "pattern": "^.{10}dark",
428
+ "type": "string",
429
+ },
430
+ {
431
+ "pattern": ".*world$",
432
+ "type": "string",
433
+ },
434
+ {
435
+ "pattern": "stuff",
436
+ "type": "string",
437
+ },
438
+ ],
439
+ "type": "string",
440
+ }
441
+ `);
442
+ });
443
+
444
+ test("number constraints", () => {
445
+ expect(z.toJSONSchema(z.number().min(5).max(10))).toMatchInlineSnapshot(
446
+ `
447
+ {
448
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
449
+ "maximum": 10,
450
+ "minimum": 5,
451
+ "type": "number",
452
+ }
453
+ `
454
+ );
455
+
456
+ expect(z.toJSONSchema(z.number().gt(5).gt(10))).toMatchInlineSnapshot(`
457
+ {
458
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
459
+ "exclusiveMinimum": 10,
460
+ "type": "number",
461
+ }
462
+ `);
463
+
464
+ expect(z.toJSONSchema(z.number().gt(5).gte(10))).toMatchInlineSnapshot(`
465
+ {
466
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
467
+ "minimum": 10,
468
+ "type": "number",
469
+ }
470
+ `);
471
+
472
+ expect(z.toJSONSchema(z.number().lt(5).lt(3))).toMatchInlineSnapshot(`
473
+ {
474
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
475
+ "exclusiveMaximum": 3,
476
+ "type": "number",
477
+ }
478
+ `);
479
+
480
+ expect(z.toJSONSchema(z.number().lt(5).lt(3).lte(2))).toMatchInlineSnapshot(`
481
+ {
482
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
483
+ "maximum": 2,
484
+ "type": "number",
485
+ }
486
+ `);
487
+
488
+ expect(z.toJSONSchema(z.number().lt(5).lte(3))).toMatchInlineSnapshot(`
489
+ {
490
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
491
+ "maximum": 3,
492
+ "type": "number",
493
+ }
494
+ `);
495
+
496
+ expect(z.toJSONSchema(z.number().gt(5).lt(10))).toMatchInlineSnapshot(`
497
+ {
498
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
499
+ "exclusiveMaximum": 10,
500
+ "exclusiveMinimum": 5,
501
+ "type": "number",
502
+ }
503
+ `);
504
+ expect(z.toJSONSchema(z.number().gte(5).lte(10))).toMatchInlineSnapshot(`
505
+ {
506
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
507
+ "maximum": 10,
508
+ "minimum": 5,
509
+ "type": "number",
510
+ }
511
+ `);
512
+ expect(z.toJSONSchema(z.number().positive())).toMatchInlineSnapshot(`
513
+ {
514
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
515
+ "exclusiveMinimum": 0,
516
+ "type": "number",
517
+ }
518
+ `);
519
+ expect(z.toJSONSchema(z.number().negative())).toMatchInlineSnapshot(`
520
+ {
521
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
522
+ "exclusiveMaximum": 0,
523
+ "type": "number",
524
+ }
525
+ `);
526
+ expect(z.toJSONSchema(z.number().nonpositive())).toMatchInlineSnapshot(`
527
+ {
528
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
529
+ "maximum": 0,
530
+ "type": "number",
531
+ }
532
+ `);
533
+ expect(z.toJSONSchema(z.number().nonnegative())).toMatchInlineSnapshot(`
534
+ {
535
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
536
+ "minimum": 0,
537
+ "type": "number",
538
+ }
539
+ `);
540
+ });
541
+
542
+ test("arrays", () => {
543
+ expect(z.toJSONSchema(z.array(z.string()))).toMatchInlineSnapshot(`
544
+ {
545
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
546
+ "items": {
547
+ "type": "string",
548
+ },
549
+ "type": "array",
550
+ }
551
+ `);
552
+ });
553
+
554
+ test("unions", () => {
555
+ const schema = z.union([z.string(), z.number()]);
556
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
557
+ {
558
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
559
+ "anyOf": [
560
+ {
561
+ "type": "string",
562
+ },
563
+ {
564
+ "type": "number",
565
+ },
566
+ ],
567
+ }
568
+ `);
569
+ });
570
+
571
+ test("intersections", () => {
572
+ const schema = z.intersection(z.object({ name: z.string() }), z.object({ age: z.number() }));
573
+
574
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
575
+ {
576
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
577
+ "allOf": [
578
+ {
579
+ "additionalProperties": false,
580
+ "properties": {
581
+ "name": {
582
+ "type": "string",
583
+ },
584
+ },
585
+ "required": [
586
+ "name",
587
+ ],
588
+ "type": "object",
589
+ },
590
+ {
591
+ "additionalProperties": false,
592
+ "properties": {
593
+ "age": {
594
+ "type": "number",
595
+ },
596
+ },
597
+ "required": [
598
+ "age",
599
+ ],
600
+ "type": "object",
601
+ },
602
+ ],
603
+ }
604
+ `);
605
+ });
606
+
607
+ test("record", () => {
608
+ const schema = z.record(z.string(), z.boolean());
609
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
610
+ {
611
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
612
+ "additionalProperties": {
613
+ "type": "boolean",
614
+ },
615
+ "propertyNames": {
616
+ "type": "string",
617
+ },
618
+ "type": "object",
619
+ }
620
+ `);
621
+ });
622
+
623
+ test("tuple", () => {
624
+ const schema = z.tuple([z.string(), z.number()]).rest(z.boolean());
625
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
626
+ {
627
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
628
+ "items": {
629
+ "type": "boolean",
630
+ },
631
+ "prefixItems": [
632
+ {
633
+ "type": "string",
634
+ },
635
+ {
636
+ "type": "number",
637
+ },
638
+ ],
639
+ "type": "array",
640
+ }
641
+ `);
642
+ });
643
+
644
+ test("promise", () => {
645
+ const schema = z.promise(z.string());
646
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
647
+ {
648
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
649
+ "type": "string",
650
+ }
651
+ `);
652
+ });
653
+
654
+ test("lazy", () => {
655
+ const schema = z.lazy(() => z.string());
656
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
657
+ {
658
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
659
+ "type": "string",
660
+ }
661
+ `);
662
+ });
663
+
664
+ // enum
665
+ test("enum", () => {
666
+ const a = z.enum(["a", "b", "c"]);
667
+ expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
668
+ {
669
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
670
+ "enum": [
671
+ "a",
672
+ "b",
673
+ "c",
674
+ ],
675
+ "type": "string",
676
+ }
677
+ `);
678
+
679
+ enum B {
680
+ A = 0,
681
+ B = 1,
682
+ C = 2,
683
+ }
684
+
685
+ const b = z.enum(B);
686
+ expect(z.toJSONSchema(b)).toMatchInlineSnapshot(`
687
+ {
688
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
689
+ "enum": [
690
+ 0,
691
+ 1,
692
+ 2,
693
+ ],
694
+ "type": "number",
695
+ }
696
+ `);
697
+ });
698
+
699
+ // literal
700
+ test("literal", () => {
701
+ const a = z.literal("hello");
702
+ expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
703
+ {
704
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
705
+ "const": "hello",
706
+ "type": "string",
707
+ }
708
+ `);
709
+
710
+ const b = z.literal(7);
711
+ expect(z.toJSONSchema(b)).toMatchInlineSnapshot(`
712
+ {
713
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
714
+ "const": 7,
715
+ "type": "number",
716
+ }
717
+ `);
718
+
719
+ const c = z.literal(["hello", undefined, null, 5, BigInt(1324)]);
720
+ expect(() => z.toJSONSchema(c)).toThrow();
721
+
722
+ const d = z.literal(["hello", null, 5]);
723
+ expect(z.toJSONSchema(d)).toMatchInlineSnapshot(`
724
+ {
725
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
726
+ "enum": [
727
+ "hello",
728
+ null,
729
+ 5,
730
+ ],
731
+ }
732
+ `);
733
+
734
+ const e = z.literal(["hello", "zod", "v4"]);
735
+ expect(z.toJSONSchema(e)).toMatchInlineSnapshot(`
736
+ {
737
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
738
+ "enum": [
739
+ "hello",
740
+ "zod",
741
+ "v4",
742
+ ],
743
+ "type": "string",
744
+ }
745
+ `);
746
+ });
747
+
748
+ // pipe
749
+ test("pipe", () => {
750
+ const schema = z
751
+ .string()
752
+ .transform((val) => Number.parseInt(val))
753
+ .pipe(z.number());
754
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
755
+ {
756
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
757
+ "type": "number",
758
+ }
759
+ `);
760
+ });
761
+
762
+ test("simple objects", () => {
763
+ const schema = z.object({
764
+ name: z.string(),
765
+ age: z.number(),
766
+ });
767
+
768
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(
769
+ `
770
+ {
771
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
772
+ "additionalProperties": false,
773
+ "properties": {
774
+ "age": {
775
+ "type": "number",
776
+ },
777
+ "name": {
778
+ "type": "string",
779
+ },
780
+ },
781
+ "required": [
782
+ "name",
783
+ "age",
784
+ ],
785
+ "type": "object",
786
+ }
787
+ `
788
+ );
789
+ });
790
+
791
+ test("additionalproperties in z.object", () => {
792
+ const a = z.object({
793
+ name: z.string(),
794
+ });
795
+ expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
796
+ {
797
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
798
+ "additionalProperties": false,
799
+ "properties": {
800
+ "name": {
801
+ "type": "string",
802
+ },
803
+ },
804
+ "required": [
805
+ "name",
806
+ ],
807
+ "type": "object",
808
+ }
809
+ `);
810
+ expect(z.toJSONSchema(a, { io: "input" })).toMatchInlineSnapshot(`
811
+ {
812
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
813
+ "properties": {
814
+ "name": {
815
+ "type": "string",
816
+ },
817
+ },
818
+ "required": [
819
+ "name",
820
+ ],
821
+ "type": "object",
822
+ }
823
+ `);
824
+ expect(
825
+ z.toJSONSchema(a, {
826
+ io: "input",
827
+ override(ctx) {
828
+ const def = ctx.zodSchema._zod.def;
829
+ if (def.type === "object" && !def.catchall) {
830
+ (ctx.jsonSchema as z.core.JSONSchema.ObjectSchema).additionalProperties = false;
831
+ }
832
+ },
833
+ })
834
+ ).toMatchInlineSnapshot(`
835
+ {
836
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
837
+ "additionalProperties": false,
838
+ "properties": {
839
+ "name": {
840
+ "type": "string",
841
+ },
842
+ },
843
+ "required": [
844
+ "name",
845
+ ],
846
+ "type": "object",
847
+ }
848
+ `);
849
+ });
850
+
851
+ test("catchall objects", () => {
852
+ const a = z.strictObject({
853
+ name: z.string(),
854
+ age: z.number(),
855
+ });
856
+
857
+ expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
858
+ {
859
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
860
+ "additionalProperties": false,
861
+ "properties": {
862
+ "age": {
863
+ "type": "number",
864
+ },
865
+ "name": {
866
+ "type": "string",
867
+ },
868
+ },
869
+ "required": [
870
+ "name",
871
+ "age",
872
+ ],
873
+ "type": "object",
874
+ }
875
+ `);
876
+
877
+ const b = z
878
+ .object({
879
+ name: z.string(),
880
+ })
881
+ .catchall(z.string());
882
+
883
+ expect(z.toJSONSchema(b)).toMatchInlineSnapshot(`
884
+ {
885
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
886
+ "additionalProperties": {
887
+ "type": "string",
888
+ },
889
+ "properties": {
890
+ "name": {
891
+ "type": "string",
892
+ },
893
+ },
894
+ "required": [
895
+ "name",
896
+ ],
897
+ "type": "object",
898
+ }
899
+ `);
900
+
901
+ const c = z.looseObject({
902
+ name: z.string(),
903
+ });
904
+
905
+ expect(z.toJSONSchema(c)).toMatchInlineSnapshot(`
906
+ {
907
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
908
+ "additionalProperties": {},
909
+ "properties": {
910
+ "name": {
911
+ "type": "string",
912
+ },
913
+ },
914
+ "required": [
915
+ "name",
916
+ ],
917
+ "type": "object",
918
+ }
919
+ `);
920
+ });
921
+
922
+ test("optional fields - object", () => {
923
+ const schema = z.object({
924
+ required: z.string(),
925
+ optional: z.string().optional(),
926
+ nonoptional: z.string().optional().nonoptional(),
927
+ });
928
+
929
+ const result = z.toJSONSchema(schema);
930
+
931
+ expect(result).toMatchInlineSnapshot(`
932
+ {
933
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
934
+ "additionalProperties": false,
935
+ "properties": {
936
+ "nonoptional": {
937
+ "type": "string",
938
+ },
939
+ "optional": {
940
+ "type": "string",
941
+ },
942
+ "required": {
943
+ "type": "string",
944
+ },
945
+ },
946
+ "required": [
947
+ "required",
948
+ "nonoptional",
949
+ ],
950
+ "type": "object",
951
+ }
952
+ `);
953
+ });
954
+
955
+ test("recursive object", () => {
956
+ interface Category {
957
+ name: string;
958
+ subcategories: Category[];
959
+ }
960
+
961
+ const categorySchema: z.ZodType<Category> = z.object({
962
+ name: z.string(),
963
+ subcategories: z.array(z.lazy(() => categorySchema)),
964
+ });
965
+
966
+ const result = z.toJSONSchema(categorySchema);
967
+ expect(result).toMatchInlineSnapshot(`
968
+ {
969
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
970
+ "additionalProperties": false,
971
+ "properties": {
972
+ "name": {
973
+ "type": "string",
974
+ },
975
+ "subcategories": {
976
+ "items": {
977
+ "$ref": "#",
978
+ },
979
+ "type": "array",
980
+ },
981
+ },
982
+ "required": [
983
+ "name",
984
+ "subcategories",
985
+ ],
986
+ "type": "object",
987
+ }
988
+ `);
989
+ });
990
+
991
+ test("simple interface", () => {
992
+ const userSchema = z.object({
993
+ name: z.string(),
994
+ age: z.number().optional(),
995
+ });
996
+
997
+ const result = z.toJSONSchema(userSchema);
998
+ expect(result).toMatchInlineSnapshot(`
999
+ {
1000
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1001
+ "additionalProperties": false,
1002
+ "properties": {
1003
+ "age": {
1004
+ "type": "number",
1005
+ },
1006
+ "name": {
1007
+ "type": "string",
1008
+ },
1009
+ },
1010
+ "required": [
1011
+ "name",
1012
+ ],
1013
+ "type": "object",
1014
+ }
1015
+ `);
1016
+ });
1017
+
1018
+ test("catchall interface", () => {
1019
+ const a = z.strictObject({
1020
+ name: z.string(),
1021
+ age: z.number(),
1022
+ });
1023
+
1024
+ expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
1025
+ {
1026
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1027
+ "additionalProperties": false,
1028
+ "properties": {
1029
+ "age": {
1030
+ "type": "number",
1031
+ },
1032
+ "name": {
1033
+ "type": "string",
1034
+ },
1035
+ },
1036
+ "required": [
1037
+ "name",
1038
+ "age",
1039
+ ],
1040
+ "type": "object",
1041
+ }
1042
+ `);
1043
+
1044
+ const b = z
1045
+ .object({
1046
+ name: z.string(),
1047
+ })
1048
+ .catchall(z.string());
1049
+
1050
+ expect(z.toJSONSchema(b)).toMatchInlineSnapshot(`
1051
+ {
1052
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1053
+ "additionalProperties": {
1054
+ "type": "string",
1055
+ },
1056
+ "properties": {
1057
+ "name": {
1058
+ "type": "string",
1059
+ },
1060
+ },
1061
+ "required": [
1062
+ "name",
1063
+ ],
1064
+ "type": "object",
1065
+ }
1066
+ `);
1067
+
1068
+ const c = z.looseObject({
1069
+ name: z.string(),
1070
+ });
1071
+
1072
+ expect(z.toJSONSchema(c)).toMatchInlineSnapshot(`
1073
+ {
1074
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1075
+ "additionalProperties": {},
1076
+ "properties": {
1077
+ "name": {
1078
+ "type": "string",
1079
+ },
1080
+ },
1081
+ "required": [
1082
+ "name",
1083
+ ],
1084
+ "type": "object",
1085
+ }
1086
+ `);
1087
+ });
1088
+
1089
+ test("recursive interface schemas", () => {
1090
+ const TreeNodeSchema = z.object({
1091
+ id: z.string(),
1092
+ get children() {
1093
+ return TreeNodeSchema;
1094
+ },
1095
+ });
1096
+
1097
+ const result = z.toJSONSchema(TreeNodeSchema);
1098
+
1099
+ // Should have definitions for recursive schema
1100
+ expect(JSON.stringify(result, null, 2)).toMatchInlineSnapshot(
1101
+ `
1102
+ "{
1103
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1104
+ "type": "object",
1105
+ "properties": {
1106
+ "id": {
1107
+ "type": "string"
1108
+ },
1109
+ "children": {
1110
+ "$ref": "#"
1111
+ }
1112
+ },
1113
+ "required": [
1114
+ "id",
1115
+ "children"
1116
+ ],
1117
+ "additionalProperties": false
1118
+ }"
1119
+ `
1120
+ );
1121
+ });
1122
+
1123
+ test("mutually recursive interface schemas", () => {
1124
+ const FolderSchema = z.object({
1125
+ name: z.string(),
1126
+ get files() {
1127
+ return z.array(FileSchema);
1128
+ },
1129
+ });
1130
+
1131
+ const FileSchema = z.object({
1132
+ name: z.string(),
1133
+ get parent() {
1134
+ return FolderSchema;
1135
+ },
1136
+ });
1137
+
1138
+ const result = z.toJSONSchema(FolderSchema);
1139
+
1140
+ // Should have definitions for both schemas
1141
+ expect(JSON.stringify(result, null, 2)).toMatchInlineSnapshot(
1142
+ `
1143
+ "{
1144
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1145
+ "type": "object",
1146
+ "properties": {
1147
+ "name": {
1148
+ "type": "string"
1149
+ },
1150
+ "files": {
1151
+ "type": "array",
1152
+ "items": {
1153
+ "type": "object",
1154
+ "properties": {
1155
+ "name": {
1156
+ "type": "string"
1157
+ },
1158
+ "parent": {
1159
+ "$ref": "#"
1160
+ }
1161
+ },
1162
+ "required": [
1163
+ "name",
1164
+ "parent"
1165
+ ],
1166
+ "additionalProperties": false
1167
+ }
1168
+ }
1169
+ },
1170
+ "required": [
1171
+ "name",
1172
+ "files"
1173
+ ],
1174
+ "additionalProperties": false
1175
+ }"
1176
+ `
1177
+ );
1178
+ });
1179
+ });
1180
+
1181
+ test("override", () => {
1182
+ const schema = z.z.toJSONSchema(z.string(), {
1183
+ override: (ctx) => {
1184
+ ctx.zodSchema;
1185
+ ctx.jsonSchema;
1186
+ ctx.jsonSchema.whatever = "sup";
1187
+ },
1188
+ });
1189
+ expect(schema).toMatchInlineSnapshot(`
1190
+ {
1191
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1192
+ "type": "string",
1193
+ "whatever": "sup",
1194
+ }
1195
+ `);
1196
+ });
1197
+
1198
+ test("override: do not run on references", () => {
1199
+ let overrideCount = 0;
1200
+ const schema = z
1201
+ .union([z.string().date(), z.string().datetime(), z.string().datetime({ local: true })])
1202
+ .meta({ a: true })
1203
+ .transform((str) => new Date(str))
1204
+ .meta({ b: true })
1205
+ .pipe(z.date())
1206
+ .meta({ c: true })
1207
+ .brand("dateIn");
1208
+ z.z.toJSONSchema(schema, {
1209
+ unrepresentable: "any",
1210
+ io: "input",
1211
+ override(_) {
1212
+ overrideCount++;
1213
+ },
1214
+ });
1215
+
1216
+ expect(overrideCount).toBe(6);
1217
+ });
1218
+
1219
+ test("override with refs", () => {
1220
+ const a = z.string().optional();
1221
+ const result = z.z.toJSONSchema(a, {
1222
+ override(ctx) {
1223
+ if (ctx.zodSchema._zod.def.type === "string") {
1224
+ ctx.jsonSchema.type = "STRING" as "string";
1225
+ }
1226
+ },
1227
+ });
1228
+
1229
+ expect(result).toMatchInlineSnapshot(`
1230
+ {
1231
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1232
+ "type": "STRING",
1233
+ }
1234
+ `);
1235
+ });
1236
+
1237
+ test("override execution order", () => {
1238
+ const schema = z.union([z.string(), z.number()]);
1239
+ let unionSchema!: any;
1240
+ z.z.toJSONSchema(schema, {
1241
+ override(ctx) {
1242
+ if (ctx.zodSchema._zod.def.type === "union") {
1243
+ unionSchema = ctx.jsonSchema;
1244
+ }
1245
+ },
1246
+ });
1247
+
1248
+ expect(unionSchema).toMatchInlineSnapshot(`
1249
+ {
1250
+ "anyOf": [
1251
+ {
1252
+ "type": "string",
1253
+ },
1254
+ {
1255
+ "type": "number",
1256
+ },
1257
+ ],
1258
+ }
1259
+ `);
1260
+ });
1261
+
1262
+ test("override with path", () => {
1263
+ const userSchema = z.object({
1264
+ name: z.string(),
1265
+ age: z.number(),
1266
+ });
1267
+
1268
+ const capturedPaths: (string | number)[][] = [];
1269
+
1270
+ z.toJSONSchema(userSchema, {
1271
+ override(ctx) {
1272
+ capturedPaths.push(ctx.path);
1273
+ },
1274
+ });
1275
+
1276
+ expect(capturedPaths).toMatchInlineSnapshot(`
1277
+ [
1278
+ [
1279
+ "properties",
1280
+ "age",
1281
+ ],
1282
+ [
1283
+ "properties",
1284
+ "name",
1285
+ ],
1286
+ [],
1287
+ ]
1288
+ `);
1289
+ });
1290
+
1291
+ test("pipe", () => {
1292
+ const mySchema = z
1293
+ .string()
1294
+ .transform((val) => val.length)
1295
+ .pipe(z.number());
1296
+ // ZodPipe
1297
+
1298
+ const a = z.z.toJSONSchema(mySchema);
1299
+ expect(a).toMatchInlineSnapshot(`
1300
+ {
1301
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1302
+ "type": "number",
1303
+ }
1304
+ `);
1305
+ // => { type: "number" }
1306
+
1307
+ const b = z.z.toJSONSchema(mySchema, { io: "input" });
1308
+ expect(b).toMatchInlineSnapshot(`
1309
+ {
1310
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1311
+ "type": "string",
1312
+ }
1313
+ `);
1314
+ // => { type: "string" }
1315
+ });
1316
+
1317
+ test("passthrough schemas", () => {
1318
+ const Internal = z.object({
1319
+ num: z.number(),
1320
+ str: z.string(),
1321
+ });
1322
+ //.meta({ id: "Internal" });
1323
+
1324
+ const External = z.object({
1325
+ a: Internal,
1326
+ b: Internal.optional(),
1327
+ c: z.lazy(() => Internal),
1328
+ d: z.promise(Internal),
1329
+ e: z.pipe(Internal, Internal),
1330
+ });
1331
+
1332
+ const result = z.z.toJSONSchema(External, {
1333
+ reused: "ref",
1334
+ });
1335
+ expect(result).toMatchInlineSnapshot(`
1336
+ {
1337
+ "$defs": {
1338
+ "__schema0": {
1339
+ "additionalProperties": false,
1340
+ "properties": {
1341
+ "num": {
1342
+ "type": "number",
1343
+ },
1344
+ "str": {
1345
+ "type": "string",
1346
+ },
1347
+ },
1348
+ "required": [
1349
+ "num",
1350
+ "str",
1351
+ ],
1352
+ "type": "object",
1353
+ },
1354
+ },
1355
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1356
+ "additionalProperties": false,
1357
+ "properties": {
1358
+ "a": {
1359
+ "$ref": "#/$defs/__schema0",
1360
+ },
1361
+ "b": {
1362
+ "$ref": "#/$defs/__schema0",
1363
+ },
1364
+ "c": {
1365
+ "$ref": "#/$defs/__schema0",
1366
+ },
1367
+ "d": {
1368
+ "$ref": "#/$defs/__schema0",
1369
+ },
1370
+ "e": {
1371
+ "$ref": "#/$defs/__schema0",
1372
+ },
1373
+ },
1374
+ "required": [
1375
+ "a",
1376
+ "c",
1377
+ "d",
1378
+ "e",
1379
+ ],
1380
+ "type": "object",
1381
+ }
1382
+ `);
1383
+ });
1384
+
1385
+ test("extract schemas with id", () => {
1386
+ const name = z.string().meta({ id: "name" });
1387
+ const result = z.z.toJSONSchema(
1388
+ z.object({
1389
+ first_name: name,
1390
+ last_name: name.nullable(),
1391
+ middle_name: name.optional(),
1392
+ age: z.number().meta({ id: "age" }),
1393
+ })
1394
+ );
1395
+ expect(result).toMatchInlineSnapshot(`
1396
+ {
1397
+ "$defs": {
1398
+ "age": {
1399
+ "id": "age",
1400
+ "type": "number",
1401
+ },
1402
+ "name": {
1403
+ "id": "name",
1404
+ "type": "string",
1405
+ },
1406
+ },
1407
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1408
+ "additionalProperties": false,
1409
+ "properties": {
1410
+ "age": {
1411
+ "$ref": "#/$defs/age",
1412
+ },
1413
+ "first_name": {
1414
+ "$ref": "#/$defs/name",
1415
+ },
1416
+ "last_name": {
1417
+ "anyOf": [
1418
+ {
1419
+ "$ref": "#/$defs/name",
1420
+ },
1421
+ {
1422
+ "type": "null",
1423
+ },
1424
+ ],
1425
+ },
1426
+ "middle_name": {
1427
+ "$ref": "#/$defs/name",
1428
+ },
1429
+ },
1430
+ "required": [
1431
+ "first_name",
1432
+ "last_name",
1433
+ "age",
1434
+ ],
1435
+ "type": "object",
1436
+ }
1437
+ `);
1438
+ });
1439
+
1440
+ test("unrepresentable literal values are ignored", () => {
1441
+ const a = z.z.toJSONSchema(z.literal(["hello", null, 5, BigInt(1324), undefined]), { unrepresentable: "any" });
1442
+ expect(a).toMatchInlineSnapshot(`
1443
+ {
1444
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1445
+ "enum": [
1446
+ "hello",
1447
+ null,
1448
+ 5,
1449
+ 1324,
1450
+ ],
1451
+ }
1452
+ `);
1453
+
1454
+ const b = z.z.toJSONSchema(z.literal([undefined, null, 5, BigInt(1324)]), { unrepresentable: "any" });
1455
+ expect(b).toMatchInlineSnapshot(`
1456
+ {
1457
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1458
+ "enum": [
1459
+ null,
1460
+ 5,
1461
+ 1324,
1462
+ ],
1463
+ }
1464
+ `);
1465
+
1466
+ const c = z.z.toJSONSchema(z.literal([undefined]), { unrepresentable: "any" });
1467
+ expect(c).toMatchInlineSnapshot(`
1468
+ {
1469
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1470
+ }
1471
+ `);
1472
+ });
1473
+
1474
+ test("describe with id", () => {
1475
+ const jobId = z.string().meta({ id: "jobId" });
1476
+
1477
+ const a = z.z.toJSONSchema(
1478
+ z.object({
1479
+ current: jobId.describe("Current job"),
1480
+ previous: jobId.describe("Previous job"),
1481
+ })
1482
+ );
1483
+ expect(a).toMatchInlineSnapshot(`
1484
+ {
1485
+ "$defs": {
1486
+ "jobId": {
1487
+ "id": "jobId",
1488
+ "type": "string",
1489
+ },
1490
+ },
1491
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1492
+ "additionalProperties": false,
1493
+ "properties": {
1494
+ "current": {
1495
+ "$ref": "#/$defs/jobId",
1496
+ "description": "Current job",
1497
+ },
1498
+ "previous": {
1499
+ "$ref": "#/$defs/jobId",
1500
+ "description": "Previous job",
1501
+ },
1502
+ },
1503
+ "required": [
1504
+ "current",
1505
+ "previous",
1506
+ ],
1507
+ "type": "object",
1508
+ }
1509
+ `);
1510
+ });
1511
+
1512
+ test("overwrite id", () => {
1513
+ const jobId = z.string().meta({ id: "aaa" });
1514
+
1515
+ const a = z.z.toJSONSchema(
1516
+ z.object({
1517
+ current: jobId,
1518
+ previous: jobId.meta({ id: "bbb" }),
1519
+ })
1520
+ );
1521
+ expect(a).toMatchInlineSnapshot(`
1522
+ {
1523
+ "$defs": {
1524
+ "aaa": {
1525
+ "id": "aaa",
1526
+ "type": "string",
1527
+ },
1528
+ "bbb": {
1529
+ "$ref": "#/$defs/aaa",
1530
+ "id": "bbb",
1531
+ },
1532
+ },
1533
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1534
+ "additionalProperties": false,
1535
+ "properties": {
1536
+ "current": {
1537
+ "$ref": "#/$defs/aaa",
1538
+ },
1539
+ "previous": {
1540
+ "$ref": "#/$defs/bbb",
1541
+ },
1542
+ },
1543
+ "required": [
1544
+ "current",
1545
+ "previous",
1546
+ ],
1547
+ "type": "object",
1548
+ }
1549
+ `);
1550
+
1551
+ const b = z.z.toJSONSchema(
1552
+ z.object({
1553
+ current: jobId,
1554
+ previous: jobId.meta({ id: "ccc" }),
1555
+ }),
1556
+ {
1557
+ reused: "ref",
1558
+ }
1559
+ );
1560
+ expect(b).toMatchInlineSnapshot(`
1561
+ {
1562
+ "$defs": {
1563
+ "aaa": {
1564
+ "id": "aaa",
1565
+ "type": "string",
1566
+ },
1567
+ "ccc": {
1568
+ "$ref": "#/$defs/aaa",
1569
+ "id": "ccc",
1570
+ },
1571
+ },
1572
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1573
+ "additionalProperties": false,
1574
+ "properties": {
1575
+ "current": {
1576
+ "$ref": "#/$defs/aaa",
1577
+ },
1578
+ "previous": {
1579
+ "$ref": "#/$defs/ccc",
1580
+ },
1581
+ },
1582
+ "required": [
1583
+ "current",
1584
+ "previous",
1585
+ ],
1586
+ "type": "object",
1587
+ }
1588
+ `);
1589
+ });
1590
+
1591
+ test("overwrite descriptions", () => {
1592
+ const field = z.string().describe("a").describe("b").describe("c");
1593
+
1594
+ const a = z.z.toJSONSchema(
1595
+ z.object({
1596
+ d: field.describe("d"),
1597
+ e: field.describe("e"),
1598
+ })
1599
+ );
1600
+ expect(a).toMatchInlineSnapshot(`
1601
+ {
1602
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1603
+ "additionalProperties": false,
1604
+ "properties": {
1605
+ "d": {
1606
+ "description": "d",
1607
+ "type": "string",
1608
+ },
1609
+ "e": {
1610
+ "description": "e",
1611
+ "type": "string",
1612
+ },
1613
+ },
1614
+ "required": [
1615
+ "d",
1616
+ "e",
1617
+ ],
1618
+ "type": "object",
1619
+ }
1620
+ `);
1621
+
1622
+ const b = z.z.toJSONSchema(
1623
+ z.object({
1624
+ d: field.describe("d"),
1625
+ e: field.describe("e"),
1626
+ }),
1627
+ {
1628
+ reused: "ref",
1629
+ }
1630
+ );
1631
+ expect(b).toMatchInlineSnapshot(`
1632
+ {
1633
+ "$defs": {
1634
+ "__schema0": {
1635
+ "description": "c",
1636
+ "type": "string",
1637
+ },
1638
+ },
1639
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1640
+ "additionalProperties": false,
1641
+ "properties": {
1642
+ "d": {
1643
+ "$ref": "#/$defs/__schema0",
1644
+ "description": "d",
1645
+ },
1646
+ "e": {
1647
+ "$ref": "#/$defs/__schema0",
1648
+ "description": "e",
1649
+ },
1650
+ },
1651
+ "required": [
1652
+ "d",
1653
+ "e",
1654
+ ],
1655
+ "type": "object",
1656
+ }
1657
+ `);
1658
+ });
1659
+
1660
+ test("top-level readonly", () => {
1661
+ const A = z
1662
+ .object({
1663
+ name: z.string(),
1664
+ get b() {
1665
+ return B;
1666
+ },
1667
+ })
1668
+ .readonly()
1669
+ .meta({ id: "A" });
1670
+ // z.globalRegistry.add(A, { id: "A" });
1671
+ // .meta({ id: "A" });
1672
+
1673
+ const B = z
1674
+ .object({
1675
+ name: z.string(),
1676
+ get a() {
1677
+ return A;
1678
+ },
1679
+ })
1680
+ .readonly()
1681
+ .meta({ id: "B" });
1682
+ // z.globalRegistry.add(B, { id: "B" });
1683
+ // .meta({ id: "B" });
1684
+
1685
+ const result = z.z.toJSONSchema(A);
1686
+ expect(result).toMatchInlineSnapshot(`
1687
+ {
1688
+ "$defs": {
1689
+ "B": {
1690
+ "additionalProperties": false,
1691
+ "id": "B",
1692
+ "properties": {
1693
+ "a": {
1694
+ "$ref": "#",
1695
+ },
1696
+ "name": {
1697
+ "type": "string",
1698
+ },
1699
+ },
1700
+ "readOnly": true,
1701
+ "required": [
1702
+ "name",
1703
+ "a",
1704
+ ],
1705
+ "type": "object",
1706
+ },
1707
+ },
1708
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1709
+ "additionalProperties": false,
1710
+ "id": "A",
1711
+ "properties": {
1712
+ "b": {
1713
+ "$ref": "#/$defs/B",
1714
+ },
1715
+ "name": {
1716
+ "type": "string",
1717
+ },
1718
+ },
1719
+ "readOnly": true,
1720
+ "required": [
1721
+ "name",
1722
+ "b",
1723
+ ],
1724
+ "type": "object",
1725
+ }
1726
+ `);
1727
+ });
1728
+
1729
+ test("basic registry", () => {
1730
+ const myRegistry = z.registry<{ id: string }>();
1731
+ const User = z.object({
1732
+ name: z.string(),
1733
+ get posts() {
1734
+ return z.array(Post);
1735
+ },
1736
+ });
1737
+
1738
+ const Post = z.object({
1739
+ title: z.string(),
1740
+ content: z.string(),
1741
+ get author() {
1742
+ return User;
1743
+ },
1744
+ });
1745
+
1746
+ myRegistry.add(User, { id: "User" });
1747
+ myRegistry.add(Post, { id: "Post" });
1748
+
1749
+ const result = z.z.toJSONSchema(myRegistry, { uri: (id) => `https://example.com/${id}.json` });
1750
+ expect(result).toMatchInlineSnapshot(`
1751
+ {
1752
+ "schemas": {
1753
+ "Post": {
1754
+ "$id": "https://example.com/Post.json",
1755
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1756
+ "additionalProperties": false,
1757
+ "properties": {
1758
+ "author": {
1759
+ "$ref": "https://example.com/User.json",
1760
+ },
1761
+ "content": {
1762
+ "type": "string",
1763
+ },
1764
+ "title": {
1765
+ "type": "string",
1766
+ },
1767
+ },
1768
+ "required": [
1769
+ "title",
1770
+ "content",
1771
+ "author",
1772
+ ],
1773
+ "type": "object",
1774
+ },
1775
+ "User": {
1776
+ "$id": "https://example.com/User.json",
1777
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1778
+ "additionalProperties": false,
1779
+ "properties": {
1780
+ "name": {
1781
+ "type": "string",
1782
+ },
1783
+ "posts": {
1784
+ "items": {
1785
+ "$ref": "https://example.com/Post.json",
1786
+ },
1787
+ "type": "array",
1788
+ },
1789
+ },
1790
+ "required": [
1791
+ "name",
1792
+ "posts",
1793
+ ],
1794
+ "type": "object",
1795
+ },
1796
+ },
1797
+ }
1798
+ `);
1799
+ });
1800
+
1801
+ test("_ref", () => {
1802
+ // const a = z.promise(z.string().describe("a"));
1803
+ const a = z.z.toJSONSchema(z.promise(z.string().describe("a")));
1804
+ expect(a).toMatchInlineSnapshot(`
1805
+ {
1806
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1807
+ "description": "a",
1808
+ "type": "string",
1809
+ }
1810
+ `);
1811
+
1812
+ const b = z.z.toJSONSchema(z.lazy(() => z.string().describe("a")));
1813
+ expect(b).toMatchInlineSnapshot(`
1814
+ {
1815
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1816
+ "description": "a",
1817
+ "type": "string",
1818
+ }
1819
+ `);
1820
+
1821
+ const c = z.z.toJSONSchema(z.optional(z.string().describe("a")));
1822
+ expect(c).toMatchInlineSnapshot(`
1823
+ {
1824
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1825
+ "description": "a",
1826
+ "type": "string",
1827
+ }
1828
+ `);
1829
+ });
1830
+
1831
+ test("defaults/prefaults", () => {
1832
+ const a = z
1833
+ .string()
1834
+ .transform((val) => val.length)
1835
+ .pipe(z.number());
1836
+ const b = a.prefault("hello");
1837
+ const c = a.default(1234);
1838
+
1839
+ // a
1840
+ expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
1841
+ {
1842
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1843
+ "type": "number",
1844
+ }
1845
+ `);
1846
+ expect(z.toJSONSchema(a, { io: "input" })).toMatchInlineSnapshot(`
1847
+ {
1848
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1849
+ "type": "string",
1850
+ }
1851
+ `);
1852
+
1853
+ // b
1854
+ expect(z.toJSONSchema(b)).toMatchInlineSnapshot(`
1855
+ {
1856
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1857
+ "type": "number",
1858
+ }
1859
+ `);
1860
+ expect(z.toJSONSchema(b, { io: "input" })).toMatchInlineSnapshot(`
1861
+ {
1862
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1863
+ "default": "hello",
1864
+ "type": "string",
1865
+ }
1866
+ `);
1867
+ // c
1868
+ expect(z.toJSONSchema(c)).toMatchInlineSnapshot(`
1869
+ {
1870
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1871
+ "default": 1234,
1872
+ "type": "number",
1873
+ }
1874
+ `);
1875
+ expect(z.toJSONSchema(c, { io: "input" })).toMatchInlineSnapshot(`
1876
+ {
1877
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1878
+ "type": "string",
1879
+ }
1880
+ `);
1881
+ });
1882
+
1883
+ test("input type", () => {
1884
+ const schema = z.object({
1885
+ a: z.string(),
1886
+ b: z.string().optional(),
1887
+ c: z.string().default("hello"),
1888
+ d: z.string().nullable(),
1889
+ e: z.string().prefault("hello"),
1890
+ f: z.string().catch("hello"),
1891
+ g: z.never(),
1892
+ h: z.union([z.string(), z.number().default(2)]),
1893
+ i: z.union([z.string(), z.string().optional()]),
1894
+ });
1895
+ expect(z.toJSONSchema(schema, { io: "input" })).toMatchInlineSnapshot(`
1896
+ {
1897
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1898
+ "properties": {
1899
+ "a": {
1900
+ "type": "string",
1901
+ },
1902
+ "b": {
1903
+ "type": "string",
1904
+ },
1905
+ "c": {
1906
+ "default": "hello",
1907
+ "type": "string",
1908
+ },
1909
+ "d": {
1910
+ "anyOf": [
1911
+ {
1912
+ "type": "string",
1913
+ },
1914
+ {
1915
+ "type": "null",
1916
+ },
1917
+ ],
1918
+ },
1919
+ "e": {
1920
+ "default": "hello",
1921
+ "type": "string",
1922
+ },
1923
+ "f": {
1924
+ "default": "hello",
1925
+ "type": "string",
1926
+ },
1927
+ "g": {
1928
+ "not": {},
1929
+ },
1930
+ "h": {
1931
+ "anyOf": [
1932
+ {
1933
+ "type": "string",
1934
+ },
1935
+ {
1936
+ "default": 2,
1937
+ "type": "number",
1938
+ },
1939
+ ],
1940
+ },
1941
+ "i": {
1942
+ "anyOf": [
1943
+ {
1944
+ "type": "string",
1945
+ },
1946
+ {
1947
+ "type": "string",
1948
+ },
1949
+ ],
1950
+ },
1951
+ },
1952
+ "required": [
1953
+ "a",
1954
+ "d",
1955
+ "g",
1956
+ ],
1957
+ "type": "object",
1958
+ }
1959
+ `);
1960
+ expect(z.toJSONSchema(schema, { io: "output" })).toMatchInlineSnapshot(`
1961
+ {
1962
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1963
+ "additionalProperties": false,
1964
+ "properties": {
1965
+ "a": {
1966
+ "type": "string",
1967
+ },
1968
+ "b": {
1969
+ "type": "string",
1970
+ },
1971
+ "c": {
1972
+ "default": "hello",
1973
+ "type": "string",
1974
+ },
1975
+ "d": {
1976
+ "anyOf": [
1977
+ {
1978
+ "type": "string",
1979
+ },
1980
+ {
1981
+ "type": "null",
1982
+ },
1983
+ ],
1984
+ },
1985
+ "e": {
1986
+ "type": "string",
1987
+ },
1988
+ "f": {
1989
+ "default": "hello",
1990
+ "type": "string",
1991
+ },
1992
+ "g": {
1993
+ "not": {},
1994
+ },
1995
+ "h": {
1996
+ "anyOf": [
1997
+ {
1998
+ "type": "string",
1999
+ },
2000
+ {
2001
+ "default": 2,
2002
+ "type": "number",
2003
+ },
2004
+ ],
2005
+ },
2006
+ "i": {
2007
+ "anyOf": [
2008
+ {
2009
+ "type": "string",
2010
+ },
2011
+ {
2012
+ "type": "string",
2013
+ },
2014
+ ],
2015
+ },
2016
+ },
2017
+ "required": [
2018
+ "a",
2019
+ "c",
2020
+ "d",
2021
+ "e",
2022
+ "f",
2023
+ "g",
2024
+ "h",
2025
+ ],
2026
+ "type": "object",
2027
+ }
2028
+ `);
2029
+ });
2030
+
2031
+ test("examples on pipe", () => {
2032
+ const schema = z
2033
+ .string()
2034
+ .meta({ examples: ["test"] })
2035
+ .transform(Number)
2036
+ // .pipe(z.transform(Number).meta({ examples: [4] }))
2037
+ .meta({ examples: [4] });
2038
+
2039
+ const i = z.z.toJSONSchema(schema, { io: "input", unrepresentable: "any" });
2040
+ expect(i).toMatchInlineSnapshot(`
2041
+ {
2042
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2043
+ "examples": [
2044
+ "test",
2045
+ ],
2046
+ "type": "string",
2047
+ }
2048
+ `);
2049
+ const o = z.z.toJSONSchema(schema, { io: "output", unrepresentable: "any" });
2050
+ expect(o).toMatchInlineSnapshot(`
2051
+ {
2052
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2053
+ "examples": [
2054
+ 4,
2055
+ ],
2056
+ }
2057
+ `);
2058
+ });
2059
+
2060
+ // test("number checks", () => {
2061
+ // expect(z.z.toJSONSchema(z.number().int())).toMatchInlineSnapshot(`
2062
+ // {
2063
+ // "maximum": 9007199254740991,
2064
+ // "minimum": -9007199254740991,
2065
+ // "type": "integer",
2066
+ // }
2067
+ // `);
2068
+ // expect(z.z.toJSONSchema(z.int())).toMatchInlineSnapshot(`
2069
+ // {
2070
+ // "maximum": 9007199254740991,
2071
+ // "minimum": -9007199254740991,
2072
+ // "type": "integer",
2073
+ // }
2074
+ // `);
2075
+ // expect(z.z.toJSONSchema(z.int().positive())).toMatchInlineSnapshot(`
2076
+ // {
2077
+ // "exclusiveMinimum": 0,
2078
+ // "maximum": 9007199254740991,
2079
+ // "minimum": -9007199254740991,
2080
+ // "type": "integer",
2081
+ // }
2082
+ // `);
2083
+ // expect(z.z.toJSONSchema(z.int().nonnegative())).toMatchInlineSnapshot(`
2084
+ // {
2085
+ // "maximum": 9007199254740991,
2086
+ // "minimum": 0,
2087
+ // "type": "integer",
2088
+ // }
2089
+ // `);
2090
+ // expect(z.z.toJSONSchema(z.int().gt(0))).toMatchInlineSnapshot(`
2091
+ // {
2092
+ // "exclusiveMinimum": 0,
2093
+ // "maximum": 9007199254740991,
2094
+ // "minimum": -9007199254740991,
2095
+ // "type": "integer",
2096
+ // }
2097
+ // `);
2098
+ // expect(z.z.toJSONSchema(z.int().gte(0))).toMatchInlineSnapshot(`
2099
+ // {
2100
+ // "maximum": 9007199254740991,
2101
+ // "minimum": 0,
2102
+ // "type": "integer",
2103
+ // }
2104
+ // `);
2105
+
2106
+ // });
2107
+
2108
+ test("use output type for preprocess", () => {
2109
+ const a = z.preprocess((val) => String(val), z.string());
2110
+
2111
+ expect(z.toJSONSchema(a, { io: "input" })).toMatchInlineSnapshot(`
2112
+ {
2113
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2114
+ "type": "string",
2115
+ }
2116
+ `);
2117
+ });
2118
+
2119
+ // test("isTransforming", () => {
2120
+ // const tx = z.core.isTransforming;
2121
+ // expect(tx(z.string())).toEqual(false);
2122
+ // expect(tx(z.string().transform((val) => val))).toEqual(true);
2123
+ // expect(tx(z.string().pipe(z.string()))).toEqual(false);
2124
+ // expect(
2125
+ // tx(
2126
+ // z
2127
+ // .string()
2128
+ // .transform((val) => val)
2129
+ // .pipe(z.string())
2130
+ // )
2131
+ // ).toEqual(true);
2132
+
2133
+ // const a = z.transform((val) => val);
2134
+ // expect(tx(z.transform((val) => val))).toEqual(true);
2135
+ // expect(tx(a.optional())).toEqual(true);
2136
+
2137
+ // const b = z.string().optional();
2138
+ // expect(tx(b)).toEqual(false);
2139
+
2140
+ // const c = z.string().prefault("hello");
2141
+ // expect(tx(c)).toEqual(false);
2142
+
2143
+ // const d = z.string().default("hello");
2144
+ // expect(tx(d)).toEqual(false);
2145
+ // });
2146
+
2147
+ test("flatten simple intersections", () => {
2148
+ const FirstSchema = z.object({
2149
+ testNum: z.number(),
2150
+ });
2151
+
2152
+ const SecondSchema = z.object({
2153
+ testStr: z.string(),
2154
+ });
2155
+
2156
+ const ThirdSchema = z.object({
2157
+ testBool: z.boolean(),
2158
+ });
2159
+
2160
+ const HelloSchema = FirstSchema.and(SecondSchema).and(ThirdSchema).describe("123");
2161
+
2162
+ // Zod 3
2163
+ // console.log(JSON.stringify(zodToJsonSchema(HelloSchema), null, 2));
2164
+
2165
+ // Zod 4
2166
+ const result = z.toJSONSchema(HelloSchema, { target: "draft-7" });
2167
+ expect(result).toMatchInlineSnapshot(`
2168
+ {
2169
+ "$schema": "http://json-schema.org/draft-07/schema#",
2170
+ "allOf": [
2171
+ {
2172
+ "additionalProperties": false,
2173
+ "properties": {
2174
+ "testNum": {
2175
+ "type": "number",
2176
+ },
2177
+ },
2178
+ "required": [
2179
+ "testNum",
2180
+ ],
2181
+ "type": "object",
2182
+ },
2183
+ {
2184
+ "additionalProperties": false,
2185
+ "properties": {
2186
+ "testStr": {
2187
+ "type": "string",
2188
+ },
2189
+ },
2190
+ "required": [
2191
+ "testStr",
2192
+ ],
2193
+ "type": "object",
2194
+ },
2195
+ {
2196
+ "additionalProperties": false,
2197
+ "properties": {
2198
+ "testBool": {
2199
+ "type": "boolean",
2200
+ },
2201
+ },
2202
+ "required": [
2203
+ "testBool",
2204
+ ],
2205
+ "type": "object",
2206
+ },
2207
+ ],
2208
+ "description": "123",
2209
+ }
2210
+ `);
2211
+ });
2212
+
2213
+ test("z.file()", () => {
2214
+ const a = z.file();
2215
+ expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
2216
+ {
2217
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2218
+ "contentEncoding": "binary",
2219
+ "format": "binary",
2220
+ "type": "string",
2221
+ }
2222
+ `);
2223
+
2224
+ const b = z.file().mime("image/png").min(1000).max(10000);
2225
+ expect(z.toJSONSchema(b)).toMatchInlineSnapshot(`
2226
+ {
2227
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2228
+ "contentEncoding": "binary",
2229
+ "contentMediaType": "image/png",
2230
+ "format": "binary",
2231
+ "maxLength": 10000,
2232
+ "minLength": 1000,
2233
+ "type": "string",
2234
+ }
2235
+ `);
2236
+
2237
+ const c = z.file().mime(["image/png", "image/jpg"]).min(1000).max(10000);
2238
+ expect(z.toJSONSchema(c)).toMatchInlineSnapshot(`
2239
+ {
2240
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2241
+ "anyOf": [
2242
+ {
2243
+ "contentEncoding": "binary",
2244
+ "contentMediaType": "image/png",
2245
+ "format": "binary",
2246
+ "maxLength": 10000,
2247
+ "minLength": 1000,
2248
+ "type": "string",
2249
+ },
2250
+ {
2251
+ "contentEncoding": "binary",
2252
+ "contentMediaType": "image/jpg",
2253
+ "format": "binary",
2254
+ "maxLength": 10000,
2255
+ "minLength": 1000,
2256
+ "type": "string",
2257
+ },
2258
+ ],
2259
+ }
2260
+ `);
2261
+ });
2262
+
2263
+ test("custom toJSONSchema", () => {
2264
+ const schema = z.instanceof(Date);
2265
+ schema._zod.toJSONSchema = () => ({
2266
+ type: "string",
2267
+ format: "date-time",
2268
+ });
2269
+
2270
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
2271
+ {
2272
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2273
+ "format": "date-time",
2274
+ "type": "string",
2275
+ }
2276
+ `);
2277
+ });
2278
+
2279
+ test("cycle detection - root", () => {
2280
+ const schema = z.object({
2281
+ name: z.string(),
2282
+ get subcategories() {
2283
+ return z.array(schema);
2284
+ },
2285
+ });
2286
+
2287
+ expect(() => z.toJSONSchema(schema, { cycles: "throw" })).toThrowErrorMatchingInlineSnapshot(`
2288
+ [Error: Cycle detected: #/properties/subcategories/items/<root>
2289
+
2290
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.]
2291
+ `);
2292
+ });
2293
+
2294
+ test("cycle detection - mutual recursion", () => {
2295
+ const A = z.object({
2296
+ name: z.string(),
2297
+ get subcategories() {
2298
+ return z.array(B);
2299
+ },
2300
+ });
2301
+
2302
+ const B = z.object({
2303
+ name: z.string(),
2304
+ get subcategories() {
2305
+ return z.array(A);
2306
+ },
2307
+ });
2308
+
2309
+ expect(() => z.toJSONSchema(A, { cycles: "throw" })).toThrowErrorMatchingInlineSnapshot(`
2310
+ [Error: Cycle detected: #/properties/subcategories/items/properties/subcategories/items/<root>
2311
+
2312
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.]
2313
+ `);
2314
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/transform.test.ts ADDED
@@ -0,0 +1,250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+
4
+ test("transform ctx.addIssue with parse", () => {
5
+ const strs = ["foo", "bar"];
6
+ const schema = z.string().transform((data, ctx) => {
7
+ const i = strs.indexOf(data);
8
+ if (i === -1) {
9
+ ctx.addIssue({
10
+ input: data,
11
+ code: "custom",
12
+ message: `${data} is not one of our allowed strings`,
13
+ });
14
+ }
15
+ return data.length;
16
+ });
17
+ const result = schema.safeParse("asdf");
18
+ expect(result.success).toEqual(false);
19
+ expect(result.error!).toMatchInlineSnapshot(`
20
+ [ZodError: [
21
+ {
22
+ "code": "custom",
23
+ "message": "asdf is not one of our allowed strings",
24
+ "path": []
25
+ }
26
+ ]]
27
+ `);
28
+ });
29
+
30
+ test("transform ctx.addIssue with parseAsync", async () => {
31
+ const strs = ["foo", "bar"];
32
+
33
+ const result = await z
34
+ .string()
35
+ .transform(async (data, ctx) => {
36
+ const i = strs.indexOf(data);
37
+ if (i === -1) {
38
+ ctx.addIssue({
39
+ input: data,
40
+ code: "custom",
41
+ message: `${data} is not one of our allowed strings`,
42
+ });
43
+ }
44
+ return data.length;
45
+ })
46
+ .safeParseAsync("asdf");
47
+
48
+ expect(result).toMatchInlineSnapshot(`
49
+ {
50
+ "error": [ZodError: [
51
+ {
52
+ "code": "custom",
53
+ "message": "asdf is not one of our allowed strings",
54
+ "path": []
55
+ }
56
+ ]],
57
+ "success": false,
58
+ }
59
+ `);
60
+ });
61
+
62
+ test("z.NEVER in transform", () => {
63
+ const foo = z
64
+ .number()
65
+ .optional()
66
+ .transform((val, ctx) => {
67
+ if (!val) {
68
+ ctx.addIssue({
69
+ input: val,
70
+ code: z.ZodIssueCode.custom,
71
+ message: "bad",
72
+ });
73
+ return z.NEVER;
74
+ }
75
+ return val;
76
+ });
77
+ type foo = z.infer<typeof foo>;
78
+ expectTypeOf<foo>().toEqualTypeOf<number>();
79
+ const arg = foo.safeParse(undefined);
80
+ if (!arg.success) {
81
+ expect(arg.error.issues[0].message).toEqual("bad");
82
+ }
83
+ });
84
+
85
+ test("basic transformations", () => {
86
+ const r1 = z
87
+ .string()
88
+ .transform((data) => data.length)
89
+ .parse("asdf");
90
+ expect(r1).toEqual(4);
91
+ });
92
+
93
+ test("coercion", () => {
94
+ const numToString = z.number().transform((n) => String(n));
95
+ const data = z
96
+ .object({
97
+ id: numToString,
98
+ })
99
+ .parse({ id: 5 });
100
+
101
+ expect(data).toEqual({ id: "5" });
102
+ });
103
+
104
+ test("async coercion", async () => {
105
+ const numToString = z.number().transform(async (n) => String(n));
106
+ const data = await z
107
+ .object({
108
+ id: numToString,
109
+ })
110
+ .parseAsync({ id: 5 });
111
+
112
+ expect(data).toEqual({ id: "5" });
113
+ });
114
+
115
+ test("sync coercion async error", async () => {
116
+ const asyncNumberToString = z.number().transform(async (n) => String(n));
117
+ expect(() =>
118
+ z
119
+ .object({
120
+ id: asyncNumberToString,
121
+ })
122
+ .parse({ id: 5 })
123
+ ).toThrow();
124
+ // expect(data).toEqual({ id: '5' });
125
+ });
126
+
127
+ test("default", () => {
128
+ const data = z.string().default("asdf").parse(undefined); // => "asdf"
129
+ expect(data).toEqual("asdf");
130
+ });
131
+
132
+ test("dynamic default", () => {
133
+ const data = z
134
+ .string()
135
+ .default(() => "string")
136
+ .parse(undefined); // => "asdf"
137
+ expect(data).toEqual("string");
138
+ });
139
+
140
+ test("default when property is null or undefined", () => {
141
+ const data = z
142
+ .object({
143
+ foo: z.boolean().nullable().default(true),
144
+ bar: z.boolean().default(true),
145
+ })
146
+ .parse({ foo: null });
147
+
148
+ expect(data).toEqual({ foo: null, bar: true });
149
+ });
150
+
151
+ test("default with falsy values", () => {
152
+ const schema = z.object({
153
+ emptyStr: z.string().default("def"),
154
+ zero: z.number().default(5),
155
+ falseBoolean: z.boolean().default(true),
156
+ });
157
+ const input = { emptyStr: "", zero: 0, falseBoolean: true };
158
+ const output = schema.parse(input);
159
+ // defaults are not supposed to be used
160
+ expect(output).toEqual(input);
161
+ });
162
+
163
+ test("object typing", () => {
164
+ const stringToNumber = z.string().transform((arg) => Number.parseFloat(arg));
165
+
166
+ const t1 = z.object({
167
+ stringToNumber,
168
+ });
169
+
170
+ type t1 = z.input<typeof t1>;
171
+ type t2 = z.output<typeof t1>;
172
+
173
+ expectTypeOf<t1>().toEqualTypeOf<{ stringToNumber: string }>();
174
+ expectTypeOf<t2>().toEqualTypeOf<{ stringToNumber: number }>();
175
+ });
176
+
177
+ test("transform method overloads", () => {
178
+ const t1 = z.string().transform((val) => val.toUpperCase());
179
+ expect(t1.parse("asdf")).toEqual("ASDF");
180
+
181
+ const t2 = z.string().transform((val) => val.length);
182
+ expect(t2.parse("asdf")).toEqual(4);
183
+ });
184
+
185
+ test("multiple transformers", () => {
186
+ const stringToNumber = z.string().transform((arg) => Number.parseFloat(arg));
187
+
188
+ const doubler = stringToNumber.transform((val) => {
189
+ return val * 2;
190
+ });
191
+ expect(doubler.parse("5")).toEqual(10);
192
+ });
193
+
194
+ test("short circuit on dirty", () => {
195
+ const schema = z
196
+ .string()
197
+ .refine(() => false)
198
+ .transform((val) => val.toUpperCase());
199
+ const result = schema.safeParse("asdf");
200
+ expect(result.success).toEqual(false);
201
+
202
+ expect(result.error).toMatchInlineSnapshot(`
203
+ [ZodError: [
204
+ {
205
+ "code": "custom",
206
+ "path": [],
207
+ "message": "Invalid input"
208
+ }
209
+ ]]
210
+ `);
211
+
212
+ const result2 = schema.safeParse(1234);
213
+ expect(result2.success).toEqual(false);
214
+ if (!result2.success) {
215
+ expect(result2.error.issues[0].code).toEqual(z.ZodIssueCode.invalid_type);
216
+ }
217
+ });
218
+
219
+ test("async short circuit on dirty", async () => {
220
+ const schema = z
221
+ .string()
222
+ .refine(() => false)
223
+ .transform((val) => val.toUpperCase());
224
+ const result = await schema.spa("asdf");
225
+ expect(result.success).toEqual(false);
226
+
227
+ expect(result.error).toMatchInlineSnapshot(`
228
+ [ZodError: [
229
+ {
230
+ "code": "custom",
231
+ "path": [],
232
+ "message": "Invalid input"
233
+ }
234
+ ]]
235
+ `);
236
+
237
+ const result2 = await schema.spa(1234);
238
+ expect(result2.success).toEqual(false);
239
+
240
+ expect(result2.error).toMatchInlineSnapshot(`
241
+ [ZodError: [
242
+ {
243
+ "expected": "string",
244
+ "code": "invalid_type",
245
+ "path": [],
246
+ "message": "Invalid input: expected string, received number"
247
+ }
248
+ ]]
249
+ `);
250
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/tuple.test.ts ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+
4
+ test("successful validation", () => {
5
+ const testTuple = z.tuple([z.string(), z.number()]);
6
+ expectTypeOf<typeof testTuple._output>().toEqualTypeOf<[string, number]>();
7
+
8
+ const val = testTuple.parse(["asdf", 1234]);
9
+ expect(val).toEqual(val);
10
+
11
+ const r1 = testTuple.safeParse(["asdf", "asdf"]);
12
+ expect(r1.success).toEqual(false);
13
+ expect(r1.error!).toMatchInlineSnapshot(`
14
+ [ZodError: [
15
+ {
16
+ "expected": "number",
17
+ "code": "invalid_type",
18
+ "path": [
19
+ 1
20
+ ],
21
+ "message": "Invalid input: expected number, received string"
22
+ }
23
+ ]]
24
+ `);
25
+
26
+ const r2 = testTuple.safeParse(["asdf", 1234, true]);
27
+ expect(r2.success).toEqual(false);
28
+ expect(r2.error!).toMatchInlineSnapshot(`
29
+ [ZodError: [
30
+ {
31
+ "origin": "array",
32
+ "code": "too_big",
33
+ "maximum": 2,
34
+ "path": [],
35
+ "message": "Too big: expected array to have <2 items"
36
+ }
37
+ ]]
38
+ `);
39
+
40
+ const r3 = testTuple.safeParse({});
41
+ expect(r3.success).toEqual(false);
42
+ expect(r3.error!).toMatchInlineSnapshot(`
43
+ [ZodError: [
44
+ {
45
+ "expected": "tuple",
46
+ "code": "invalid_type",
47
+ "path": [],
48
+ "message": "Invalid input: expected tuple, received object"
49
+ }
50
+ ]]
51
+ `);
52
+ });
53
+
54
+ test("async validation", async () => {
55
+ const testTuple = z
56
+ .tuple([z.string().refine(async () => true), z.number().refine(async () => true)])
57
+ .refine(async () => true);
58
+ expectTypeOf<typeof testTuple._output>().toEqualTypeOf<[string, number]>();
59
+
60
+ const val = await testTuple.parseAsync(["asdf", 1234]);
61
+ expect(val).toEqual(val);
62
+
63
+ const r1 = await testTuple.safeParseAsync(["asdf", "asdf"]);
64
+ expect(r1.success).toEqual(false);
65
+ expect(r1.error!).toMatchInlineSnapshot(`
66
+ [ZodError: [
67
+ {
68
+ "expected": "number",
69
+ "code": "invalid_type",
70
+ "path": [
71
+ 1
72
+ ],
73
+ "message": "Invalid input: expected number, received string"
74
+ }
75
+ ]]
76
+ `);
77
+
78
+ const r2 = await testTuple.safeParseAsync(["asdf", 1234, true]);
79
+ expect(r2.success).toEqual(false);
80
+ expect(r2.error!).toMatchInlineSnapshot(`
81
+ [ZodError: [
82
+ {
83
+ "origin": "array",
84
+ "code": "too_big",
85
+ "maximum": 2,
86
+ "path": [],
87
+ "message": "Too big: expected array to have <2 items"
88
+ }
89
+ ]]
90
+ `);
91
+
92
+ const r3 = await testTuple.safeParseAsync({});
93
+ expect(r3.success).toEqual(false);
94
+ expect(r3.error!).toMatchInlineSnapshot(`
95
+ [ZodError: [
96
+ {
97
+ "expected": "tuple",
98
+ "code": "invalid_type",
99
+ "path": [],
100
+ "message": "Invalid input: expected tuple, received object"
101
+ }
102
+ ]]
103
+ `);
104
+ });
105
+
106
+ test("tuple with optional elements", () => {
107
+ const myTuple = z.tuple([z.string(), z.number().optional(), z.string().optional()]).rest(z.boolean());
108
+ expectTypeOf<typeof myTuple._output>().toEqualTypeOf<[string, number?, string?, ...boolean[]]>();
109
+
110
+ const goodData = [["asdf"], ["asdf", 1234], ["asdf", 1234, "asdf"], ["asdf", 1234, "asdf", true, false, true]];
111
+ for (const data of goodData) {
112
+ expect(myTuple.parse(data)).toEqual(data);
113
+ }
114
+
115
+ const badData = [
116
+ ["asdf", "asdf"],
117
+ ["asdf", 1234, "asdf", "asdf"],
118
+ ["asdf", 1234, "asdf", true, false, "asdf"],
119
+ ];
120
+ for (const data of badData) {
121
+ expect(() => myTuple.parse(data)).toThrow();
122
+ }
123
+ });
124
+
125
+ test("tuple with optional elements followed by required", () => {
126
+ const myTuple = z.tuple([z.string(), z.number().optional(), z.string()]).rest(z.boolean());
127
+ expectTypeOf<typeof myTuple._output>().toEqualTypeOf<[string, number | undefined, string, ...boolean[]]>();
128
+
129
+ const goodData = [
130
+ ["asdf", 1234, "asdf"],
131
+ ["asdf", 1234, "asdf", true, false, true],
132
+ ];
133
+ for (const data of goodData) {
134
+ expect(myTuple.parse(data)).toEqual(data);
135
+ }
136
+
137
+ const badData = [
138
+ ["asdf"],
139
+ ["asdf", 1234],
140
+ ["asdf", 1234, "asdf", "asdf"],
141
+ ["asdf", 1234, "asdf", true, false, "asdf"],
142
+ ];
143
+ for (const data of badData) {
144
+ expect(() => myTuple.parse(data)).toThrow();
145
+ }
146
+ });
147
+
148
+ test("tuple with rest schema", () => {
149
+ const myTuple = z.tuple([z.string(), z.number()]).rest(z.boolean());
150
+ expect(myTuple.parse(["asdf", 1234, true, false, true])).toEqual(["asdf", 1234, true, false, true]);
151
+
152
+ expect(myTuple.parse(["asdf", 1234])).toEqual(["asdf", 1234]);
153
+
154
+ expect(() => myTuple.parse(["asdf", 1234, "asdf"])).toThrow();
155
+ type t1 = z.output<typeof myTuple>;
156
+
157
+ expectTypeOf<t1>().toEqualTypeOf<[string, number, ...boolean[]]>();
158
+ });
159
+
160
+ test("sparse array input", () => {
161
+ const schema = z.tuple([z.string(), z.number()]);
162
+ expect(() => schema.parse(new Array(2))).toThrow();
163
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/union.test.ts ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+
3
+ import * as z from "zod/v4";
4
+
5
+ test("function parsing", () => {
6
+ const schema = z.union([z.string().refine(() => false), z.number().refine(() => false)]);
7
+ const result = schema.safeParse("asdf");
8
+ expect(result.success).toEqual(false);
9
+ });
10
+
11
+ test("union 2", () => {
12
+ const result = z.union([z.number(), z.string().refine(() => false)]).safeParse("a");
13
+ expect(result.success).toEqual(false);
14
+ });
15
+
16
+ test("return valid over invalid", () => {
17
+ const schema = z.union([
18
+ z.object({
19
+ email: z.string().email(),
20
+ }),
21
+ z.string(),
22
+ ]);
23
+ expect(schema.parse("asdf")).toEqual("asdf");
24
+ expect(schema.parse({ email: "asdlkjf@lkajsdf.com" })).toEqual({
25
+ email: "asdlkjf@lkajsdf.com",
26
+ });
27
+ });
28
+
29
+ test("return errors from both union arms", () => {
30
+ const result = z.union([z.number(), z.string().refine(() => false)]).safeParse("a");
31
+ expect(result.success).toEqual(false);
32
+ if (!result.success) {
33
+ expect(result.error.issues).toMatchInlineSnapshot(`
34
+ [
35
+ {
36
+ "code": "invalid_union",
37
+ "errors": [
38
+ [
39
+ {
40
+ "code": "invalid_type",
41
+ "expected": "number",
42
+ "message": "Invalid input: expected number, received string",
43
+ "path": [],
44
+ },
45
+ ],
46
+ [
47
+ {
48
+ "code": "custom",
49
+ "message": "Invalid input",
50
+ "path": [],
51
+ },
52
+ ],
53
+ ],
54
+ "message": "Invalid input",
55
+ "path": [],
56
+ },
57
+ ]
58
+ `);
59
+ }
60
+ });
61
+
62
+ test("options getter", async () => {
63
+ const union = z.union([z.string(), z.number()]);
64
+ union.options[0].parse("asdf");
65
+ union.options[1].parse(1234);
66
+ await union.options[0].parseAsync("asdf");
67
+ await union.options[1].parseAsync(1234);
68
+ });
69
+
70
+ test("readonly union", async () => {
71
+ const options = [z.string(), z.number()] as const;
72
+ const union = z.union(options);
73
+ union.parse("asdf");
74
+ union.parse(12);
75
+ });
76
+
77
+ test("union inferred types", () => {
78
+ const test = z.object({}).or(z.array(z.object({})));
79
+
80
+ type Test = z.output<typeof test>; // <— any
81
+ expectTypeOf<Test>().toEqualTypeOf<Record<string, never> | Array<Record<string, never>>>();
82
+ });
83
+
84
+ test("union values", () => {
85
+ const schema = z.union([z.literal("a"), z.literal("b"), z.literal("c")]);
86
+
87
+ expect(schema._zod.values).toMatchInlineSnapshot(`
88
+ Set {
89
+ "a",
90
+ "b",
91
+ "c",
92
+ }
93
+ `);
94
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/validations.test.ts ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, test } from "vitest";
2
+
3
+ import * as z from "zod/v4";
4
+
5
+ test("string length", async () => {
6
+ try {
7
+ await z.string().length(4).parseAsync("asd");
8
+ } catch (err) {
9
+ // ("String must contain exactly 4 character(s)");
10
+ expect((err as z.ZodError).issues).toMatchInlineSnapshot(`
11
+ [
12
+ {
13
+ "code": "too_small",
14
+ "exact": true,
15
+ "inclusive": true,
16
+ "message": "Too small: expected string to have >=4 characters",
17
+ "minimum": 4,
18
+ "origin": "string",
19
+ "path": [],
20
+ },
21
+ ]
22
+ `);
23
+ }
24
+
25
+ try {
26
+ await z.string().length(4).parseAsync("asdaa");
27
+ } catch (err) {
28
+ // ("String must contain exactly 4 character(s)");
29
+ expect((err as z.ZodError).issues).toMatchInlineSnapshot(`
30
+ [
31
+ {
32
+ "code": "too_big",
33
+ "exact": true,
34
+ "inclusive": true,
35
+ "maximum": 4,
36
+ "message": "Too big: expected string to have <=4 characters",
37
+ "origin": "string",
38
+ "path": [],
39
+ },
40
+ ]
41
+ `);
42
+ }
43
+ });
44
+
45
+ test("string min/max", async () => {
46
+ try {
47
+ await z.string().min(4).parseAsync("asd");
48
+ } catch (err) {
49
+ // ("String must contain at least 4 character(s)");
50
+ expect((err as z.ZodError).issues).toMatchInlineSnapshot(`
51
+ [
52
+ {
53
+ "code": "too_small",
54
+ "inclusive": true,
55
+ "message": "Too small: expected string to have >=4 characters",
56
+ "minimum": 4,
57
+ "origin": "string",
58
+ "path": [],
59
+ },
60
+ ]
61
+ `);
62
+ }
63
+ });
64
+
65
+ test("string max", async () => {
66
+ try {
67
+ await z.string().max(4).parseAsync("aasdfsdfsd");
68
+ } catch (err) {
69
+ // ("String must contain at most 4 character(s)");
70
+ expect((err as z.ZodError).issues).toMatchInlineSnapshot(`
71
+ [
72
+ {
73
+ "code": "too_big",
74
+ "inclusive": true,
75
+ "maximum": 4,
76
+ "message": "Too big: expected string to have <=4 characters",
77
+ "origin": "string",
78
+ "path": [],
79
+ },
80
+ ]
81
+ `);
82
+ }
83
+ });
84
+
85
+ test("number min", async () => {
86
+ try {
87
+ await z.number().min(3).parseAsync(2);
88
+ } catch (err) {
89
+ // ("Number must be greater than or equal to 3");
90
+ expect((err as z.ZodError).issues).toMatchInlineSnapshot(`
91
+ [
92
+ {
93
+ "code": "too_small",
94
+ "inclusive": true,
95
+ "message": "Too small: expected number to be >=3",
96
+ "minimum": 3,
97
+ "origin": "number",
98
+ "path": [],
99
+ },
100
+ ]
101
+ `);
102
+ }
103
+ });
104
+
105
+ test("number gte", async () => {
106
+ try {
107
+ await z.number().gte(3).parseAsync(2);
108
+ } catch (err) {
109
+ // ("Number must be greater than or equal to 3");
110
+ expect((err as z.ZodError).issues).toMatchInlineSnapshot(`
111
+ [
112
+ {
113
+ "code": "too_small",
114
+ "inclusive": true,
115
+ "message": "Too small: expected number to be >=3",
116
+ "minimum": 3,
117
+ "origin": "number",
118
+ "path": [],
119
+ },
120
+ ]
121
+ `);
122
+ }
123
+ });
124
+
125
+ test("number gt", async () => {
126
+ try {
127
+ await z.number().gt(3).parseAsync(3);
128
+ } catch (err) {
129
+ // ("Number must be greater than or equal to 3");
130
+ expect((err as z.ZodError).issues).toMatchInlineSnapshot(`
131
+ [
132
+ {
133
+ "code": "too_small",
134
+ "inclusive": false,
135
+ "message": "Too small: expected number to be >3",
136
+ "minimum": 3,
137
+ "origin": "number",
138
+ "path": [],
139
+ },
140
+ ]
141
+ `);
142
+ }
143
+ });
144
+
145
+ test("number max", async () => {
146
+ try {
147
+ await z.number().max(3).parseAsync(4);
148
+ } catch (err) {
149
+ // ("Number must be less than or equal to 3");
150
+ expect((err as z.ZodError).issues).toMatchInlineSnapshot(`
151
+ [
152
+ {
153
+ "code": "too_big",
154
+ "inclusive": true,
155
+ "maximum": 3,
156
+ "message": "Too big: expected number to be <=3",
157
+ "origin": "number",
158
+ "path": [],
159
+ },
160
+ ]
161
+ `);
162
+ }
163
+ });
164
+
165
+ test("number lte", async () => {
166
+ try {
167
+ await z.number().lte(3).parseAsync(4);
168
+ } catch (err) {
169
+ // ("Number must be less than or equal to 3");
170
+ expect((err as z.ZodError).issues).toMatchInlineSnapshot(`
171
+ [
172
+ {
173
+ "code": "too_big",
174
+ "inclusive": true,
175
+ "maximum": 3,
176
+ "message": "Too big: expected number to be <=3",
177
+ "origin": "number",
178
+ "path": [],
179
+ },
180
+ ]
181
+ `);
182
+ }
183
+ });
184
+
185
+ test("number lt", async () => {
186
+ try {
187
+ await z.number().lt(3).parseAsync(3);
188
+ } catch (err) {
189
+ // ("Number must be less than or equal to 3");
190
+ expect((err as z.ZodError).issues).toMatchInlineSnapshot(`
191
+ [
192
+ {
193
+ "code": "too_big",
194
+ "inclusive": false,
195
+ "maximum": 3,
196
+ "message": "Too big: expected number to be <3",
197
+ "origin": "number",
198
+ "path": [],
199
+ },
200
+ ]
201
+ `);
202
+ }
203
+ });
204
+
205
+ test("number nonnegative", async () => {
206
+ try {
207
+ await z.number().nonnegative().parseAsync(-1);
208
+ } catch (err) {
209
+ // ("Number must be greater than or equal to 0");
210
+ expect((err as z.ZodError).issues).toMatchInlineSnapshot(`
211
+ [
212
+ {
213
+ "code": "too_small",
214
+ "inclusive": true,
215
+ "message": "Too small: expected number to be >=0",
216
+ "minimum": 0,
217
+ "origin": "number",
218
+ "path": [],
219
+ },
220
+ ]
221
+ `);
222
+ }
223
+ });
224
+
225
+ test("number nonpositive", async () => {
226
+ try {
227
+ await z.number().nonpositive().parseAsync(1);
228
+ } catch (err) {
229
+ // ("Number must be less than or equal to 0");
230
+ expect((err as z.ZodError).issues).toMatchInlineSnapshot(`
231
+ [
232
+ {
233
+ "code": "too_big",
234
+ "inclusive": true,
235
+ "maximum": 0,
236
+ "message": "Too big: expected number to be <=0",
237
+ "origin": "number",
238
+ "path": [],
239
+ },
240
+ ]
241
+ `);
242
+ }
243
+ });
244
+
245
+ test("number negative", async () => {
246
+ try {
247
+ await z.number().negative().parseAsync(1);
248
+ } catch (err) {
249
+ // ("Number must be less than 0");
250
+ expect((err as z.ZodError).issues).toMatchInlineSnapshot(`
251
+ [
252
+ {
253
+ "code": "too_big",
254
+ "inclusive": false,
255
+ "maximum": 0,
256
+ "message": "Too big: expected number to be <0",
257
+ "origin": "number",
258
+ "path": [],
259
+ },
260
+ ]
261
+ `);
262
+ }
263
+ });
264
+
265
+ test("number positive", async () => {
266
+ try {
267
+ await z.number().positive().parseAsync(-1);
268
+ } catch (err) {
269
+ // ("Number must be greater than 0");
270
+ expect((err as z.ZodError).issues).toMatchInlineSnapshot(`
271
+ [
272
+ {
273
+ "code": "too_small",
274
+ "inclusive": false,
275
+ "message": "Too small: expected number to be >0",
276
+ "minimum": 0,
277
+ "origin": "number",
278
+ "path": [],
279
+ },
280
+ ]
281
+ `);
282
+ }
283
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/classic/tests/void.test.ts ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+ test("void", () => {
4
+ const v = z.void();
5
+ v.parse(undefined);
6
+
7
+ expect(() => v.parse(null)).toThrow();
8
+ expect(() => v.parse("")).toThrow();
9
+
10
+ type v = z.infer<typeof v>;
11
+ expectTypeOf<v>().toEqualTypeOf<void>();
12
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/api.ts ADDED
@@ -0,0 +1,1594 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as checks from "./checks.js";
2
+ import type * as core from "./core.js";
3
+ import type * as errors from "./errors.js";
4
+ import * as schemas from "./schemas.js";
5
+ import * as util from "./util.js";
6
+
7
+ export type Params<
8
+ T extends schemas.$ZodType | checks.$ZodCheck,
9
+ IssueTypes extends errors.$ZodIssueBase,
10
+ OmitKeys extends keyof T["_zod"]["def"] = never,
11
+ > = util.Flatten<
12
+ Partial<
13
+ util.EmptyToNever<
14
+ Omit<T["_zod"]["def"], OmitKeys> &
15
+ ([IssueTypes] extends [never]
16
+ ? {} // unknown
17
+ : {
18
+ error?: string | errors.$ZodErrorMap<IssueTypes> | undefined;
19
+ /** @deprecated This parameter is deprecated. Use `error` instead. */
20
+ message?: string | undefined; // supported in Zod 3
21
+ })
22
+ >
23
+ >
24
+ >;
25
+
26
+ export type TypeParams<
27
+ T extends schemas.$ZodType = schemas.$ZodType & { _isst: never },
28
+ AlsoOmit extends Exclude<keyof T["_zod"]["def"], "type" | "checks" | "error"> = never,
29
+ > = Params<T, NonNullable<T["_zod"]["isst"]>, "type" | "checks" | "error" | AlsoOmit>;
30
+
31
+ // strips types that are not exposed in the public factory
32
+ // incl. `error`, `check`
33
+ export type CheckParams<
34
+ T extends checks.$ZodCheck = checks.$ZodCheck, // & { _issc: never },
35
+ AlsoOmit extends Exclude<keyof T["_zod"]["def"], "check" | "error"> = never,
36
+ > = Params<T, NonNullable<T["_zod"]["issc"]>, "check" | "error" | AlsoOmit>;
37
+
38
+ // strips types that are not exposed in the public factory
39
+ // incl. `type`, `checks`, `error`, `check`, `format`
40
+ export type StringFormatParams<
41
+ T extends schemas.$ZodStringFormat = schemas.$ZodStringFormat,
42
+ AlsoOmit extends Exclude<keyof T["_zod"]["def"], "type" | "coerce" | "checks" | "error" | "check" | "format"> = never,
43
+ > = Params<
44
+ T,
45
+ NonNullable<T["_zod"]["isst"] | T["_zod"]["issc"]>,
46
+ "type" | "coerce" | "checks" | "error" | "check" | "format" | AlsoOmit
47
+ >;
48
+
49
+ export type CheckStringFormatParams<
50
+ T extends schemas.$ZodStringFormat = schemas.$ZodStringFormat,
51
+ AlsoOmit extends Exclude<keyof T["_zod"]["def"], "type" | "coerce" | "checks" | "error" | "check" | "format"> = never,
52
+ > = Params<T, NonNullable<T["_zod"]["issc"]>, "type" | "coerce" | "checks" | "error" | "check" | "format" | AlsoOmit>;
53
+
54
+ export type CheckTypeParams<
55
+ T extends schemas.$ZodType & checks.$ZodCheck = schemas.$ZodType & checks.$ZodCheck,
56
+ AlsoOmit extends Exclude<keyof T["_zod"]["def"], "type" | "checks" | "error" | "check"> = never,
57
+ > = Params<T, NonNullable<T["_zod"]["isst"] | T["_zod"]["issc"]>, "type" | "checks" | "error" | "check" | AlsoOmit>;
58
+
59
+ // String
60
+ export type $ZodStringParams = TypeParams<schemas.$ZodString<string>, "coerce">;
61
+ export function _string<T extends schemas.$ZodString>(
62
+ Class: util.SchemaClass<T>,
63
+ params?: string | $ZodStringParams
64
+ ): T {
65
+ return new Class({
66
+ type: "string",
67
+ ...util.normalizeParams(params),
68
+ });
69
+ }
70
+
71
+ export function _coercedString<T extends schemas.$ZodString>(
72
+ Class: util.SchemaClass<T>,
73
+ params?: string | $ZodStringParams
74
+ ): T {
75
+ return new Class({
76
+ type: "string",
77
+ coerce: true,
78
+ ...util.normalizeParams(params),
79
+ });
80
+ }
81
+
82
+ export type $ZodStringFormatParams = CheckTypeParams<schemas.$ZodStringFormat, "format" | "coerce">;
83
+ export type $ZodCheckStringFormatParams = CheckParams<checks.$ZodCheckStringFormat, "format">;
84
+ // custom format
85
+
86
+ // Email
87
+ export type $ZodEmailParams = StringFormatParams<schemas.$ZodEmail>;
88
+ export type $ZodCheckEmailParams = CheckStringFormatParams<schemas.$ZodEmail>;
89
+ export function _email<T extends schemas.$ZodEmail>(
90
+ Class: util.SchemaClass<T>,
91
+ params?: string | $ZodEmailParams | $ZodCheckEmailParams
92
+ ): T {
93
+ return new Class({
94
+ type: "string",
95
+ format: "email",
96
+ check: "string_format",
97
+ abort: false,
98
+ ...util.normalizeParams(params),
99
+ });
100
+ }
101
+
102
+ // GUID
103
+ export type $ZodGUIDParams = StringFormatParams<schemas.$ZodGUID, "pattern">;
104
+ export type $ZodCheckGUIDParams = CheckStringFormatParams<schemas.$ZodGUID, "pattern">;
105
+ export function _guid<T extends schemas.$ZodGUID>(
106
+ Class: util.SchemaClass<T>,
107
+ params?: string | $ZodGUIDParams | $ZodCheckGUIDParams
108
+ ): T {
109
+ return new Class({
110
+ type: "string",
111
+ format: "guid",
112
+ check: "string_format",
113
+ abort: false,
114
+ ...util.normalizeParams(params),
115
+ });
116
+ }
117
+
118
+ // UUID
119
+ export type $ZodUUIDParams = StringFormatParams<schemas.$ZodUUID, "pattern">;
120
+ export type $ZodCheckUUIDParams = CheckStringFormatParams<schemas.$ZodUUID, "pattern">;
121
+ export function _uuid<T extends schemas.$ZodUUID>(
122
+ Class: util.SchemaClass<T>,
123
+ params?: string | $ZodUUIDParams | $ZodCheckUUIDParams
124
+ ): T {
125
+ return new Class({
126
+ type: "string",
127
+ format: "uuid",
128
+ check: "string_format",
129
+ abort: false,
130
+ ...util.normalizeParams(params),
131
+ });
132
+ }
133
+
134
+ // UUIDv4
135
+ export type $ZodUUIDv4Params = StringFormatParams<schemas.$ZodUUID, "pattern">;
136
+ export type $ZodCheckUUIDv4Params = CheckStringFormatParams<schemas.$ZodUUID, "pattern">;
137
+ export function _uuidv4<T extends schemas.$ZodUUID>(
138
+ Class: util.SchemaClass<T>,
139
+ params?: string | $ZodUUIDv4Params | $ZodCheckUUIDv4Params
140
+ ): T {
141
+ return new Class({
142
+ type: "string",
143
+ format: "uuid",
144
+ check: "string_format",
145
+ abort: false,
146
+ version: "v4",
147
+ ...util.normalizeParams(params),
148
+ });
149
+ }
150
+
151
+ // UUIDv6
152
+ export type $ZodUUIDv6Params = StringFormatParams<schemas.$ZodUUID, "pattern">;
153
+ export type $ZodCheckUUIDv6Params = CheckStringFormatParams<schemas.$ZodUUID, "pattern">;
154
+ export function _uuidv6<T extends schemas.$ZodUUID>(
155
+ Class: util.SchemaClass<T>,
156
+ params?: string | $ZodUUIDv6Params | $ZodCheckUUIDv6Params
157
+ ): T {
158
+ return new Class({
159
+ type: "string",
160
+ format: "uuid",
161
+ check: "string_format",
162
+ abort: false,
163
+ version: "v6",
164
+ ...util.normalizeParams(params),
165
+ });
166
+ }
167
+
168
+ // UUIDv7
169
+ export type $ZodUUIDv7Params = StringFormatParams<schemas.$ZodUUID, "pattern">;
170
+ export type $ZodCheckUUIDv7Params = CheckStringFormatParams<schemas.$ZodUUID, "pattern">;
171
+ export function _uuidv7<T extends schemas.$ZodUUID>(
172
+ Class: util.SchemaClass<T>,
173
+ params?: string | $ZodUUIDv7Params | $ZodCheckUUIDv7Params
174
+ ): T {
175
+ return new Class({
176
+ type: "string",
177
+ format: "uuid",
178
+ check: "string_format",
179
+ abort: false,
180
+ version: "v7",
181
+ ...util.normalizeParams(params),
182
+ });
183
+ }
184
+
185
+ // URL
186
+ export type $ZodURLParams = StringFormatParams<schemas.$ZodURL>;
187
+ export type $ZodCheckURLParams = CheckStringFormatParams<schemas.$ZodURL>;
188
+ export function _url<T extends schemas.$ZodURL>(
189
+ Class: util.SchemaClass<T>,
190
+ params?: string | $ZodURLParams | $ZodCheckURLParams
191
+ ): T {
192
+ return new Class({
193
+ type: "string",
194
+ format: "url",
195
+ check: "string_format",
196
+ abort: false,
197
+ ...util.normalizeParams(params),
198
+ });
199
+ }
200
+
201
+ // Emoji
202
+ export type $ZodEmojiParams = StringFormatParams<schemas.$ZodEmoji>;
203
+ export type $ZodCheckEmojiParams = CheckStringFormatParams<schemas.$ZodEmoji>;
204
+ export function _emoji<T extends schemas.$ZodEmoji>(
205
+ Class: util.SchemaClass<T>,
206
+ params?: string | $ZodEmojiParams | $ZodCheckEmojiParams
207
+ ): T {
208
+ return new Class({
209
+ type: "string",
210
+ format: "emoji",
211
+ check: "string_format",
212
+ abort: false,
213
+ ...util.normalizeParams(params),
214
+ });
215
+ }
216
+
217
+ // NanoID
218
+ export type $ZodNanoIDParams = StringFormatParams<schemas.$ZodNanoID>;
219
+ export type $ZodCheckNanoIDParams = CheckStringFormatParams<schemas.$ZodNanoID>;
220
+ export function _nanoid<T extends schemas.$ZodNanoID>(
221
+ Class: util.SchemaClass<T>,
222
+ params?: string | $ZodNanoIDParams | $ZodCheckNanoIDParams
223
+ ): T {
224
+ return new Class({
225
+ type: "string",
226
+ format: "nanoid",
227
+ check: "string_format",
228
+ abort: false,
229
+ ...util.normalizeParams(params),
230
+ });
231
+ }
232
+
233
+ // CUID
234
+ export type $ZodCUIDParams = StringFormatParams<schemas.$ZodCUID>;
235
+ export type $ZodCheckCUIDParams = CheckStringFormatParams<schemas.$ZodCUID>;
236
+ export function _cuid<T extends schemas.$ZodCUID>(
237
+ Class: util.SchemaClass<T>,
238
+ params?: string | $ZodCUIDParams | $ZodCheckCUIDParams
239
+ ): T {
240
+ return new Class({
241
+ type: "string",
242
+ format: "cuid",
243
+ check: "string_format",
244
+ abort: false,
245
+ ...util.normalizeParams(params),
246
+ });
247
+ }
248
+
249
+ // CUID2
250
+ export type $ZodCUID2Params = StringFormatParams<schemas.$ZodCUID2>;
251
+ export type $ZodCheckCUID2Params = CheckStringFormatParams<schemas.$ZodCUID2>;
252
+ export function _cuid2<T extends schemas.$ZodCUID2>(
253
+ Class: util.SchemaClass<T>,
254
+ params?: string | $ZodCUID2Params | $ZodCheckCUID2Params
255
+ ): T {
256
+ return new Class({
257
+ type: "string",
258
+ format: "cuid2",
259
+ check: "string_format",
260
+ abort: false,
261
+ ...util.normalizeParams(params),
262
+ });
263
+ }
264
+
265
+ // ULID
266
+ export type $ZodULIDParams = StringFormatParams<schemas.$ZodULID>;
267
+ export type $ZodCheckULIDParams = CheckStringFormatParams<schemas.$ZodULID>;
268
+ export function _ulid<T extends schemas.$ZodULID>(
269
+ Class: util.SchemaClass<T>,
270
+ params?: string | $ZodULIDParams | $ZodCheckULIDParams
271
+ ): T {
272
+ return new Class({
273
+ type: "string",
274
+ format: "ulid",
275
+ check: "string_format",
276
+ abort: false,
277
+ ...util.normalizeParams(params),
278
+ });
279
+ }
280
+
281
+ // XID
282
+ export type $ZodXIDParams = StringFormatParams<schemas.$ZodXID>;
283
+ export type $ZodCheckXIDParams = CheckStringFormatParams<schemas.$ZodXID>;
284
+ export function _xid<T extends schemas.$ZodXID>(
285
+ Class: util.SchemaClass<T>,
286
+ params?: string | $ZodXIDParams | $ZodCheckXIDParams
287
+ ): T {
288
+ return new Class({
289
+ type: "string",
290
+ format: "xid",
291
+ check: "string_format",
292
+ abort: false,
293
+ ...util.normalizeParams(params),
294
+ });
295
+ }
296
+
297
+ // KSUID
298
+ export type $ZodKSUIDParams = StringFormatParams<schemas.$ZodKSUID>;
299
+ export type $ZodCheckKSUIDParams = CheckStringFormatParams<schemas.$ZodKSUID>;
300
+ export function _ksuid<T extends schemas.$ZodKSUID>(
301
+ Class: util.SchemaClass<T>,
302
+ params?: string | $ZodKSUIDParams | $ZodCheckKSUIDParams
303
+ ): T {
304
+ return new Class({
305
+ type: "string",
306
+ format: "ksuid",
307
+ check: "string_format",
308
+ abort: false,
309
+ ...util.normalizeParams(params),
310
+ });
311
+ }
312
+
313
+ // IP
314
+ // export type $ZodIPParams = StringFormatParams<schemas.$ZodIP, "pattern">;
315
+ // export type $ZodCheckIPParams = CheckStringFormatParams<schemas.$ZodIP, "pattern">;
316
+ // export function _ip<T extends schemas.$ZodIP>(
317
+ // Class: util.SchemaClass<T>,
318
+ // params?: string | $ZodIPParams | $ZodCheckIPParams
319
+ // ): T {
320
+ // return new Class({
321
+ // type: "string",
322
+ // format: "ip",
323
+ // check: "string_format",
324
+ // abort: false,
325
+ // ...util.normalizeParams(params),
326
+ // });
327
+ // }
328
+
329
+ // IPv4
330
+ export type $ZodIPv4Params = StringFormatParams<schemas.$ZodIPv4, "pattern">;
331
+ export type $ZodCheckIPv4Params = CheckStringFormatParams<schemas.$ZodIPv4, "pattern">;
332
+ export function _ipv4<T extends schemas.$ZodIPv4>(
333
+ Class: util.SchemaClass<T>,
334
+ params?: string | $ZodIPv4Params | $ZodCheckIPv4Params
335
+ ): T {
336
+ return new Class({
337
+ type: "string",
338
+ format: "ipv4",
339
+ check: "string_format",
340
+ abort: false,
341
+ ...util.normalizeParams(params),
342
+ });
343
+ }
344
+
345
+ // IPv6
346
+ export type $ZodIPv6Params = StringFormatParams<schemas.$ZodIPv6, "pattern">;
347
+ export type $ZodCheckIPv6Params = CheckStringFormatParams<schemas.$ZodIPv6, "pattern">;
348
+ export function _ipv6<T extends schemas.$ZodIPv6>(
349
+ Class: util.SchemaClass<T>,
350
+ params?: string | $ZodIPv6Params | $ZodCheckIPv6Params
351
+ ): T {
352
+ return new Class({
353
+ type: "string",
354
+ format: "ipv6",
355
+ check: "string_format",
356
+ abort: false,
357
+ ...util.normalizeParams(params),
358
+ });
359
+ }
360
+
361
+ // CIDRv4
362
+ export type $ZodCIDRv4Params = StringFormatParams<schemas.$ZodCIDRv4, "pattern">;
363
+ export type $ZodCheckCIDRv4Params = CheckStringFormatParams<schemas.$ZodCIDRv4, "pattern">;
364
+ export function _cidrv4<T extends schemas.$ZodCIDRv4>(
365
+ Class: util.SchemaClass<T>,
366
+ params?: string | $ZodCIDRv4Params | $ZodCheckCIDRv4Params
367
+ ): T {
368
+ return new Class({
369
+ type: "string",
370
+ format: "cidrv4",
371
+ check: "string_format",
372
+ abort: false,
373
+ ...util.normalizeParams(params),
374
+ });
375
+ }
376
+
377
+ // CIDRv6
378
+ export type $ZodCIDRv6Params = StringFormatParams<schemas.$ZodCIDRv6, "pattern">;
379
+ export type $ZodCheckCIDRv6Params = CheckStringFormatParams<schemas.$ZodCIDRv6, "pattern">;
380
+ export function _cidrv6<T extends schemas.$ZodCIDRv6>(
381
+ Class: util.SchemaClass<T>,
382
+ params?: string | $ZodCIDRv6Params | $ZodCheckCIDRv6Params
383
+ ): T {
384
+ return new Class({
385
+ type: "string",
386
+ format: "cidrv6",
387
+ check: "string_format",
388
+ abort: false,
389
+ ...util.normalizeParams(params),
390
+ });
391
+ }
392
+
393
+ // Base64
394
+ export type $ZodBase64Params = StringFormatParams<schemas.$ZodBase64, "pattern">;
395
+ export type $ZodCheckBase64Params = CheckStringFormatParams<schemas.$ZodBase64, "pattern">;
396
+ export function _base64<T extends schemas.$ZodBase64>(
397
+ Class: util.SchemaClass<T>,
398
+ params?: string | $ZodBase64Params | $ZodCheckBase64Params
399
+ ): T {
400
+ return new Class({
401
+ type: "string",
402
+ format: "base64",
403
+ check: "string_format",
404
+ abort: false,
405
+ ...util.normalizeParams(params),
406
+ });
407
+ }
408
+
409
+ // base64url
410
+ export type $ZodBase64URLParams = StringFormatParams<schemas.$ZodBase64URL, "pattern">;
411
+ export type $ZodCheckBase64URLParams = CheckStringFormatParams<schemas.$ZodBase64URL, "pattern">;
412
+ export function _base64url<T extends schemas.$ZodBase64URL>(
413
+ Class: util.SchemaClass<T>,
414
+ params?: string | $ZodBase64URLParams | $ZodCheckBase64URLParams
415
+ ): T {
416
+ return new Class({
417
+ type: "string",
418
+ format: "base64url",
419
+ check: "string_format",
420
+ abort: false,
421
+ ...util.normalizeParams(params),
422
+ });
423
+ }
424
+
425
+ // E164
426
+ export type $ZodE164Params = StringFormatParams<schemas.$ZodE164>;
427
+ export type $ZodCheckE164Params = CheckStringFormatParams<schemas.$ZodE164>;
428
+ export function _e164<T extends schemas.$ZodE164>(
429
+ Class: util.SchemaClass<T>,
430
+ params?: string | $ZodE164Params | $ZodCheckE164Params
431
+ ): T {
432
+ return new Class({
433
+ type: "string",
434
+ format: "e164",
435
+ check: "string_format",
436
+ abort: false,
437
+ ...util.normalizeParams(params),
438
+ });
439
+ }
440
+
441
+ // JWT
442
+ export type $ZodJWTParams = StringFormatParams<schemas.$ZodJWT, "pattern">;
443
+ export type $ZodCheckJWTParams = CheckStringFormatParams<schemas.$ZodJWT, "pattern">;
444
+ export function _jwt<T extends schemas.$ZodJWT>(
445
+ Class: util.SchemaClass<T>,
446
+ params?: string | $ZodJWTParams | $ZodCheckJWTParams
447
+ ): T {
448
+ return new Class({
449
+ type: "string",
450
+ format: "jwt",
451
+ check: "string_format",
452
+ abort: false,
453
+ ...util.normalizeParams(params),
454
+ });
455
+ }
456
+
457
+ export const TimePrecision = {
458
+ Any: null,
459
+ Minute: -1,
460
+ Second: 0,
461
+ Millisecond: 3,
462
+ Microsecond: 6,
463
+ } as const;
464
+ // ISODateTime
465
+ export type $ZodISODateTimeParams = StringFormatParams<schemas.$ZodISODateTime, "pattern">;
466
+ export type $ZodCheckISODateTimeParams = CheckStringFormatParams<schemas.$ZodISODateTime, "pattern">;
467
+ export function _isoDateTime<T extends schemas.$ZodISODateTime>(
468
+ Class: util.SchemaClass<T>,
469
+ params?: string | $ZodISODateTimeParams | $ZodCheckISODateTimeParams
470
+ ): T {
471
+ return new Class({
472
+ type: "string",
473
+ format: "datetime",
474
+ check: "string_format",
475
+ offset: false,
476
+ local: false,
477
+ precision: null,
478
+ ...util.normalizeParams(params),
479
+ });
480
+ }
481
+
482
+ // ISODate
483
+ export type $ZodISODateParams = StringFormatParams<schemas.$ZodISODate, "pattern">;
484
+ export type $ZodCheckISODateParams = CheckStringFormatParams<schemas.$ZodISODate, "pattern">;
485
+ export function _isoDate<T extends schemas.$ZodISODate>(
486
+ Class: util.SchemaClass<T>,
487
+ params?: string | $ZodISODateParams | $ZodCheckISODateParams
488
+ ): T {
489
+ return new Class({
490
+ type: "string",
491
+ format: "date",
492
+ check: "string_format",
493
+ ...util.normalizeParams(params),
494
+ });
495
+ }
496
+
497
+ // ISOTime
498
+ export type $ZodISOTimeParams = StringFormatParams<schemas.$ZodISOTime, "pattern">;
499
+ export type $ZodCheckISOTimeParams = CheckStringFormatParams<schemas.$ZodISOTime, "pattern">;
500
+ export function _isoTime<T extends schemas.$ZodISOTime>(
501
+ Class: util.SchemaClass<T>,
502
+ params?: string | $ZodISOTimeParams | $ZodCheckISOTimeParams
503
+ ): T {
504
+ return new Class({
505
+ type: "string",
506
+ format: "time",
507
+ check: "string_format",
508
+ precision: null,
509
+ ...util.normalizeParams(params),
510
+ });
511
+ }
512
+
513
+ // ISODuration
514
+ export type $ZodISODurationParams = StringFormatParams<schemas.$ZodISODuration>;
515
+ export type $ZodCheckISODurationParams = CheckStringFormatParams<schemas.$ZodISODuration>;
516
+ export function _isoDuration<T extends schemas.$ZodISODuration>(
517
+ Class: util.SchemaClass<T>,
518
+ params?: string | $ZodISODurationParams | $ZodCheckISODurationParams
519
+ ): T {
520
+ return new Class({
521
+ type: "string",
522
+ format: "duration",
523
+ check: "string_format",
524
+ ...util.normalizeParams(params),
525
+ });
526
+ }
527
+
528
+ // Number
529
+ export type $ZodNumberParams = TypeParams<schemas.$ZodNumber<number>, "coerce">;
530
+ export type $ZodNumberFormatParams = CheckTypeParams<schemas.$ZodNumberFormat, "format" | "coerce">;
531
+ export type $ZodCheckNumberFormatParams = CheckParams<checks.$ZodCheckNumberFormat, "format">;
532
+ export function _number<T extends schemas.$ZodNumber>(
533
+ Class: util.SchemaClass<T>,
534
+ params?: string | $ZodNumberParams
535
+ ): T {
536
+ return new Class({
537
+ type: "number",
538
+ checks: [],
539
+ ...util.normalizeParams(params),
540
+ });
541
+ }
542
+
543
+ export function _coercedNumber<T extends schemas.$ZodNumber>(
544
+ Class: util.SchemaClass<T>,
545
+ params?: string | $ZodNumberParams
546
+ ): T {
547
+ return new Class({
548
+ type: "number",
549
+ coerce: true,
550
+ checks: [],
551
+ ...util.normalizeParams(params),
552
+ });
553
+ }
554
+
555
+ export function _int<T extends schemas.$ZodNumberFormat>(
556
+ Class: util.SchemaClass<T>,
557
+ params?: string | $ZodCheckNumberFormatParams
558
+ ): T {
559
+ return new Class({
560
+ type: "number",
561
+ check: "number_format",
562
+ abort: false,
563
+ format: "safeint",
564
+ ...util.normalizeParams(params),
565
+ });
566
+ }
567
+ export function _float32<T extends schemas.$ZodNumberFormat>(
568
+ Class: util.SchemaClass<T>,
569
+ params?: string | $ZodCheckNumberFormatParams
570
+ ): T {
571
+ return new Class({
572
+ type: "number",
573
+ check: "number_format",
574
+ abort: false,
575
+ format: "float32",
576
+ ...util.normalizeParams(params),
577
+ });
578
+ }
579
+ export function _float64<T extends schemas.$ZodNumberFormat>(
580
+ Class: util.SchemaClass<T>,
581
+ params?: string | $ZodCheckNumberFormatParams
582
+ ): T {
583
+ return new Class({
584
+ type: "number",
585
+ check: "number_format",
586
+ abort: false,
587
+ format: "float64",
588
+ ...util.normalizeParams(params),
589
+ });
590
+ }
591
+ export function _int32<T extends schemas.$ZodNumberFormat>(
592
+ Class: util.SchemaClass<T>,
593
+ params?: string | $ZodCheckNumberFormatParams
594
+ ): T {
595
+ return new Class({
596
+ type: "number",
597
+ check: "number_format",
598
+ abort: false,
599
+ format: "int32",
600
+ ...util.normalizeParams(params),
601
+ });
602
+ }
603
+ export function _uint32<T extends schemas.$ZodNumberFormat>(
604
+ Class: util.SchemaClass<T>,
605
+ params?: string | $ZodCheckNumberFormatParams
606
+ ): T {
607
+ return new Class({
608
+ type: "number",
609
+ check: "number_format",
610
+ abort: false,
611
+ format: "uint32",
612
+ ...util.normalizeParams(params),
613
+ });
614
+ }
615
+
616
+ // Boolean
617
+ export type $ZodBooleanParams = TypeParams<schemas.$ZodBoolean<boolean>, "coerce">;
618
+ export function _boolean<T extends schemas.$ZodBoolean>(
619
+ Class: util.SchemaClass<T>,
620
+ params?: string | $ZodBooleanParams
621
+ ): T {
622
+ return new Class({
623
+ type: "boolean",
624
+ ...util.normalizeParams(params),
625
+ });
626
+ }
627
+ export function _coercedBoolean<T extends schemas.$ZodBoolean>(
628
+ Class: util.SchemaClass<T>,
629
+ params?: string | $ZodBooleanParams
630
+ ): T {
631
+ return new Class({
632
+ type: "boolean",
633
+ coerce: true,
634
+ ...util.normalizeParams(params),
635
+ });
636
+ }
637
+
638
+ // BigInt
639
+ export type $ZodBigIntParams = TypeParams<schemas.$ZodBigInt<bigint>>;
640
+ export type $ZodBigIntFormatParams = CheckTypeParams<schemas.$ZodBigIntFormat, "format" | "coerce">;
641
+ export type $ZodCheckBigIntFormatParams = CheckParams<checks.$ZodCheckBigIntFormat, "format">;
642
+ export function _bigint<T extends schemas.$ZodBigInt>(
643
+ Class: util.SchemaClass<T>,
644
+ params?: string | $ZodBigIntParams
645
+ ): T {
646
+ return new Class({
647
+ type: "bigint",
648
+ ...util.normalizeParams(params),
649
+ });
650
+ }
651
+ export function _coercedBigint<T extends schemas.$ZodBigInt>(
652
+ Class: util.SchemaClass<T>,
653
+ params?: string | $ZodBigIntParams
654
+ ): T {
655
+ return new Class({
656
+ type: "bigint",
657
+ coerce: true,
658
+ ...util.normalizeParams(params),
659
+ });
660
+ }
661
+
662
+ export function _int64<T extends schemas.$ZodBigIntFormat>(
663
+ Class: util.SchemaClass<T>,
664
+ params?: string | $ZodBigIntFormatParams
665
+ ): T {
666
+ return new Class({
667
+ type: "bigint",
668
+ check: "bigint_format",
669
+ abort: false,
670
+ format: "int64",
671
+ ...util.normalizeParams(params),
672
+ });
673
+ }
674
+ export function _uint64<T extends schemas.$ZodBigIntFormat>(
675
+ Class: util.SchemaClass<T>,
676
+ params?: string | $ZodBigIntFormatParams
677
+ ): T {
678
+ return new Class({
679
+ type: "bigint",
680
+ check: "bigint_format",
681
+ abort: false,
682
+ format: "uint64",
683
+ ...util.normalizeParams(params),
684
+ });
685
+ }
686
+
687
+ // Symbol
688
+ export type $ZodSymbolParams = TypeParams<schemas.$ZodSymbol>;
689
+ export function _symbol<T extends schemas.$ZodSymbol>(
690
+ Class: util.SchemaClass<T>,
691
+ params?: string | $ZodSymbolParams
692
+ ): T {
693
+ return new Class({
694
+ type: "symbol",
695
+ ...util.normalizeParams(params),
696
+ });
697
+ }
698
+
699
+ // Undefined
700
+ export type $ZodUndefinedParams = TypeParams<schemas.$ZodUndefined>;
701
+ export function _undefined<T extends schemas.$ZodUndefined>(
702
+ Class: util.SchemaClass<T>,
703
+ params?: string | $ZodUndefinedParams
704
+ ): T {
705
+ return new Class({
706
+ type: "undefined",
707
+ ...util.normalizeParams(params),
708
+ });
709
+ }
710
+
711
+ // Null
712
+ export type $ZodNullParams = TypeParams<schemas.$ZodNull>;
713
+ export function _null<T extends schemas.$ZodNull>(Class: util.SchemaClass<T>, params?: string | $ZodNullParams): T {
714
+ return new Class({
715
+ type: "null",
716
+ ...util.normalizeParams(params),
717
+ });
718
+ }
719
+
720
+ // Any
721
+ export type $ZodAnyParams = TypeParams<schemas.$ZodAny>;
722
+ export function _any<T extends schemas.$ZodAny>(Class: util.SchemaClass<T>): T {
723
+ return new Class({
724
+ type: "any",
725
+ });
726
+ }
727
+
728
+ // Unknown
729
+ export type $ZodUnknownParams = TypeParams<schemas.$ZodUnknown>;
730
+ export function _unknown<T extends schemas.$ZodUnknown>(Class: util.SchemaClass<T>): T {
731
+ return new Class({
732
+ type: "unknown",
733
+ });
734
+ }
735
+
736
+ // Never
737
+ export type $ZodNeverParams = TypeParams<schemas.$ZodNever>;
738
+ export function _never<T extends schemas.$ZodNever>(Class: util.SchemaClass<T>, params?: string | $ZodNeverParams): T {
739
+ return new Class({
740
+ type: "never",
741
+ ...util.normalizeParams(params),
742
+ });
743
+ }
744
+
745
+ // Void
746
+ export type $ZodVoidParams = TypeParams<schemas.$ZodVoid>;
747
+ export function _void<T extends schemas.$ZodVoid>(Class: util.SchemaClass<T>, params?: string | $ZodVoidParams): T {
748
+ return new Class({
749
+ type: "void",
750
+ ...util.normalizeParams(params),
751
+ });
752
+ }
753
+
754
+ // Date
755
+ export type $ZodDateParams = TypeParams<schemas.$ZodDate, "coerce">;
756
+ export function _date<T extends schemas.$ZodDate>(Class: util.SchemaClass<T>, params?: string | $ZodDateParams): T {
757
+ return new Class({
758
+ type: "date",
759
+ ...util.normalizeParams(params),
760
+ });
761
+ }
762
+ export function _coercedDate<T extends schemas.$ZodDate>(
763
+ Class: util.SchemaClass<T>,
764
+ params?: string | $ZodDateParams
765
+ ): T {
766
+ return new Class({
767
+ type: "date",
768
+ coerce: true,
769
+ ...util.normalizeParams(params),
770
+ });
771
+ }
772
+
773
+ // NaN
774
+ export type $ZodNaNParams = TypeParams<schemas.$ZodNaN>;
775
+ export function _nan<T extends schemas.$ZodNaN>(Class: util.SchemaClass<T>, params?: string | $ZodNaNParams): T {
776
+ return new Class({
777
+ type: "nan",
778
+ ...util.normalizeParams(params),
779
+ });
780
+ }
781
+
782
+ // export type $ZodCheckParams = CheckParams<checks.$ZodCheck, "abort">;
783
+
784
+ export type $ZodCheckLessThanParams = CheckParams<checks.$ZodCheckLessThan, "inclusive" | "value">;
785
+ export function _lt(
786
+ value: util.Numeric,
787
+ params?: string | $ZodCheckLessThanParams
788
+ ): checks.$ZodCheckLessThan<util.Numeric> {
789
+ return new checks.$ZodCheckLessThan({
790
+ check: "less_than",
791
+ ...util.normalizeParams(params),
792
+ value,
793
+ inclusive: false,
794
+ });
795
+ }
796
+
797
+ export function _lte(
798
+ value: util.Numeric,
799
+ params?: string | $ZodCheckLessThanParams
800
+ ): checks.$ZodCheckLessThan<util.Numeric> {
801
+ return new checks.$ZodCheckLessThan({
802
+ check: "less_than",
803
+
804
+ ...util.normalizeParams(params),
805
+ value,
806
+ inclusive: true,
807
+ });
808
+ }
809
+ export {
810
+ /** @deprecated Use `z.lte()` instead. */
811
+ _lte as _max,
812
+ };
813
+
814
+ // ZodCheckGreaterThan
815
+ export type $ZodCheckGreaterThanParams = CheckParams<checks.$ZodCheckGreaterThan, "inclusive" | "value">;
816
+ export function _gt(value: util.Numeric, params?: string | $ZodCheckGreaterThanParams): checks.$ZodCheckGreaterThan {
817
+ return new checks.$ZodCheckGreaterThan({
818
+ check: "greater_than",
819
+
820
+ ...util.normalizeParams(params),
821
+ value,
822
+ inclusive: false,
823
+ });
824
+ }
825
+
826
+ export function _gte(value: util.Numeric, params?: string | $ZodCheckGreaterThanParams): checks.$ZodCheckGreaterThan {
827
+ return new checks.$ZodCheckGreaterThan({
828
+ check: "greater_than",
829
+ ...util.normalizeParams(params),
830
+ value,
831
+ inclusive: true,
832
+ });
833
+ }
834
+
835
+ export {
836
+ /** @deprecated Use `z.gte()` instead. */
837
+ _gte as _min,
838
+ };
839
+
840
+ export function _positive(params?: string | $ZodCheckGreaterThanParams): checks.$ZodCheckGreaterThan {
841
+ return _gt(0, params);
842
+ }
843
+
844
+ // negative
845
+ export function _negative(params?: string | $ZodCheckLessThanParams): checks.$ZodCheckLessThan {
846
+ return _lt(0, params);
847
+ }
848
+
849
+ // nonpositive
850
+ export function _nonpositive(params?: string | $ZodCheckLessThanParams): checks.$ZodCheckLessThan {
851
+ return _lte(0, params);
852
+ }
853
+
854
+ // nonnegative
855
+ export function _nonnegative(params?: string | $ZodCheckGreaterThanParams): checks.$ZodCheckGreaterThan {
856
+ return _gte(0, params);
857
+ }
858
+
859
+ export type $ZodCheckMultipleOfParams = CheckParams<checks.$ZodCheckMultipleOf, "value">;
860
+ export function _multipleOf(
861
+ value: number | bigint,
862
+ params?: string | $ZodCheckMultipleOfParams
863
+ ): checks.$ZodCheckMultipleOf {
864
+ return new checks.$ZodCheckMultipleOf({
865
+ check: "multiple_of",
866
+ ...util.normalizeParams(params),
867
+ value,
868
+ });
869
+ }
870
+
871
+ export type $ZodCheckMaxSizeParams = CheckParams<checks.$ZodCheckMaxSize, "maximum">;
872
+ export function _maxSize(
873
+ maximum: number,
874
+ params?: string | $ZodCheckMaxSizeParams
875
+ ): checks.$ZodCheckMaxSize<util.HasSize> {
876
+ return new checks.$ZodCheckMaxSize({
877
+ check: "max_size",
878
+ ...util.normalizeParams(params),
879
+ maximum,
880
+ });
881
+ }
882
+
883
+ export type $ZodCheckMinSizeParams = CheckParams<checks.$ZodCheckMinSize, "minimum">;
884
+ export function _minSize(
885
+ minimum: number,
886
+ params?: string | $ZodCheckMinSizeParams
887
+ ): checks.$ZodCheckMinSize<util.HasSize> {
888
+ return new checks.$ZodCheckMinSize({
889
+ check: "min_size",
890
+ ...util.normalizeParams(params),
891
+ minimum,
892
+ });
893
+ }
894
+
895
+ export type $ZodCheckSizeEqualsParams = CheckParams<checks.$ZodCheckSizeEquals, "size">;
896
+ export function _size(
897
+ size: number,
898
+ params?: string | $ZodCheckSizeEqualsParams
899
+ ): checks.$ZodCheckSizeEquals<util.HasSize> {
900
+ return new checks.$ZodCheckSizeEquals({
901
+ check: "size_equals",
902
+ ...util.normalizeParams(params),
903
+ size,
904
+ });
905
+ }
906
+
907
+ export type $ZodCheckMaxLengthParams = CheckParams<checks.$ZodCheckMaxLength, "maximum">;
908
+ export function _maxLength(
909
+ maximum: number,
910
+ params?: string | $ZodCheckMaxLengthParams
911
+ ): checks.$ZodCheckMaxLength<util.HasLength> {
912
+ const ch = new checks.$ZodCheckMaxLength({
913
+ check: "max_length",
914
+ ...util.normalizeParams(params),
915
+ maximum,
916
+ });
917
+ return ch;
918
+ }
919
+
920
+ export type $ZodCheckMinLengthParams = CheckParams<checks.$ZodCheckMinLength, "minimum">;
921
+ export function _minLength(
922
+ minimum: number,
923
+ params?: string | $ZodCheckMinLengthParams
924
+ ): checks.$ZodCheckMinLength<util.HasLength> {
925
+ return new checks.$ZodCheckMinLength({
926
+ check: "min_length",
927
+ ...util.normalizeParams(params),
928
+ minimum,
929
+ });
930
+ }
931
+
932
+ export type $ZodCheckLengthEqualsParams = CheckParams<checks.$ZodCheckLengthEquals, "length">;
933
+ export function _length(
934
+ length: number,
935
+ params?: string | $ZodCheckLengthEqualsParams
936
+ ): checks.$ZodCheckLengthEquals<util.HasLength> {
937
+ return new checks.$ZodCheckLengthEquals({
938
+ check: "length_equals",
939
+ ...util.normalizeParams(params),
940
+ length,
941
+ });
942
+ }
943
+
944
+ export type $ZodCheckRegexParams = CheckParams<checks.$ZodCheckRegex, "format" | "pattern">;
945
+ export function _regex(pattern: RegExp, params?: string | $ZodCheckRegexParams): checks.$ZodCheckRegex {
946
+ return new checks.$ZodCheckRegex({
947
+ check: "string_format",
948
+ format: "regex",
949
+ ...util.normalizeParams(params),
950
+ pattern,
951
+ });
952
+ }
953
+
954
+ export type $ZodCheckLowerCaseParams = CheckParams<checks.$ZodCheckLowerCase, "format">;
955
+ export function _lowercase(params?: string | $ZodCheckLowerCaseParams): checks.$ZodCheckLowerCase {
956
+ return new checks.$ZodCheckLowerCase({
957
+ check: "string_format",
958
+ format: "lowercase",
959
+ ...util.normalizeParams(params),
960
+ });
961
+ }
962
+
963
+ export type $ZodCheckUpperCaseParams = CheckParams<checks.$ZodCheckUpperCase, "format">;
964
+
965
+ export function _uppercase(params?: string | $ZodCheckUpperCaseParams): checks.$ZodCheckUpperCase {
966
+ return new checks.$ZodCheckUpperCase({
967
+ check: "string_format",
968
+ format: "uppercase",
969
+ ...util.normalizeParams(params),
970
+ });
971
+ }
972
+
973
+ export type $ZodCheckIncludesParams = CheckParams<checks.$ZodCheckIncludes, "includes" | "format" | "pattern">;
974
+ export function _includes(includes: string, params?: string | $ZodCheckIncludesParams): checks.$ZodCheckIncludes {
975
+ return new checks.$ZodCheckIncludes({
976
+ check: "string_format",
977
+ format: "includes",
978
+ ...util.normalizeParams(params),
979
+ includes,
980
+ });
981
+ }
982
+ export type $ZodCheckStartsWithParams = CheckParams<checks.$ZodCheckStartsWith, "prefix" | "format" | "pattern">;
983
+ export function _startsWith(prefix: string, params?: string | $ZodCheckStartsWithParams): checks.$ZodCheckStartsWith {
984
+ return new checks.$ZodCheckStartsWith({
985
+ check: "string_format",
986
+ format: "starts_with",
987
+ ...util.normalizeParams(params),
988
+ prefix,
989
+ });
990
+ }
991
+
992
+ export type $ZodCheckEndsWithParams = CheckParams<checks.$ZodCheckEndsWith, "suffix" | "format" | "pattern">;
993
+
994
+ export function _endsWith(suffix: string, params?: string | $ZodCheckEndsWithParams): checks.$ZodCheckEndsWith {
995
+ return new checks.$ZodCheckEndsWith({
996
+ check: "string_format",
997
+ format: "ends_with",
998
+ ...util.normalizeParams(params),
999
+ suffix,
1000
+ });
1001
+ }
1002
+
1003
+ export type $ZodCheckPropertyParams = CheckParams<checks.$ZodCheckProperty, "property" | "schema">;
1004
+ export function _property<K extends string, T extends schemas.$ZodType>(
1005
+ property: K,
1006
+ schema: T,
1007
+ params?: string | $ZodCheckPropertyParams
1008
+ ): checks.$ZodCheckProperty<{ [k in K]: core.output<T> }> {
1009
+ return new checks.$ZodCheckProperty({
1010
+ check: "property",
1011
+ property,
1012
+ schema,
1013
+ ...util.normalizeParams(params),
1014
+ });
1015
+ }
1016
+
1017
+ export type $ZodCheckMimeTypeParams = CheckParams<checks.$ZodCheckMimeType, "mime">;
1018
+ export function _mime(types: util.MimeTypes[], params?: string | $ZodCheckMimeTypeParams): checks.$ZodCheckMimeType {
1019
+ return new checks.$ZodCheckMimeType({
1020
+ check: "mime_type",
1021
+ mime: types,
1022
+ ...util.normalizeParams(params),
1023
+ });
1024
+ }
1025
+
1026
+ export function _overwrite<T>(tx: (input: T) => T): checks.$ZodCheckOverwrite<T> {
1027
+ return new checks.$ZodCheckOverwrite({
1028
+ check: "overwrite",
1029
+ tx,
1030
+ }) as checks.$ZodCheckOverwrite<T>;
1031
+ }
1032
+ // normalize
1033
+ export function _normalize(form?: "NFC" | "NFD" | "NFKC" | "NFKD" | (string & {})): checks.$ZodCheckOverwrite<string> {
1034
+ return _overwrite((input) => input.normalize(form));
1035
+ }
1036
+
1037
+ // trim
1038
+ export function _trim(): checks.$ZodCheckOverwrite<string> {
1039
+ return _overwrite((input) => input.trim());
1040
+ }
1041
+ // toLowerCase
1042
+ export function _toLowerCase(): checks.$ZodCheckOverwrite<string> {
1043
+ return _overwrite((input) => input.toLowerCase());
1044
+ }
1045
+ // toUpperCase
1046
+ export function _toUpperCase(): checks.$ZodCheckOverwrite<string> {
1047
+ return _overwrite((input) => input.toUpperCase());
1048
+ }
1049
+
1050
+ /////// collections ///////
1051
+
1052
+ // Array
1053
+ export type $ZodArrayParams = TypeParams<schemas.$ZodArray, "element">;
1054
+ export function _array<T extends schemas.$ZodType>(
1055
+ Class: util.SchemaClass<schemas.$ZodArray>,
1056
+ element: T,
1057
+ params?: string | $ZodArrayParams
1058
+ ): schemas.$ZodArray<T> {
1059
+ return new Class({
1060
+ type: "array",
1061
+ element,
1062
+ // get element() {
1063
+ // return element;
1064
+ // },
1065
+ ...util.normalizeParams(params),
1066
+ }) as any;
1067
+ }
1068
+
1069
+ export type $ZodObjectParams = TypeParams<schemas.$ZodObject, "shape" | "catchall">;
1070
+
1071
+ // ZodUnion
1072
+ export type $ZodUnionParams = TypeParams<schemas.$ZodUnion, "options">;
1073
+ export function _union<const T extends readonly schemas.$ZodObject[]>(
1074
+ Class: util.SchemaClass<schemas.$ZodUnion>,
1075
+ options: T,
1076
+ params?: string | $ZodUnionParams
1077
+ ): schemas.$ZodUnion<T> {
1078
+ return new Class({
1079
+ type: "union",
1080
+ options,
1081
+ ...util.normalizeParams(params),
1082
+ }) as any;
1083
+ }
1084
+
1085
+ // ZodDiscriminatedUnion
1086
+ export interface $ZodTypeDiscriminableInternals extends schemas.$ZodTypeInternals {
1087
+ propValues: util.PropValues;
1088
+ }
1089
+
1090
+ export interface $ZodTypeDiscriminable extends schemas.$ZodType {
1091
+ _zod: $ZodTypeDiscriminableInternals;
1092
+ }
1093
+ export type $ZodDiscriminatedUnionParams = TypeParams<schemas.$ZodDiscriminatedUnion, "options" | "discriminator">;
1094
+ export function _discriminatedUnion<Types extends [$ZodTypeDiscriminable, ...$ZodTypeDiscriminable[]]>(
1095
+ Class: util.SchemaClass<schemas.$ZodDiscriminatedUnion>,
1096
+ discriminator: string,
1097
+ options: Types,
1098
+ params?: string | $ZodDiscriminatedUnionParams
1099
+ ): schemas.$ZodDiscriminatedUnion<Types> {
1100
+ return new Class({
1101
+ type: "union",
1102
+ options,
1103
+ discriminator,
1104
+ ...util.normalizeParams(params),
1105
+ }) as any;
1106
+ }
1107
+
1108
+ // ZodIntersection
1109
+ export type $ZodIntersectionParams = TypeParams<schemas.$ZodIntersection, "left" | "right">;
1110
+ export function _intersection<T extends schemas.$ZodObject, U extends schemas.$ZodObject>(
1111
+ Class: util.SchemaClass<schemas.$ZodIntersection>,
1112
+ left: T,
1113
+ right: U
1114
+ ): schemas.$ZodIntersection<T, U> {
1115
+ return new Class({
1116
+ type: "intersection",
1117
+ left,
1118
+ right,
1119
+ }) as any;
1120
+ }
1121
+
1122
+ // ZodTuple
1123
+ export type $ZodTupleParams = TypeParams<schemas.$ZodTuple, "items" | "rest">;
1124
+ export function _tuple<T extends readonly [schemas.$ZodType, ...schemas.$ZodType[]]>(
1125
+ Class: util.SchemaClass<schemas.$ZodTuple>,
1126
+ items: T,
1127
+ params?: string | $ZodTupleParams
1128
+ ): schemas.$ZodTuple<T, null>;
1129
+ export function _tuple<T extends readonly [schemas.$ZodType, ...schemas.$ZodType[]], Rest extends schemas.$ZodType>(
1130
+ Class: util.SchemaClass<schemas.$ZodTuple>,
1131
+ items: T,
1132
+ rest: Rest,
1133
+ params?: string | $ZodTupleParams
1134
+ ): schemas.$ZodTuple<T, Rest>;
1135
+ // export function _tuple(
1136
+ // Class: util.SchemaClass<schemas.$ZodTuple>,
1137
+ // items: [],
1138
+ // params?: string | $ZodTupleParams
1139
+ // ): schemas.$ZodTuple<[], null>;
1140
+ export function _tuple(
1141
+ Class: util.SchemaClass<schemas.$ZodTuple>,
1142
+ items: schemas.$ZodType[],
1143
+ _paramsOrRest?: string | $ZodTupleParams | schemas.$ZodType,
1144
+ _params?: string | $ZodTupleParams
1145
+ ) {
1146
+ const hasRest = _paramsOrRest instanceof schemas.$ZodType;
1147
+ const params = hasRest ? _params : _paramsOrRest;
1148
+ const rest = hasRest ? _paramsOrRest : null;
1149
+ return new Class({
1150
+ type: "tuple",
1151
+ items,
1152
+ rest,
1153
+ ...util.normalizeParams(params),
1154
+ });
1155
+ }
1156
+
1157
+ // ZodRecord
1158
+ export type $ZodRecordParams = TypeParams<schemas.$ZodRecord, "keyType" | "valueType">;
1159
+ export function _record<Key extends schemas.$ZodRecordKey, Value extends schemas.$ZodObject>(
1160
+ Class: util.SchemaClass<schemas.$ZodRecord>,
1161
+ keyType: Key,
1162
+ valueType: Value,
1163
+ params?: string | $ZodRecordParams
1164
+ ): schemas.$ZodRecord<Key, Value> {
1165
+ return new Class({
1166
+ type: "record",
1167
+ keyType,
1168
+ valueType,
1169
+ ...util.normalizeParams(params),
1170
+ }) as any;
1171
+ }
1172
+
1173
+ // ZodMap
1174
+ export type $ZodMapParams = TypeParams<schemas.$ZodMap, "keyType" | "valueType">;
1175
+ export function _map<Key extends schemas.$ZodObject, Value extends schemas.$ZodObject>(
1176
+ Class: util.SchemaClass<schemas.$ZodMap>,
1177
+ keyType: Key,
1178
+ valueType: Value,
1179
+ params?: string | $ZodMapParams
1180
+ ): schemas.$ZodMap<Key, Value> {
1181
+ return new Class({
1182
+ type: "map",
1183
+ keyType,
1184
+ valueType,
1185
+ ...util.normalizeParams(params),
1186
+ }) as any;
1187
+ }
1188
+
1189
+ // ZodSet
1190
+ export type $ZodSetParams = TypeParams<schemas.$ZodSet, "valueType">;
1191
+ export function _set<Value extends schemas.$ZodObject>(
1192
+ Class: util.SchemaClass<schemas.$ZodSet>,
1193
+ valueType: Value,
1194
+ params?: string | $ZodSetParams
1195
+ ): schemas.$ZodSet<Value> {
1196
+ return new Class({
1197
+ type: "set",
1198
+ valueType,
1199
+ ...util.normalizeParams(params),
1200
+ }) as any;
1201
+ }
1202
+
1203
+ // ZodEnum
1204
+ export type $ZodEnumParams = TypeParams<schemas.$ZodEnum, "entries">;
1205
+ export function _enum<const T extends string[]>(
1206
+ Class: util.SchemaClass<schemas.$ZodEnum>,
1207
+ values: T,
1208
+ params?: string | $ZodEnumParams
1209
+ ): schemas.$ZodEnum<util.ToEnum<T[number]>>;
1210
+ export function _enum<T extends util.EnumLike>(
1211
+ Class: util.SchemaClass<schemas.$ZodEnum>,
1212
+ entries: T,
1213
+ params?: string | $ZodEnumParams
1214
+ ): schemas.$ZodEnum<T>;
1215
+ export function _enum(Class: util.SchemaClass<schemas.$ZodEnum>, values: any, params?: string | $ZodEnumParams) {
1216
+ const entries: any = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
1217
+ // if (Array.isArray(values)) {
1218
+ // for (const value of values) {
1219
+ // entries[value] = value;
1220
+ // }
1221
+ // } else {
1222
+ // Object.assign(entries, values);
1223
+ // }
1224
+ // const entries: util.EnumLike = {};
1225
+ // for (const val of values) {
1226
+ // entries[val] = val;
1227
+ // }
1228
+
1229
+ return new Class({
1230
+ type: "enum",
1231
+ entries,
1232
+ ...util.normalizeParams(params),
1233
+ }) as any;
1234
+ }
1235
+
1236
+ /** @deprecated This API has been merged into `z.enum()`. Use `z.enum()` instead.
1237
+ *
1238
+ * ```ts
1239
+ * enum Colors { red, green, blue }
1240
+ * z.enum(Colors);
1241
+ * ```
1242
+ */
1243
+ export function _nativeEnum<T extends util.EnumLike>(
1244
+ Class: util.SchemaClass<schemas.$ZodEnum>,
1245
+ entries: T,
1246
+ params?: string | $ZodEnumParams
1247
+ ): schemas.$ZodEnum<T> {
1248
+ return new Class({
1249
+ type: "enum",
1250
+ entries,
1251
+ ...util.normalizeParams(params),
1252
+ }) as any;
1253
+ }
1254
+
1255
+ // ZodLiteral
1256
+ export type $ZodLiteralParams = TypeParams<schemas.$ZodLiteral, "values">;
1257
+ export function _literal<const T extends Array<util.Literal>>(
1258
+ Class: util.SchemaClass<schemas.$ZodLiteral>,
1259
+ value: T,
1260
+ params?: string | $ZodLiteralParams
1261
+ ): schemas.$ZodLiteral<T[number]>;
1262
+ export function _literal<const T extends util.Literal>(
1263
+ Class: util.SchemaClass<schemas.$ZodLiteral>,
1264
+ value: T,
1265
+ params?: string | $ZodLiteralParams
1266
+ ): schemas.$ZodLiteral<T>;
1267
+ export function _literal(Class: util.SchemaClass<schemas.$ZodLiteral>, value: any, params: any) {
1268
+ return new Class({
1269
+ type: "literal",
1270
+ values: Array.isArray(value) ? value : [value],
1271
+ ...util.normalizeParams(params),
1272
+ });
1273
+ }
1274
+
1275
+ // ZodFile
1276
+ export type $ZodFileParams = TypeParams<schemas.$ZodFile>;
1277
+ export function _file(Class: util.SchemaClass<schemas.$ZodFile>, params?: string | $ZodFileParams): schemas.$ZodFile {
1278
+ return new Class({
1279
+ type: "file",
1280
+ ...util.normalizeParams(params),
1281
+ });
1282
+ }
1283
+
1284
+ // ZodTransform
1285
+ export type $ZodTransformParams = TypeParams<schemas.$ZodTransform, "transform">;
1286
+ export function _transform<I = unknown, O = I>(
1287
+ Class: util.SchemaClass<schemas.$ZodTransform>,
1288
+ fn: (input: I, ctx?: schemas.ParsePayload) => O
1289
+ ): schemas.$ZodTransform<Awaited<O>, I> {
1290
+ return new Class({
1291
+ type: "transform",
1292
+ transform: fn as any,
1293
+ }) as any;
1294
+ }
1295
+
1296
+ // ZodOptional
1297
+ export type $ZodOptionalParams = TypeParams<schemas.$ZodOptional, "innerType">;
1298
+ export function _optional<T extends schemas.$ZodObject>(
1299
+ Class: util.SchemaClass<schemas.$ZodOptional>,
1300
+ innerType: T
1301
+ ): schemas.$ZodOptional<T> {
1302
+ return new Class({
1303
+ type: "optional",
1304
+ innerType,
1305
+ }) as any;
1306
+ }
1307
+
1308
+ // ZodNullable
1309
+ export type $ZodNullableParams = TypeParams<schemas.$ZodNullable, "innerType">;
1310
+ export function _nullable<T extends schemas.$ZodObject>(
1311
+ Class: util.SchemaClass<schemas.$ZodNullable>,
1312
+ innerType: T
1313
+ ): schemas.$ZodNullable<T> {
1314
+ return new Class({
1315
+ type: "nullable",
1316
+ innerType,
1317
+ }) as any;
1318
+ }
1319
+
1320
+ // ZodDefault
1321
+ export type $ZodDefaultParams = TypeParams<schemas.$ZodDefault, "innerType" | "defaultValue">;
1322
+ export function _default<T extends schemas.$ZodObject>(
1323
+ Class: util.SchemaClass<schemas.$ZodDefault>,
1324
+ innerType: T,
1325
+ defaultValue: util.NoUndefined<core.output<T>> | (() => util.NoUndefined<core.output<T>>)
1326
+ ): schemas.$ZodDefault<T> {
1327
+ return new Class({
1328
+ type: "default",
1329
+ innerType,
1330
+ get defaultValue() {
1331
+ return typeof defaultValue === "function" ? (defaultValue as Function)() : defaultValue;
1332
+ },
1333
+ }) as any;
1334
+ }
1335
+
1336
+ // ZodNonOptional
1337
+ export type $ZodNonOptionalParams = TypeParams<schemas.$ZodNonOptional, "innerType">;
1338
+ export function _nonoptional<T extends schemas.$ZodObject>(
1339
+ Class: util.SchemaClass<schemas.$ZodNonOptional>,
1340
+ innerType: T,
1341
+ params?: string | $ZodNonOptionalParams
1342
+ ): schemas.$ZodNonOptional<T> {
1343
+ return new Class({
1344
+ type: "nonoptional",
1345
+ innerType,
1346
+ ...util.normalizeParams(params),
1347
+ }) as any;
1348
+ }
1349
+
1350
+ // ZodSuccess
1351
+ export type $ZodSuccessParams = TypeParams<schemas.$ZodSuccess, "innerType">;
1352
+ export function _success<T extends schemas.$ZodObject>(
1353
+ Class: util.SchemaClass<schemas.$ZodSuccess>,
1354
+ innerType: T
1355
+ ): schemas.$ZodSuccess<T> {
1356
+ return new Class({
1357
+ type: "success",
1358
+ innerType,
1359
+ }) as any;
1360
+ }
1361
+
1362
+ // ZodCatch
1363
+ export type $ZodCatchParams = TypeParams<schemas.$ZodCatch, "innerType" | "catchValue">;
1364
+ export function _catch<T extends schemas.$ZodObject>(
1365
+ Class: util.SchemaClass<schemas.$ZodCatch>,
1366
+ innerType: T,
1367
+ catchValue: core.output<T> | ((ctx: schemas.$ZodCatchCtx) => core.output<T>)
1368
+ ): schemas.$ZodCatch<T> {
1369
+ return new Class({
1370
+ type: "catch",
1371
+ innerType,
1372
+ catchValue: (typeof catchValue === "function" ? catchValue : () => catchValue) as any,
1373
+ }) as any;
1374
+ }
1375
+
1376
+ // ZodPipe
1377
+ export type $ZodPipeParams = TypeParams<schemas.$ZodPipe, "in" | "out">;
1378
+ export function _pipe<
1379
+ const A extends schemas.$ZodType,
1380
+ B extends schemas.$ZodType<unknown, core.output<A>> = schemas.$ZodType<unknown, core.output<A>>,
1381
+ >(
1382
+ Class: util.SchemaClass<schemas.$ZodPipe>,
1383
+ in_: A,
1384
+ out: B | schemas.$ZodType<unknown, core.output<A>>
1385
+ ): schemas.$ZodPipe<A, B> {
1386
+ return new Class({
1387
+ type: "pipe",
1388
+ in: in_,
1389
+ out,
1390
+ }) as any;
1391
+ }
1392
+
1393
+ // ZodReadonly
1394
+ export type $ZodReadonlyParams = TypeParams<schemas.$ZodReadonly, "innerType">;
1395
+ export function _readonly<T extends schemas.$ZodObject>(
1396
+ Class: util.SchemaClass<schemas.$ZodReadonly>,
1397
+ innerType: T
1398
+ ): schemas.$ZodReadonly<T> {
1399
+ return new Class({
1400
+ type: "readonly",
1401
+ innerType,
1402
+ }) as any;
1403
+ }
1404
+
1405
+ // ZodTemplateLiteral
1406
+ export type $ZodTemplateLiteralParams = TypeParams<schemas.$ZodTemplateLiteral, "parts">;
1407
+ export function _templateLiteral<const Parts extends schemas.$ZodTemplateLiteralPart[]>(
1408
+ Class: util.SchemaClass<schemas.$ZodTemplateLiteral>,
1409
+ parts: Parts,
1410
+ params?: string | $ZodTemplateLiteralParams
1411
+ ): schemas.$ZodTemplateLiteral<schemas.$PartsToTemplateLiteral<Parts>> {
1412
+ return new Class({
1413
+ type: "template_literal",
1414
+ parts,
1415
+ ...util.normalizeParams(params),
1416
+ }) as any;
1417
+ }
1418
+
1419
+ // ZodLazy
1420
+ export type $ZodLazyParams = TypeParams<schemas.$ZodLazy, "getter">;
1421
+ export function _lazy<T extends schemas.$ZodType>(
1422
+ Class: util.SchemaClass<schemas.$ZodLazy>,
1423
+ getter: () => T
1424
+ ): schemas.$ZodLazy<T> {
1425
+ return new Class({
1426
+ type: "lazy",
1427
+ getter,
1428
+ }) as any;
1429
+ }
1430
+
1431
+ // ZodPromise
1432
+ export type $ZodPromiseParams = TypeParams<schemas.$ZodPromise, "innerType">;
1433
+ export function _promise<T extends schemas.$ZodObject>(
1434
+ Class: util.SchemaClass<schemas.$ZodPromise>,
1435
+ innerType: T
1436
+ ): schemas.$ZodPromise<T> {
1437
+ return new Class({
1438
+ type: "promise",
1439
+ innerType,
1440
+ }) as any;
1441
+ }
1442
+
1443
+ // ZodCustom
1444
+ export type $ZodCustomParams = CheckTypeParams<schemas.$ZodCustom, "fn">;
1445
+ export function _custom<O = unknown, I = O>(
1446
+ Class: util.SchemaClass<schemas.$ZodCustom>,
1447
+ fn: (data: O) => unknown,
1448
+ _params: string | $ZodCustomParams | undefined
1449
+ ): schemas.$ZodCustom<O, I> {
1450
+ const norm = util.normalizeParams(_params);
1451
+ norm.abort ??= true; // default to abort:false
1452
+ const schema = new Class({
1453
+ type: "custom",
1454
+ check: "custom",
1455
+ fn: fn as any,
1456
+ ...norm,
1457
+ });
1458
+
1459
+ return schema as any;
1460
+ }
1461
+
1462
+ // export function _refine<T>(
1463
+ // Class: util.SchemaClass<schemas.$ZodCustom>,
1464
+ // fn: (arg: NoInfer<T>) => util.MaybeAsync<unknown>,
1465
+ // _params: string | $ZodCustomParams = {}
1466
+ // ): checks.$ZodCheck<T> {
1467
+ // return _custom(Class, fn, _params);
1468
+ // }
1469
+ // same as _custom but defaults to abort:false
1470
+ export function _refine<O = unknown, I = O>(
1471
+ Class: util.SchemaClass<schemas.$ZodCustom>,
1472
+ fn: (data: O) => unknown,
1473
+ _params: string | $ZodCustomParams | undefined
1474
+ ): schemas.$ZodCustom<O, I> {
1475
+ const schema = new Class({
1476
+ type: "custom",
1477
+ check: "custom",
1478
+ fn: fn as any,
1479
+ ...util.normalizeParams(_params),
1480
+ });
1481
+
1482
+ return schema as any;
1483
+ }
1484
+
1485
+ // export type $ZodCustomParams = CheckTypeParams<schemas.$ZodCustom, "fn">
1486
+
1487
+ ///////// STRINGBOOL /////////
1488
+
1489
+ // stringbool
1490
+ export interface $ZodStringBoolParams extends TypeParams {
1491
+ truthy?: string[];
1492
+ falsy?: string[];
1493
+ /**
1494
+ * Options: `"sensitive"`, `"insensitive"`
1495
+ *
1496
+ * @default `"insensitive"`
1497
+ */
1498
+ case?: "sensitive" | "insensitive" | undefined;
1499
+ }
1500
+
1501
+ export function _stringbool(
1502
+ Classes: {
1503
+ Pipe?: typeof schemas.$ZodPipe;
1504
+ Boolean?: typeof schemas.$ZodBoolean;
1505
+ Transform?: typeof schemas.$ZodTransform;
1506
+ String?: typeof schemas.$ZodString;
1507
+ },
1508
+ _params?: string | $ZodStringBoolParams
1509
+ ): schemas.$ZodPipe<
1510
+ schemas.$ZodPipe<schemas.$ZodString, schemas.$ZodTransform<boolean, string>>,
1511
+ schemas.$ZodBoolean<boolean>
1512
+ > {
1513
+ const params = util.normalizeParams(_params);
1514
+
1515
+ let truthyArray = params.truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
1516
+ let falsyArray = params.falsy ?? ["false", "0", "no", "off", "n", "disabled"];
1517
+ if (params.case !== "sensitive") {
1518
+ truthyArray = truthyArray.map((v) => (typeof v === "string" ? v.toLowerCase() : v));
1519
+ falsyArray = falsyArray.map((v) => (typeof v === "string" ? v.toLowerCase() : v));
1520
+ }
1521
+
1522
+ const truthySet = new Set(truthyArray);
1523
+ const falsySet = new Set(falsyArray);
1524
+
1525
+ const _Pipe = Classes.Pipe ?? schemas.$ZodPipe;
1526
+ const _Boolean = Classes.Boolean ?? schemas.$ZodBoolean;
1527
+ const _String = Classes.String ?? schemas.$ZodString;
1528
+ const _Transform = Classes.Transform ?? schemas.$ZodTransform;
1529
+
1530
+ const tx = new _Transform({
1531
+ type: "transform",
1532
+ transform: (input, payload: schemas.ParsePayload<unknown>) => {
1533
+ let data: string = input as string;
1534
+ if (params.case !== "sensitive") data = data.toLowerCase();
1535
+ if (truthySet.has(data)) {
1536
+ return true;
1537
+ } else if (falsySet.has(data)) {
1538
+ return false;
1539
+ } else {
1540
+ payload.issues.push({
1541
+ code: "invalid_value",
1542
+ expected: "stringbool",
1543
+ values: [...truthySet, ...falsySet],
1544
+ input: payload.value,
1545
+ inst: tx,
1546
+ });
1547
+ return {} as never;
1548
+ }
1549
+ },
1550
+ error: params.error,
1551
+ });
1552
+ // params.error;
1553
+
1554
+ const innerPipe = new _Pipe({
1555
+ type: "pipe",
1556
+ in: new _String({ type: "string", error: params.error }),
1557
+ out: tx,
1558
+ error: params.error,
1559
+ });
1560
+
1561
+ const outerPipe = new _Pipe({
1562
+ type: "pipe",
1563
+ in: innerPipe,
1564
+ out: new _Boolean({
1565
+ type: "boolean",
1566
+ error: params.error,
1567
+ }),
1568
+ error: params.error,
1569
+ });
1570
+ return outerPipe as any;
1571
+ }
1572
+
1573
+ export function _stringFormat<Format extends string>(
1574
+ Class: typeof schemas.$ZodCustomStringFormat,
1575
+ format: Format,
1576
+ fnOrRegex: ((arg: string) => util.MaybeAsync<unknown>) | RegExp,
1577
+ _params: string | $ZodStringFormatParams = {}
1578
+ ): schemas.$ZodCustomStringFormat<Format> {
1579
+ const params = util.normalizeParams(_params);
1580
+ const def: schemas.$ZodCustomStringFormatDef = {
1581
+ ...util.normalizeParams(_params),
1582
+ check: "string_format",
1583
+ type: "string",
1584
+ format,
1585
+ fn: typeof fnOrRegex === "function" ? fnOrRegex : (val) => fnOrRegex.test(val),
1586
+ ...params,
1587
+ };
1588
+ if (fnOrRegex instanceof RegExp) {
1589
+ def.pattern = fnOrRegex;
1590
+ }
1591
+
1592
+ const inst = new Class(def);
1593
+ return inst as any;
1594
+ }
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/checks.ts ADDED
@@ -0,0 +1,1283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // import { $ZodType } from "./schemas.js";
2
+
3
+ import * as core from "./core.js";
4
+ import type * as errors from "./errors.js";
5
+ import * as regexes from "./regexes.js";
6
+ import type * as schemas from "./schemas.js";
7
+ import * as util from "./util.js";
8
+
9
+ ////////////////////////////// CHECKS ///////////////////////////////////////
10
+
11
+ export interface $ZodCheckDef {
12
+ check: string;
13
+ error?: errors.$ZodErrorMap<never> | undefined;
14
+ /** If true, no later checks will be executed if this check fails. Default `false`. */
15
+ abort?: boolean | undefined;
16
+ /** If provided, this check will only be executed if the function returns `true`. Defaults to `payload => z.util.isAborted(payload)`. */
17
+ when?: ((payload: schemas.ParsePayload) => boolean) | undefined;
18
+ }
19
+
20
+ export interface $ZodCheckInternals<T> {
21
+ def: $ZodCheckDef;
22
+ /** The set of issues this check might throw. */
23
+ issc?: errors.$ZodIssueBase;
24
+ check(payload: schemas.ParsePayload<T>): util.MaybeAsync<void>;
25
+ onattach: ((schema: schemas.$ZodType) => void)[];
26
+ }
27
+
28
+ export interface $ZodCheck<in T = never> {
29
+ _zod: $ZodCheckInternals<T>;
30
+ }
31
+
32
+ export const $ZodCheck: core.$constructor<$ZodCheck<any>> = /*@__PURE__*/ core.$constructor(
33
+ "$ZodCheck",
34
+ (inst, def) => {
35
+ inst._zod ??= {} as any;
36
+ inst._zod.def = def;
37
+ inst._zod.onattach ??= [];
38
+ }
39
+ );
40
+
41
+ ///////////////////////////////////////
42
+ ///// $ZodCheckLessThan /////
43
+ ///////////////////////////////////////
44
+ export interface $ZodCheckLessThanDef extends $ZodCheckDef {
45
+ check: "less_than";
46
+ value: util.Numeric;
47
+ inclusive: boolean;
48
+ }
49
+
50
+ export interface $ZodCheckLessThanInternals<T extends util.Numeric = util.Numeric> extends $ZodCheckInternals<T> {
51
+ def: $ZodCheckLessThanDef;
52
+ issc: errors.$ZodIssueTooBig<T>;
53
+ }
54
+
55
+ const numericOriginMap = {
56
+ number: "number",
57
+ bigint: "bigint",
58
+ object: "date",
59
+ } as const;
60
+ export interface $ZodCheckLessThan<T extends util.Numeric = util.Numeric> extends $ZodCheck<T> {
61
+ _zod: $ZodCheckLessThanInternals<T>;
62
+ }
63
+
64
+ export const $ZodCheckLessThan: core.$constructor<$ZodCheckLessThan> = /*@__PURE__*/ core.$constructor(
65
+ "$ZodCheckLessThan",
66
+ (inst, def) => {
67
+ $ZodCheck.init(inst, def);
68
+ const origin = numericOriginMap[typeof def.value as "number" | "bigint" | "object"];
69
+
70
+ inst._zod.onattach.push((inst) => {
71
+ const bag = inst._zod.bag;
72
+ const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
73
+ if (def.value < curr) {
74
+ if (def.inclusive) bag.maximum = def.value;
75
+ else bag.exclusiveMaximum = def.value;
76
+ }
77
+ });
78
+
79
+ inst._zod.check = (payload) => {
80
+ if (def.inclusive ? payload.value <= def.value : payload.value < def.value) {
81
+ return;
82
+ }
83
+
84
+ payload.issues.push({
85
+ origin,
86
+ code: "too_big",
87
+ maximum: def.value as number,
88
+ input: payload.value,
89
+ inclusive: def.inclusive,
90
+ inst,
91
+ continue: !def.abort,
92
+ });
93
+ };
94
+ }
95
+ );
96
+
97
+ /////////////////////////////////////
98
+ ///// $ZodCheckGreaterThan /////
99
+ /////////////////////////////////////
100
+ export interface $ZodCheckGreaterThanDef extends $ZodCheckDef {
101
+ check: "greater_than";
102
+ value: util.Numeric;
103
+ inclusive: boolean;
104
+ }
105
+
106
+ export interface $ZodCheckGreaterThanInternals<T extends util.Numeric = util.Numeric> extends $ZodCheckInternals<T> {
107
+ def: $ZodCheckGreaterThanDef;
108
+ issc: errors.$ZodIssueTooSmall<T>;
109
+ }
110
+
111
+ export interface $ZodCheckGreaterThan<T extends util.Numeric = util.Numeric> extends $ZodCheck<T> {
112
+ _zod: $ZodCheckGreaterThanInternals<T>;
113
+ }
114
+
115
+ export const $ZodCheckGreaterThan: core.$constructor<$ZodCheckGreaterThan> = /*@__PURE__*/ core.$constructor(
116
+ "$ZodCheckGreaterThan",
117
+ (inst, def) => {
118
+ $ZodCheck.init(inst, def);
119
+ const origin = numericOriginMap[typeof def.value as "number" | "bigint" | "object"];
120
+
121
+ inst._zod.onattach.push((inst) => {
122
+ const bag = inst._zod.bag;
123
+ const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
124
+ if (def.value > curr) {
125
+ if (def.inclusive) bag.minimum = def.value;
126
+ else bag.exclusiveMinimum = def.value;
127
+ }
128
+ });
129
+
130
+ inst._zod.check = (payload) => {
131
+ if (def.inclusive ? payload.value >= def.value : payload.value > def.value) {
132
+ return;
133
+ }
134
+
135
+ payload.issues.push({
136
+ origin,
137
+ code: "too_small",
138
+ minimum: def.value as number,
139
+ input: payload.value,
140
+ inclusive: def.inclusive,
141
+ inst,
142
+ continue: !def.abort,
143
+ });
144
+ };
145
+ }
146
+ );
147
+
148
+ /////////////////////////////////////
149
+ ///// $ZodCheckMultipleOf /////
150
+ /////////////////////////////////////
151
+ // https://stackoverflow.com/questions/3966484/why-does-modulus-operator-return-fractional-number-in-javascript/31711034#31711034
152
+
153
+ export interface $ZodCheckMultipleOfDef<T extends number | bigint = number | bigint> extends $ZodCheckDef {
154
+ check: "multiple_of";
155
+ value: T;
156
+ }
157
+
158
+ export interface $ZodCheckMultipleOfInternals<T extends number | bigint = number | bigint>
159
+ extends $ZodCheckInternals<T> {
160
+ def: $ZodCheckMultipleOfDef<T>;
161
+ issc: errors.$ZodIssueNotMultipleOf;
162
+ }
163
+
164
+ export interface $ZodCheckMultipleOf<T extends number | bigint = number | bigint> extends $ZodCheck<T> {
165
+ _zod: $ZodCheckMultipleOfInternals<T>;
166
+ }
167
+
168
+ export const $ZodCheckMultipleOf: core.$constructor<$ZodCheckMultipleOf<number | bigint>> =
169
+ /*@__PURE__*/ core.$constructor("$ZodCheckMultipleOf", (inst, def) => {
170
+ $ZodCheck.init(inst, def);
171
+
172
+ inst._zod.onattach.push((inst) => {
173
+ inst._zod.bag.multipleOf ??= def.value;
174
+ });
175
+
176
+ inst._zod.check = (payload) => {
177
+ if (typeof payload.value !== typeof def.value)
178
+ throw new Error("Cannot mix number and bigint in multiple_of check.");
179
+ const isMultiple =
180
+ typeof payload.value === "bigint"
181
+ ? payload.value % (def.value as bigint) === BigInt(0)
182
+ : util.floatSafeRemainder(payload.value, def.value as number) === 0;
183
+
184
+ if (isMultiple) return;
185
+ payload.issues.push({
186
+ origin: typeof payload.value as "number",
187
+ code: "not_multiple_of",
188
+ divisor: def.value as number,
189
+ input: payload.value,
190
+ inst,
191
+ continue: !def.abort,
192
+ });
193
+ };
194
+ });
195
+
196
+ /////////////////////////////////////
197
+ ///// $ZodCheckFinite /////
198
+ /////////////////////////////////////
199
+ // interface $ZodCheckFiniteDef extends $ZodCheckDef {
200
+ // check: "finite";
201
+ // }
202
+
203
+ // export interface $ZodCheckFinite extends $ZodCheckInternals<number> {
204
+ // _def: $ZodCheckFiniteDef;
205
+ // _issc:
206
+ // | errors.$ZodIssueTooBig<"number", number>
207
+ // | errors.$ZodIssueTooSmall<"number", number>;
208
+ // }
209
+
210
+ // export const $ZodCheckFinite: core.$constructor<$ZodCheckFinite> =
211
+ // core.$constructor("$ZodCheckFinite", (inst, def) => {
212
+ // $ZodCheck.init(inst, def);
213
+
214
+ // inst._zod.onattach = (inst) => {
215
+ // inst["_bag"].finite = true;
216
+ // };
217
+
218
+ // inst._zod.check = (payload) => {
219
+ // if (Number.isFinite(payload.value)) return;
220
+ // payload.issues.push({
221
+ // origin: "number",
222
+ // ...(payload.value === Number.POSITIVE_INFINITY
223
+ // ? {
224
+ // code: "too_big",
225
+ // maximum: Number.POSITIVE_INFINITY,
226
+ // }
227
+ // : {
228
+ // code: "too_small",
229
+ // minimum: Number.NEGATIVE_INFINITY,
230
+ // }),
231
+ // // code: payload.value === Number.POSITIVE_INFINITY ? "too_big" : "too_big",
232
+ // // maximum: Number.POSITIVE_INFINITY,
233
+ // inclusive: false,
234
+ // input: payload.value,
235
+ // inst,
236
+ // });
237
+ // };
238
+ // });
239
+
240
+ ///////////////////////////////////////
241
+ ///// $ZodCheckNumberFormat /////
242
+ ///////////////////////////////////////
243
+
244
+ export type $ZodNumberFormats = "int32" | "uint32" | "float32" | "float64" | "safeint";
245
+
246
+ export interface $ZodCheckNumberFormatDef extends $ZodCheckDef {
247
+ check: "number_format";
248
+ format: $ZodNumberFormats;
249
+ // abort?: boolean;
250
+ }
251
+
252
+ export interface $ZodCheckNumberFormatInternals extends $ZodCheckInternals<number> {
253
+ def: $ZodCheckNumberFormatDef;
254
+ issc: errors.$ZodIssueInvalidType | errors.$ZodIssueTooBig<"number"> | errors.$ZodIssueTooSmall<"number">;
255
+ // bag: util.LoosePartial<{
256
+ // minimum?: number | undefined;
257
+ // }>;
258
+ }
259
+
260
+ export interface $ZodCheckNumberFormat extends $ZodCheck<number> {
261
+ _zod: $ZodCheckNumberFormatInternals;
262
+ }
263
+
264
+ export const $ZodCheckNumberFormat: core.$constructor<$ZodCheckNumberFormat> = /*@__PURE__*/ core.$constructor(
265
+ "$ZodCheckNumberFormat",
266
+ (inst, def) => {
267
+ $ZodCheck.init(inst, def); // no format checks
268
+ def.format = def.format || "float64";
269
+
270
+ const isInt = def.format?.includes("int");
271
+ const origin = isInt ? "int" : "number";
272
+ const [minimum, maximum] = util.NUMBER_FORMAT_RANGES[def.format];
273
+
274
+ inst._zod.onattach.push((inst) => {
275
+ const bag = inst._zod.bag;
276
+ bag.format = def.format;
277
+ bag.minimum = minimum;
278
+ bag.maximum = maximum;
279
+ if (isInt) bag.pattern = regexes.integer;
280
+ });
281
+
282
+ inst._zod.check = (payload) => {
283
+ const input = payload.value;
284
+
285
+ if (isInt) {
286
+ if (!Number.isInteger(input)) {
287
+ // invalid_format issue
288
+ // payload.issues.push({
289
+ // expected: def.format,
290
+ // format: def.format,
291
+ // code: "invalid_format",
292
+ // input,
293
+ // inst,
294
+ // });
295
+ // invalid_type issue
296
+ payload.issues.push({
297
+ expected: origin,
298
+ format: def.format,
299
+ code: "invalid_type",
300
+ input,
301
+ inst,
302
+ });
303
+
304
+ return;
305
+
306
+ // not_multiple_of issue
307
+ // payload.issues.push({
308
+ // code: "not_multiple_of",
309
+ // origin: "number",
310
+ // input,
311
+ // inst,
312
+ // divisor: 1,
313
+ // });
314
+ }
315
+ if (!Number.isSafeInteger(input)) {
316
+ if (input > 0) {
317
+ // too_big
318
+ payload.issues.push({
319
+ input,
320
+ code: "too_big",
321
+ maximum: Number.MAX_SAFE_INTEGER,
322
+ note: "Integers must be within the safe integer range.",
323
+ inst,
324
+ origin,
325
+ continue: !def.abort,
326
+ });
327
+ } else {
328
+ // too_small
329
+ payload.issues.push({
330
+ input,
331
+ code: "too_small",
332
+ minimum: Number.MIN_SAFE_INTEGER,
333
+ note: "Integers must be within the safe integer range.",
334
+ inst,
335
+ origin,
336
+ continue: !def.abort,
337
+ });
338
+ }
339
+
340
+ return;
341
+ }
342
+ }
343
+
344
+ if (input < minimum) {
345
+ payload.issues.push({
346
+ origin: "number",
347
+ input,
348
+ code: "too_small",
349
+ minimum,
350
+ inclusive: true,
351
+ inst,
352
+ continue: !def.abort,
353
+ });
354
+ }
355
+
356
+ if (input > maximum) {
357
+ payload.issues.push({
358
+ origin: "number",
359
+ input,
360
+ code: "too_big",
361
+ maximum,
362
+ inst,
363
+ } as any);
364
+ }
365
+ };
366
+ }
367
+ );
368
+
369
+ /////////////////////////////////////
370
+ ///// $ZodCheckBigIntFormat /////
371
+ /////////////////////////////////////
372
+
373
+ export type $ZodBigIntFormats = "int64" | "uint64";
374
+
375
+ export interface $ZodCheckBigIntFormatDef extends $ZodCheckDef {
376
+ check: "bigint_format";
377
+ format: $ZodBigIntFormats | undefined;
378
+ }
379
+
380
+ export interface $ZodCheckBigIntFormatInternals extends $ZodCheckInternals<bigint> {
381
+ def: $ZodCheckBigIntFormatDef;
382
+ issc: errors.$ZodIssueTooBig<"bigint"> | errors.$ZodIssueTooSmall<"bigint">;
383
+ }
384
+
385
+ export interface $ZodCheckBigIntFormat extends $ZodCheck<bigint> {
386
+ _zod: $ZodCheckBigIntFormatInternals;
387
+ }
388
+
389
+ export const $ZodCheckBigIntFormat: core.$constructor<$ZodCheckBigIntFormat> = /*@__PURE__*/ core.$constructor(
390
+ "$ZodCheckBigIntFormat",
391
+ (inst, def) => {
392
+ $ZodCheck.init(inst, def); // no format checks
393
+
394
+ const [minimum, maximum] = util.BIGINT_FORMAT_RANGES[def.format!];
395
+
396
+ inst._zod.onattach.push((inst) => {
397
+ const bag = inst._zod.bag;
398
+ bag.format = def.format;
399
+ bag.minimum = minimum;
400
+ bag.maximum = maximum;
401
+ });
402
+
403
+ inst._zod.check = (payload) => {
404
+ const input = payload.value;
405
+
406
+ if (input < minimum) {
407
+ payload.issues.push({
408
+ origin: "bigint",
409
+ input,
410
+ code: "too_small",
411
+ minimum: minimum as any,
412
+ inclusive: true,
413
+ inst,
414
+ continue: !def.abort,
415
+ });
416
+ }
417
+
418
+ if (input > maximum) {
419
+ payload.issues.push({
420
+ origin: "bigint",
421
+ input,
422
+ code: "too_big",
423
+ maximum,
424
+ inst,
425
+ } as any);
426
+ }
427
+ };
428
+ }
429
+ );
430
+
431
+ //////////////////////////////////
432
+ ///// $ZodCheckMaxSize /////
433
+ //////////////////////////////////
434
+ export interface $ZodCheckMaxSizeDef extends $ZodCheckDef {
435
+ check: "max_size";
436
+ maximum: number;
437
+ }
438
+
439
+ export interface $ZodCheckMaxSizeInternals<T extends util.HasSize = util.HasSize> extends $ZodCheckInternals<T> {
440
+ def: $ZodCheckMaxSizeDef;
441
+ issc: errors.$ZodIssueTooBig<T>;
442
+ }
443
+
444
+ export interface $ZodCheckMaxSize<T extends util.HasSize = util.HasSize> extends $ZodCheck<T> {
445
+ _zod: $ZodCheckMaxSizeInternals<T>;
446
+ }
447
+
448
+ export const $ZodCheckMaxSize: core.$constructor<$ZodCheckMaxSize> = /*@__PURE__*/ core.$constructor(
449
+ "$ZodCheckMaxSize",
450
+ (inst, def) => {
451
+ $ZodCheck.init(inst, def);
452
+
453
+ inst._zod.def.when ??= (payload) => {
454
+ const val = payload.value;
455
+ return !util.nullish(val) && (val as any).size !== undefined;
456
+ };
457
+
458
+ inst._zod.onattach.push((inst) => {
459
+ const curr = (inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY) as number;
460
+ if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
461
+ });
462
+
463
+ inst._zod.check = (payload) => {
464
+ const input = payload.value;
465
+ const size = input.size;
466
+
467
+ if (size <= def.maximum) return;
468
+ payload.issues.push({
469
+ origin: util.getSizableOrigin(input),
470
+ code: "too_big",
471
+ maximum: def.maximum,
472
+ input,
473
+ inst,
474
+ continue: !def.abort,
475
+ });
476
+ };
477
+ }
478
+ );
479
+
480
+ //////////////////////////////////
481
+ ///// $ZodCheckMinSize /////
482
+ //////////////////////////////////
483
+ export interface $ZodCheckMinSizeDef extends $ZodCheckDef {
484
+ check: "min_size";
485
+ minimum: number;
486
+ }
487
+
488
+ export interface $ZodCheckMinSizeInternals<T extends util.HasSize = util.HasSize> extends $ZodCheckInternals<T> {
489
+ def: $ZodCheckMinSizeDef;
490
+ issc: errors.$ZodIssueTooSmall<T>;
491
+ }
492
+
493
+ export interface $ZodCheckMinSize<T extends util.HasSize = util.HasSize> extends $ZodCheck<T> {
494
+ _zod: $ZodCheckMinSizeInternals<T>;
495
+ }
496
+
497
+ export const $ZodCheckMinSize: core.$constructor<$ZodCheckMinSize> = /*@__PURE__*/ core.$constructor(
498
+ "$ZodCheckMinSize",
499
+ (inst, def) => {
500
+ $ZodCheck.init(inst, def);
501
+
502
+ inst._zod.def.when ??= (payload) => {
503
+ const val = payload.value;
504
+ return !util.nullish(val) && (val as any).size !== undefined;
505
+ };
506
+
507
+ inst._zod.onattach.push((inst) => {
508
+ const curr = (inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY) as number;
509
+ if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
510
+ });
511
+
512
+ inst._zod.check = (payload) => {
513
+ const input = payload.value;
514
+ const size = input.size;
515
+
516
+ if (size >= def.minimum) return;
517
+ payload.issues.push({
518
+ origin: util.getSizableOrigin(input),
519
+ code: "too_small",
520
+ minimum: def.minimum,
521
+ input,
522
+ inst,
523
+ continue: !def.abort,
524
+ });
525
+ };
526
+ }
527
+ );
528
+
529
+ /////////////////////////////////////
530
+ ///// $ZodCheckSizeEquals /////
531
+ /////////////////////////////////////
532
+ export interface $ZodCheckSizeEqualsDef extends $ZodCheckDef {
533
+ check: "size_equals";
534
+ size: number;
535
+ }
536
+
537
+ export interface $ZodCheckSizeEqualsInternals<T extends util.HasSize = util.HasSize> extends $ZodCheckInternals<T> {
538
+ def: $ZodCheckSizeEqualsDef;
539
+ issc: errors.$ZodIssueTooBig<T> | errors.$ZodIssueTooSmall<T>;
540
+ }
541
+
542
+ export interface $ZodCheckSizeEquals<T extends util.HasSize = util.HasSize> extends $ZodCheck<T> {
543
+ _zod: $ZodCheckSizeEqualsInternals<T>;
544
+ }
545
+
546
+ export const $ZodCheckSizeEquals: core.$constructor<$ZodCheckSizeEquals> = /*@__PURE__*/ core.$constructor(
547
+ "$ZodCheckSizeEquals",
548
+ (inst, def) => {
549
+ $ZodCheck.init(inst, def);
550
+
551
+ inst._zod.def.when ??= (payload) => {
552
+ const val = payload.value;
553
+ return !util.nullish(val) && (val as any).size !== undefined;
554
+ };
555
+
556
+ inst._zod.onattach.push((inst) => {
557
+ const bag = inst._zod.bag;
558
+ bag.minimum = def.size;
559
+ bag.maximum = def.size;
560
+ bag.size = def.size;
561
+ });
562
+
563
+ inst._zod.check = (payload) => {
564
+ const input = payload.value;
565
+ const size = input.size;
566
+ if (size === def.size) return;
567
+
568
+ const tooBig = size > def.size;
569
+ payload.issues.push({
570
+ origin: util.getSizableOrigin(input),
571
+ ...(tooBig ? { code: "too_big", maximum: def.size } : { code: "too_small", minimum: def.size }),
572
+ inclusive: true,
573
+ exact: true,
574
+ input: payload.value,
575
+ inst,
576
+ continue: !def.abort,
577
+ });
578
+ };
579
+ }
580
+ );
581
+
582
+ //////////////////////////////////
583
+ ///// $ZodCheckMaxLength /////
584
+ //////////////////////////////////
585
+
586
+ export interface $ZodCheckMaxLengthDef extends $ZodCheckDef {
587
+ check: "max_length";
588
+ maximum: number;
589
+ }
590
+
591
+ export interface $ZodCheckMaxLengthInternals<T extends util.HasLength = util.HasLength> extends $ZodCheckInternals<T> {
592
+ def: $ZodCheckMaxLengthDef;
593
+ issc: errors.$ZodIssueTooBig<T>;
594
+ }
595
+
596
+ export interface $ZodCheckMaxLength<T extends util.HasLength = util.HasLength> extends $ZodCheck<T> {
597
+ _zod: $ZodCheckMaxLengthInternals<T>;
598
+ }
599
+
600
+ export const $ZodCheckMaxLength: core.$constructor<$ZodCheckMaxLength> = /*@__PURE__*/ core.$constructor(
601
+ "$ZodCheckMaxLength",
602
+ (inst, def) => {
603
+ $ZodCheck.init(inst, def);
604
+
605
+ inst._zod.def.when ??= (payload) => {
606
+ const val = payload.value;
607
+ return !util.nullish(val) && (val as any).length !== undefined;
608
+ };
609
+
610
+ inst._zod.onattach.push((inst) => {
611
+ const curr = (inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY) as number;
612
+ if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
613
+ });
614
+
615
+ inst._zod.check = (payload) => {
616
+ const input = payload.value;
617
+ const length = input.length;
618
+
619
+ if (length <= def.maximum) return;
620
+ const origin = util.getLengthableOrigin(input);
621
+ payload.issues.push({
622
+ origin,
623
+ code: "too_big",
624
+ maximum: def.maximum,
625
+ inclusive: true,
626
+ input,
627
+ inst,
628
+ continue: !def.abort,
629
+ });
630
+ };
631
+ }
632
+ );
633
+
634
+ //////////////////////////////////
635
+ ///// $ZodCheckMinLength /////
636
+ //////////////////////////////////
637
+ export interface $ZodCheckMinLengthDef extends $ZodCheckDef {
638
+ check: "min_length";
639
+ minimum: number;
640
+ }
641
+
642
+ export interface $ZodCheckMinLengthInternals<T extends util.HasLength = util.HasLength> extends $ZodCheckInternals<T> {
643
+ def: $ZodCheckMinLengthDef;
644
+ issc: errors.$ZodIssueTooSmall<T>;
645
+ }
646
+
647
+ export interface $ZodCheckMinLength<T extends util.HasLength = util.HasLength> extends $ZodCheck<T> {
648
+ _zod: $ZodCheckMinLengthInternals<T>;
649
+ }
650
+
651
+ export const $ZodCheckMinLength: core.$constructor<$ZodCheckMinLength> = /*@__PURE__*/ core.$constructor(
652
+ "$ZodCheckMinLength",
653
+ (inst, def) => {
654
+ $ZodCheck.init(inst, def);
655
+
656
+ inst._zod.def.when ??= (payload) => {
657
+ const val = payload.value;
658
+ return !util.nullish(val) && (val as any).length !== undefined;
659
+ };
660
+
661
+ inst._zod.onattach.push((inst) => {
662
+ const curr = (inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY) as number;
663
+ if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
664
+ });
665
+
666
+ inst._zod.check = (payload) => {
667
+ const input = payload.value;
668
+ const length = input.length;
669
+
670
+ if (length >= def.minimum) return;
671
+ const origin = util.getLengthableOrigin(input);
672
+ payload.issues.push({
673
+ origin,
674
+ code: "too_small",
675
+ minimum: def.minimum,
676
+ inclusive: true,
677
+ input,
678
+ inst,
679
+ continue: !def.abort,
680
+ });
681
+ };
682
+ }
683
+ );
684
+
685
+ /////////////////////////////////////
686
+ ///// $ZodCheckLengthEquals /////
687
+ /////////////////////////////////////
688
+ export interface $ZodCheckLengthEqualsDef extends $ZodCheckDef {
689
+ check: "length_equals";
690
+ length: number;
691
+ }
692
+
693
+ export interface $ZodCheckLengthEqualsInternals<T extends util.HasLength = util.HasLength>
694
+ extends $ZodCheckInternals<T> {
695
+ def: $ZodCheckLengthEqualsDef;
696
+ issc: errors.$ZodIssueTooBig<T> | errors.$ZodIssueTooSmall<T>;
697
+ }
698
+
699
+ export interface $ZodCheckLengthEquals<T extends util.HasLength = util.HasLength> extends $ZodCheck<T> {
700
+ _zod: $ZodCheckLengthEqualsInternals<T>;
701
+ }
702
+
703
+ export const $ZodCheckLengthEquals: core.$constructor<$ZodCheckLengthEquals> = /*@__PURE__*/ core.$constructor(
704
+ "$ZodCheckLengthEquals",
705
+ (inst, def) => {
706
+ $ZodCheck.init(inst, def);
707
+
708
+ inst._zod.def.when ??= (payload) => {
709
+ const val = payload.value;
710
+ return !util.nullish(val) && (val as any).length !== undefined;
711
+ };
712
+
713
+ inst._zod.onattach.push((inst) => {
714
+ const bag = inst._zod.bag;
715
+ bag.minimum = def.length;
716
+ bag.maximum = def.length;
717
+ bag.length = def.length;
718
+ });
719
+
720
+ inst._zod.check = (payload) => {
721
+ const input = payload.value;
722
+ const length = input.length;
723
+ if (length === def.length) return;
724
+ const origin = util.getLengthableOrigin(input);
725
+ const tooBig = length > def.length;
726
+ payload.issues.push({
727
+ origin,
728
+ ...(tooBig ? { code: "too_big", maximum: def.length } : { code: "too_small", minimum: def.length }),
729
+ inclusive: true,
730
+ exact: true,
731
+ input: payload.value,
732
+ inst,
733
+ continue: !def.abort,
734
+ });
735
+ };
736
+ }
737
+ );
738
+
739
+ /////////////////////////////////////////////
740
+ ///// $ZodCheckStringFormatRegex /////
741
+ /////////////////////////////////////////////
742
+ export type $ZodStringFormats =
743
+ | "email"
744
+ | "url"
745
+ | "emoji"
746
+ | "uuid"
747
+ | "guid"
748
+ | "nanoid"
749
+ | "cuid"
750
+ | "cuid2"
751
+ | "ulid"
752
+ | "xid"
753
+ | "ksuid"
754
+ | "datetime"
755
+ | "date"
756
+ | "time"
757
+ | "duration"
758
+ | "ipv4"
759
+ | "ipv6"
760
+ | "cidrv4"
761
+ | "cidrv6"
762
+ | "base64"
763
+ | "base64url"
764
+ | "json_string"
765
+ | "e164"
766
+ | "lowercase"
767
+ | "uppercase"
768
+ | "regex"
769
+ | "jwt"
770
+ | "starts_with"
771
+ | "ends_with"
772
+ | "includes";
773
+ export interface $ZodCheckStringFormatDef<Format extends string = string> extends $ZodCheckDef {
774
+ check: "string_format";
775
+ format: Format;
776
+ pattern?: RegExp | undefined;
777
+ }
778
+
779
+ export interface $ZodCheckStringFormatInternals extends $ZodCheckInternals<string> {
780
+ def: $ZodCheckStringFormatDef;
781
+ issc: errors.$ZodIssueInvalidStringFormat;
782
+ }
783
+
784
+ export interface $ZodCheckStringFormat extends $ZodCheck<string> {
785
+ _zod: $ZodCheckStringFormatInternals;
786
+ }
787
+
788
+ export const $ZodCheckStringFormat: core.$constructor<$ZodCheckStringFormat> = /*@__PURE__*/ core.$constructor(
789
+ "$ZodCheckStringFormat",
790
+ (inst, def) => {
791
+ $ZodCheck.init(inst, def);
792
+
793
+ inst._zod.onattach.push((inst) => {
794
+ const bag = inst._zod.bag as schemas.$ZodStringInternals<unknown>["bag"];
795
+ bag.format = def.format;
796
+ if (def.pattern) {
797
+ bag.patterns ??= new Set();
798
+ bag.patterns.add(def.pattern);
799
+ }
800
+ });
801
+
802
+ if (def.pattern)
803
+ inst._zod.check ??= (payload) => {
804
+ def.pattern!.lastIndex = 0;
805
+ if (def.pattern!.test(payload.value)) return;
806
+ payload.issues.push({
807
+ origin: "string",
808
+ code: "invalid_format",
809
+ format: def.format,
810
+ input: payload.value,
811
+ ...(def.pattern ? { pattern: def.pattern.toString() } : {}),
812
+ inst,
813
+ continue: !def.abort,
814
+ });
815
+ };
816
+ else inst._zod.check ??= () => {};
817
+ }
818
+ );
819
+
820
+ ////////////////////////////////
821
+ ///// $ZodCheckRegex /////
822
+ ////////////////////////////////
823
+ export interface $ZodCheckRegexDef extends $ZodCheckStringFormatDef {
824
+ format: "regex";
825
+ pattern: RegExp;
826
+ }
827
+
828
+ export interface $ZodCheckRegexInternals extends $ZodCheckInternals<string> {
829
+ def: $ZodCheckRegexDef;
830
+ issc: errors.$ZodIssueInvalidStringFormat;
831
+ }
832
+
833
+ export interface $ZodCheckRegex extends $ZodCheck<string> {
834
+ _zod: $ZodCheckRegexInternals;
835
+ }
836
+
837
+ export const $ZodCheckRegex: core.$constructor<$ZodCheckRegex> = /*@__PURE__*/ core.$constructor(
838
+ "$ZodCheckRegex",
839
+ (inst, def) => {
840
+ $ZodCheckStringFormat.init(inst, def);
841
+
842
+ inst._zod.check = (payload) => {
843
+ def.pattern.lastIndex = 0;
844
+ if (def.pattern.test(payload.value)) return;
845
+ payload.issues.push({
846
+ origin: "string",
847
+ code: "invalid_format",
848
+ format: "regex",
849
+ input: payload.value,
850
+ pattern: def.pattern.toString(),
851
+ inst,
852
+ continue: !def.abort,
853
+ });
854
+ };
855
+ }
856
+ );
857
+
858
+ ///////////////////////////////////
859
+ ///// $ZodCheckJSONString /////
860
+ ///////////////////////////////////
861
+ // interface $ZodCheckJSONStringDef extends $ZodCheckStringFormatDef<"json_string"> {
862
+ // // check: "string_format";
863
+ // // format: "json_string";
864
+ // // error?: errors.$ZodErrorMap<errors.$ZodIssueInvalidStringFormat> | undefined;
865
+ // }
866
+
867
+ // export interface $ZodCheckJSONString extends $ZodCheckStringFormat {
868
+ // _def: $ZodCheckJSONStringDef;
869
+ // }
870
+
871
+ // export const $ZodCheckJSONString: core.$constructor<$ZodCheckJSONString> = /*@__PURE__*/ core.$constructor(
872
+ // "$ZodCheckJSONString",
873
+ // (inst, def) => {
874
+ // $ZodCheck.init(inst, def);
875
+
876
+ // inst._zod.check = (payload) => {
877
+ // try {
878
+ // JSON.parse(payload.value);
879
+ // return;
880
+ // } catch (_) {
881
+ // payload.issues.push({
882
+ // origin: "string",
883
+ // code: "invalid_format",
884
+ // format: def.format,
885
+ // input: payload.value,
886
+ // inst,
887
+ // continue: !def.abort,
888
+ // });
889
+ // }
890
+ // };
891
+ // }
892
+ // );
893
+
894
+ //////////////////////////////////////
895
+ ///// $ZodCheckLowerCase /////
896
+ //////////////////////////////////////
897
+ export interface $ZodCheckLowerCaseDef extends $ZodCheckStringFormatDef<"lowercase"> {}
898
+
899
+ export interface $ZodCheckLowerCaseInternals extends $ZodCheckInternals<string> {
900
+ def: $ZodCheckLowerCaseDef;
901
+ issc: errors.$ZodIssueInvalidStringFormat;
902
+ }
903
+
904
+ export interface $ZodCheckLowerCase extends $ZodCheck<string> {
905
+ _zod: $ZodCheckLowerCaseInternals;
906
+ }
907
+
908
+ export const $ZodCheckLowerCase: core.$constructor<$ZodCheckLowerCase> = /*@__PURE__*/ core.$constructor(
909
+ "$ZodCheckLowerCase",
910
+ (inst, def) => {
911
+ def.pattern ??= regexes.lowercase;
912
+ $ZodCheckStringFormat.init(inst, def);
913
+ }
914
+ );
915
+
916
+ //////////////////////////////////////
917
+ ///// $ZodCheckUpperCase /////
918
+ //////////////////////////////////////
919
+ export interface $ZodCheckUpperCaseDef extends $ZodCheckStringFormatDef<"uppercase"> {}
920
+
921
+ export interface $ZodCheckUpperCaseInternals extends $ZodCheckInternals<string> {
922
+ def: $ZodCheckUpperCaseDef;
923
+ issc: errors.$ZodIssueInvalidStringFormat;
924
+ }
925
+
926
+ export interface $ZodCheckUpperCase extends $ZodCheck<string> {
927
+ _zod: $ZodCheckUpperCaseInternals;
928
+ }
929
+
930
+ export const $ZodCheckUpperCase: core.$constructor<$ZodCheckUpperCase> = /*@__PURE__*/ core.$constructor(
931
+ "$ZodCheckUpperCase",
932
+ (inst, def) => {
933
+ def.pattern ??= regexes.uppercase;
934
+ $ZodCheckStringFormat.init(inst, def);
935
+ }
936
+ );
937
+
938
+ ///////////////////////////////////
939
+ ///// $ZodCheckIncludes /////
940
+ ///////////////////////////////////
941
+ export interface $ZodCheckIncludesDef extends $ZodCheckStringFormatDef<"includes"> {
942
+ includes: string;
943
+ position?: number | undefined;
944
+ }
945
+
946
+ export interface $ZodCheckIncludesInternals extends $ZodCheckInternals<string> {
947
+ def: $ZodCheckIncludesDef;
948
+ issc: errors.$ZodIssueInvalidStringFormat;
949
+ }
950
+
951
+ export interface $ZodCheckIncludes extends $ZodCheck<string> {
952
+ _zod: $ZodCheckIncludesInternals;
953
+ }
954
+
955
+ export const $ZodCheckIncludes: core.$constructor<$ZodCheckIncludes> = /*@__PURE__*/ core.$constructor(
956
+ "$ZodCheckIncludes",
957
+ (inst, def) => {
958
+ $ZodCheck.init(inst, def);
959
+
960
+ const escapedRegex = util.escapeRegex(def.includes);
961
+ const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
962
+ def.pattern = pattern;
963
+ inst._zod.onattach.push((inst) => {
964
+ const bag = inst._zod.bag as schemas.$ZodStringInternals<unknown>["bag"];
965
+ bag.patterns ??= new Set();
966
+ bag.patterns.add(pattern);
967
+ });
968
+
969
+ inst._zod.check = (payload) => {
970
+ if (payload.value.includes(def.includes, def.position)) return;
971
+ payload.issues.push({
972
+ origin: "string",
973
+ code: "invalid_format",
974
+ format: "includes",
975
+ includes: def.includes,
976
+ input: payload.value,
977
+ inst,
978
+ continue: !def.abort,
979
+ });
980
+ };
981
+ }
982
+ );
983
+
984
+ /////////////////////////////////////
985
+ ///// $ZodCheckStartsWith /////
986
+ /////////////////////////////////////
987
+ export interface $ZodCheckStartsWithDef extends $ZodCheckStringFormatDef<"starts_with"> {
988
+ prefix: string;
989
+ }
990
+
991
+ export interface $ZodCheckStartsWithInternals extends $ZodCheckInternals<string> {
992
+ def: $ZodCheckStartsWithDef;
993
+ issc: errors.$ZodIssueInvalidStringFormat;
994
+ }
995
+
996
+ export interface $ZodCheckStartsWith extends $ZodCheck<string> {
997
+ _zod: $ZodCheckStartsWithInternals;
998
+ }
999
+
1000
+ export const $ZodCheckStartsWith: core.$constructor<$ZodCheckStartsWith> = /*@__PURE__*/ core.$constructor(
1001
+ "$ZodCheckStartsWith",
1002
+ (inst, def) => {
1003
+ $ZodCheck.init(inst, def);
1004
+
1005
+ const pattern = new RegExp(`^${util.escapeRegex(def.prefix)}.*`);
1006
+ def.pattern ??= pattern;
1007
+ inst._zod.onattach.push((inst) => {
1008
+ const bag = inst._zod.bag as schemas.$ZodStringInternals<unknown>["bag"];
1009
+ bag.patterns ??= new Set();
1010
+ bag.patterns.add(pattern);
1011
+ });
1012
+
1013
+ inst._zod.check = (payload) => {
1014
+ if (payload.value.startsWith(def.prefix)) return;
1015
+ payload.issues.push({
1016
+ origin: "string",
1017
+ code: "invalid_format",
1018
+ format: "starts_with",
1019
+ prefix: def.prefix,
1020
+ input: payload.value,
1021
+ inst,
1022
+ continue: !def.abort,
1023
+ });
1024
+ };
1025
+ }
1026
+ );
1027
+
1028
+ //////////////////////////////////
1029
+ ///// $ZodCheckEndsWith /////
1030
+ //////////////////////////////////
1031
+ export interface $ZodCheckEndsWithDef extends $ZodCheckStringFormatDef<"ends_with"> {
1032
+ suffix: string;
1033
+ }
1034
+
1035
+ export interface $ZodCheckEndsWithInternals extends $ZodCheckInternals<string> {
1036
+ def: $ZodCheckEndsWithDef;
1037
+ issc: errors.$ZodIssueInvalidStringFormat;
1038
+ }
1039
+
1040
+ export interface $ZodCheckEndsWith extends $ZodCheckInternals<string> {
1041
+ _zod: $ZodCheckEndsWithInternals;
1042
+ }
1043
+
1044
+ export const $ZodCheckEndsWith: core.$constructor<$ZodCheckEndsWith> = /*@__PURE__*/ core.$constructor(
1045
+ "$ZodCheckEndsWith",
1046
+ (inst, def) => {
1047
+ $ZodCheck.init(inst, def);
1048
+
1049
+ const pattern = new RegExp(`.*${util.escapeRegex(def.suffix)}$`);
1050
+ def.pattern ??= pattern;
1051
+ inst._zod.onattach.push((inst) => {
1052
+ const bag = inst._zod.bag as schemas.$ZodStringInternals<unknown>["bag"];
1053
+ bag.patterns ??= new Set();
1054
+ bag.patterns.add(pattern);
1055
+ });
1056
+
1057
+ inst._zod.check = (payload) => {
1058
+ if (payload.value.endsWith(def.suffix)) return;
1059
+ payload.issues.push({
1060
+ origin: "string",
1061
+ code: "invalid_format",
1062
+ format: "ends_with",
1063
+ suffix: def.suffix,
1064
+ input: payload.value,
1065
+ inst,
1066
+ continue: !def.abort,
1067
+ });
1068
+ };
1069
+ }
1070
+ );
1071
+
1072
+ ///////////////////////////////////
1073
+ ///// $ZodCheckProperty /////
1074
+ ///////////////////////////////////
1075
+ function handleCheckPropertyResult(
1076
+ result: schemas.ParsePayload<unknown>,
1077
+ payload: schemas.ParsePayload<unknown>,
1078
+ property: string
1079
+ ) {
1080
+ if (result.issues.length) {
1081
+ payload.issues.push(...util.prefixIssues(property, result.issues));
1082
+ }
1083
+ }
1084
+ export interface $ZodCheckPropertyDef extends $ZodCheckDef {
1085
+ check: "property";
1086
+ property: string;
1087
+ schema: schemas.$ZodType;
1088
+ }
1089
+
1090
+ export interface $ZodCheckPropertyInternals<T extends object = object> extends $ZodCheckInternals<T> {
1091
+ def: $ZodCheckPropertyDef;
1092
+ issc: errors.$ZodIssue;
1093
+ }
1094
+
1095
+ export interface $ZodCheckProperty<T extends object = object> extends $ZodCheck<T> {
1096
+ _zod: $ZodCheckPropertyInternals<T>;
1097
+ }
1098
+
1099
+ export const $ZodCheckProperty: core.$constructor<$ZodCheckProperty> = /*@__PURE__*/ core.$constructor(
1100
+ "$ZodCheckProperty",
1101
+ (inst, def) => {
1102
+ $ZodCheck.init(inst, def);
1103
+
1104
+ inst._zod.check = (payload) => {
1105
+ const result = def.schema._zod.run(
1106
+ {
1107
+ value: (payload.value as any)[def.property],
1108
+ issues: [],
1109
+ },
1110
+ {}
1111
+ );
1112
+
1113
+ if (result instanceof Promise) {
1114
+ return result.then((result) => handleCheckPropertyResult(result, payload, def.property));
1115
+ }
1116
+
1117
+ handleCheckPropertyResult(result, payload, def.property);
1118
+ return;
1119
+ };
1120
+ }
1121
+ );
1122
+
1123
+ ///////////////////////////////////
1124
+ ///// $ZodCheckMimeType /////
1125
+ ///////////////////////////////////
1126
+ export interface $ZodCheckMimeTypeDef extends $ZodCheckDef {
1127
+ check: "mime_type";
1128
+ mime: util.MimeTypes[];
1129
+ }
1130
+
1131
+ export interface $ZodCheckMimeTypeInternals<T extends File = File> extends $ZodCheckInternals<T> {
1132
+ def: $ZodCheckMimeTypeDef;
1133
+ issc: errors.$ZodIssueInvalidValue;
1134
+ }
1135
+
1136
+ export interface $ZodCheckMimeType<T extends File = File> extends $ZodCheck<T> {
1137
+ _zod: $ZodCheckMimeTypeInternals<T>;
1138
+ }
1139
+
1140
+ export const $ZodCheckMimeType: core.$constructor<$ZodCheckMimeType> = /*@__PURE__*/ core.$constructor(
1141
+ "$ZodCheckMimeType",
1142
+ (inst, def) => {
1143
+ $ZodCheck.init(inst, def);
1144
+ const mimeSet = new Set(def.mime);
1145
+ inst._zod.onattach.push((inst) => {
1146
+ inst._zod.bag.mime = def.mime;
1147
+ });
1148
+ inst._zod.check = (payload) => {
1149
+ if (mimeSet.has(payload.value.type)) return;
1150
+ payload.issues.push({
1151
+ code: "invalid_value",
1152
+ values: def.mime,
1153
+ input: payload.value.type,
1154
+ inst,
1155
+ });
1156
+ };
1157
+ }
1158
+ );
1159
+
1160
+ ///////////////////////////////////
1161
+ ///// $ZodCheckFileName /////
1162
+ ///////////////////////////////////
1163
+ // interface $ZodCheckFileNameDef extends $ZodCheckDef {
1164
+ // check: "file_name";
1165
+ // fileName: string;
1166
+ // error?: errors.$ZodErrorMap<errors.$ZodIssueInvalidType> | undefined;
1167
+ // }
1168
+ // export interface $ZodCheckFileName<T extends File = File>
1169
+ // extends $ZodCheckInternals<T> {
1170
+ // _def: $ZodCheckFileNameDef;
1171
+ // }
1172
+
1173
+ // export const $ZodCheckFileName: core.$constructor<$ZodCheckFileName> =
1174
+ // core.$constructor("$ZodCheckFileName", (inst, def) => {
1175
+ // $ZodCheck.init(inst, def);
1176
+
1177
+ // inst._zod.check = (payload) => {
1178
+ // if (def.fileName === payload.value.name) return;
1179
+ // payload.issues.push({
1180
+ // origin: "file",
1181
+ // code: "invalid_value",
1182
+ // options: [def.fileName],
1183
+ // input: payload.value,
1184
+ // path: ["name"],
1185
+ // inst,
1186
+ // });
1187
+ // };
1188
+ // });
1189
+
1190
+ ///////////////////////////////////
1191
+ ///// $ZodCheckOverwrite /////
1192
+ ///////////////////////////////////
1193
+ export interface $ZodCheckOverwriteDef<T = unknown> extends $ZodCheckDef {
1194
+ check: "overwrite";
1195
+ tx(value: T): T;
1196
+ }
1197
+
1198
+ export interface $ZodCheckOverwriteInternals<T = unknown> extends $ZodCheckInternals<T> {
1199
+ def: $ZodCheckOverwriteDef<T>;
1200
+ issc: never;
1201
+ }
1202
+
1203
+ export interface $ZodCheckOverwrite<T = unknown> extends $ZodCheck<T> {
1204
+ _zod: $ZodCheckOverwriteInternals<T>;
1205
+ }
1206
+
1207
+ export const $ZodCheckOverwrite: core.$constructor<$ZodCheckOverwrite> = /*@__PURE__*/ core.$constructor(
1208
+ "$ZodCheckOverwrite",
1209
+ (inst, def) => {
1210
+ $ZodCheck.init(inst, def);
1211
+
1212
+ inst._zod.check = (payload) => {
1213
+ payload.value = def.tx(payload.value);
1214
+ };
1215
+ }
1216
+ );
1217
+
1218
+ // ///////////////////////////////
1219
+ // ///// $ZodCheckTrim /////
1220
+ // ///////////////////////////////
1221
+ // export interface $ZodCheckTrimDef extends $ZodCheckDef {
1222
+ // check: "trim";
1223
+ // error?: errors.$ZodErrorMap<never> | undefined;
1224
+ // }
1225
+ // export interface $ZodCheckTrim extends $ZodCheckInternals<string> {
1226
+ // _def: $ZodCheckTrimDef;
1227
+ // }
1228
+
1229
+ // export const $ZodCheckTrim: core.$constructor<$ZodCheckTrim> =
1230
+ // core.$constructor("$ZodCheckTrim", (inst, def) => {
1231
+ // $ZodCheck.init(inst, def);
1232
+
1233
+ // inst._zod.check = (payload) => {
1234
+ // payload.value = payload.value.trim();
1235
+ // };
1236
+ // });
1237
+
1238
+ // //////////////////////////////////////
1239
+ // ///// $ZodCheckNormalize /////
1240
+ // //////////////////////////////////////
1241
+ // interface $ZodCheckNormalizeDef extends $ZodCheckDef {
1242
+ // check: "normalize";
1243
+ // error?: errors.$ZodErrorMap<never> | undefined;
1244
+ // }
1245
+
1246
+ // export interface $ZodCheckNormalize extends $ZodCheckInternals<string> {
1247
+ // _def: $ZodCheckNormalizeDef;
1248
+ // }
1249
+
1250
+ // export const $ZodCheckNormalize: core.$constructor<$ZodCheckNormalize> =
1251
+ // core.$constructor("$ZodCheckNormalize", (inst, def) => {
1252
+ // $ZodCheck.init(inst, def);
1253
+
1254
+ // inst._zod.check = (payload) => {
1255
+ // payload.value = payload.value.normalize();
1256
+ // };
1257
+ // });
1258
+
1259
+ export type $ZodChecks =
1260
+ | $ZodCheckLessThan
1261
+ | $ZodCheckGreaterThan
1262
+ | $ZodCheckMultipleOf
1263
+ | $ZodCheckNumberFormat
1264
+ | $ZodCheckBigIntFormat
1265
+ | $ZodCheckMaxSize
1266
+ | $ZodCheckMinSize
1267
+ | $ZodCheckSizeEquals
1268
+ | $ZodCheckMaxLength
1269
+ | $ZodCheckMinLength
1270
+ | $ZodCheckLengthEquals
1271
+ | $ZodCheckStringFormat
1272
+ | $ZodCheckProperty
1273
+ | $ZodCheckMimeType
1274
+ | $ZodCheckOverwrite;
1275
+
1276
+ export type $ZodStringFormatChecks =
1277
+ | $ZodCheckRegex
1278
+ | $ZodCheckLowerCase
1279
+ | $ZodCheckUpperCase
1280
+ | $ZodCheckIncludes
1281
+ | $ZodCheckStartsWith
1282
+ | $ZodCheckEndsWith
1283
+ | schemas.$ZodStringFormatTypes; // union of string format schema types
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/config.ts ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type * as errors from "./errors.js";
2
+
3
+ export interface $ZodConfig {
4
+ /** Custom error map. Overrides `config().localeError`. */
5
+ customError?: errors.$ZodErrorMap | undefined;
6
+ /** Localized error map. Lowest priority. */
7
+ localeError?: errors.$ZodErrorMap | undefined;
8
+ }
9
+
10
+ export const globalConfig: $ZodConfig = {};
11
+
12
+ export function config(config?: Partial<$ZodConfig>): $ZodConfig {
13
+ if (config) Object.assign(globalConfig, config);
14
+ return globalConfig;
15
+ }
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/core.ts ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type * as errors from "./errors.js";
2
+ import type * as schemas from "./schemas.js";
3
+ import type { Class } from "./util.js";
4
+ ////////////////////////////// CONSTRUCTORS ///////////////////////////////////////
5
+
6
+ type ZodTrait = { _zod: { def: any; [k: string]: any } };
7
+ export interface $constructor<T extends ZodTrait, D = T["_zod"]["def"]> {
8
+ new (def: D): T;
9
+ init(inst: T, def: D): asserts inst is T;
10
+ }
11
+
12
+ /** A special constant with type `never` */
13
+ export const NEVER: never = Object.freeze({
14
+ status: "aborted",
15
+ }) as never;
16
+
17
+ export /*@__NO_SIDE_EFFECTS__*/ function $constructor<T extends ZodTrait, D = T["_zod"]["def"]>(
18
+ name: string,
19
+ initializer: (inst: T, def: D) => void,
20
+ params?: { Parent?: typeof Class }
21
+ ): $constructor<T, D> {
22
+ function init(inst: T, def: D) {
23
+ Object.defineProperty(inst, "_zod", {
24
+ value: inst._zod ?? {},
25
+ enumerable: false,
26
+ });
27
+
28
+ inst._zod.traits ??= new Set();
29
+
30
+ inst._zod.traits.add(name);
31
+ initializer(inst, def);
32
+ // support prototype modifications
33
+ for (const k in _.prototype) {
34
+ if (!(k in inst)) Object.defineProperty(inst, k, { value: _.prototype[k].bind(inst) });
35
+ }
36
+ inst._zod.constr = _;
37
+ inst._zod.def = def;
38
+ }
39
+
40
+ // doesn't work if Parent has a constructor with arguments
41
+ const Parent = params?.Parent ?? Object;
42
+ class Definition extends Parent {}
43
+ Object.defineProperty(Definition, "name", { value: name });
44
+
45
+ function _(this: any, def: D) {
46
+ const inst = params?.Parent ? new Definition() : this;
47
+ init(inst, def);
48
+ inst._zod.deferred ??= [];
49
+ for (const fn of inst._zod.deferred) {
50
+ fn();
51
+ }
52
+ return inst;
53
+ }
54
+
55
+ Object.defineProperty(_, "init", { value: init });
56
+ Object.defineProperty(_, Symbol.hasInstance, {
57
+ value: (inst: any) => {
58
+ if (params?.Parent && inst instanceof params.Parent) return true;
59
+ return inst?._zod?.traits?.has(name);
60
+ },
61
+ });
62
+ Object.defineProperty(_, "name", { value: name });
63
+ return _ as any;
64
+ }
65
+
66
+ ////////////////////////////// UTILITIES ///////////////////////////////////////
67
+ export const $brand: unique symbol = Symbol("zod_brand");
68
+ export type $brand<T extends string | number | symbol = string | number | symbol> = {
69
+ [$brand]: { [k in T]: true };
70
+ };
71
+
72
+ export type $ZodBranded<T extends schemas.SomeType, Brand extends string | number | symbol> = T &
73
+ Record<"_zod", Record<"output", output<T> & $brand<Brand>>>;
74
+
75
+ export class $ZodAsyncError extends Error {
76
+ constructor() {
77
+ super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
78
+ }
79
+ }
80
+
81
+ //////////////////////////// TYPE HELPERS ///////////////////////////////////
82
+
83
+ // export type input<T extends schemas.$ZodType> = T["_zod"]["input"];
84
+ // export type output<T extends schemas.$ZodType> = T["_zod"]["output"];
85
+ // export type input<T extends schemas.$ZodType> = T["_zod"]["input"];
86
+ // export type output<T extends schemas.$ZodType> = T["_zod"]["output"];
87
+ export type input<T> = T extends { _zod: { input: any } } ? Required<T["_zod"]>["input"] : unknown;
88
+ export type output<T> = T extends { _zod: { output: any } } ? Required<T["_zod"]>["output"] : unknown;
89
+
90
+ // Mk2
91
+ // export type input<T> = T extends { _zod: { "~input": any } }
92
+ // ? T["_zod"]["~input"]
93
+ // : T extends { _zod: { input: any } }
94
+ // ? T["_zod"]["input"]
95
+ // : never;
96
+ // export type output<T> = T extends { _zod: { "~output": any } }
97
+ // ? T["_zod"]["~output"]
98
+ // : T extends { _zod: { output: any } }
99
+ // ? T["_zod"]["output"]
100
+ // : never;
101
+ // Mk 3
102
+ // export type input<T extends schemas.$ZodType> = T["_zod"]["input"];
103
+ // export type output<T extends schemas.$ZodType> = T["_zod"]["output"];
104
+ // Mk 4
105
+ // export type input<T extends schemas.$ZodType> = T[] extends { _zod: { "~input": any } }
106
+ // ? T["_zod"]["~input"]
107
+ // : T extends { _zod: { input: any } }
108
+ // ? T["_zod"]["input"]
109
+ // : never;
110
+ // export type output<T extends schemas.$ZodType> = T extends { _zod: { "~output": any } }
111
+ // ? T["_zod"]["~output"]
112
+ // : T extends { _zod: { output: any } }
113
+ // ? T["_zod"]["output"]
114
+ // : never;
115
+
116
+ export type { output as infer };
117
+
118
+ ////////////////////////////// CONFIG ///////////////////////////////////////
119
+
120
+ export interface $ZodConfig {
121
+ /** Custom error map. Overrides `config().localeError`. */
122
+ customError?: errors.$ZodErrorMap | undefined;
123
+ /** Localized error map. Lowest priority. */
124
+ localeError?: errors.$ZodErrorMap | undefined;
125
+ /** Disable JIT schema compilation. Useful in environments that disallow `eval`. */
126
+ jitless?: boolean | undefined;
127
+ }
128
+
129
+ export const globalConfig: $ZodConfig = {};
130
+
131
+ export function config(newConfig?: Partial<$ZodConfig>): $ZodConfig {
132
+ if (newConfig) Object.assign(globalConfig, newConfig);
133
+ return globalConfig;
134
+ }
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/doc.ts ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ type ModeWriter = (doc: Doc, modes: { execution: "sync" | "async" }) => void;
2
+
3
+ export class Doc {
4
+ args!: string[];
5
+ content: string[] = [];
6
+ indent = 0;
7
+
8
+ constructor(args: string[] = []) {
9
+ if (this) this.args = args;
10
+ }
11
+
12
+ indented(fn: (doc: Doc) => void) {
13
+ this.indent += 1;
14
+ fn(this);
15
+ this.indent -= 1;
16
+ }
17
+
18
+ write(fn: ModeWriter): void;
19
+ write(line: string): void;
20
+ write(arg: any) {
21
+ if (typeof arg === "function") {
22
+ (arg as ModeWriter)(this, { execution: "sync" });
23
+ (arg as ModeWriter)(this, { execution: "async" });
24
+ return;
25
+ }
26
+
27
+ const content = arg as string;
28
+ const lines = content.split("\n").filter((x) => x);
29
+ const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
30
+ const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
31
+ for (const line of dedented) {
32
+ this.content.push(line);
33
+ }
34
+ }
35
+
36
+ compile() {
37
+ const F = Function;
38
+ const args = this?.args;
39
+ const content = this?.content ?? [``];
40
+ const lines = [...content.map((x) => ` ${x}`)];
41
+ // console.log(lines.join("\n"));
42
+ return new F(...args, lines.join("\n"));
43
+ }
44
+ }
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/errors.ts ADDED
@@ -0,0 +1,424 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { $ZodCheck, $ZodStringFormats } from "./checks.js";
2
+ import { $constructor } from "./core.js";
3
+ import type { $ZodType } from "./schemas.js";
4
+ import * as util from "./util.js";
5
+
6
+ ///////////////////////////
7
+ //// base type ////
8
+ ///////////////////////////
9
+ export interface $ZodIssueBase {
10
+ readonly code?: string;
11
+ readonly input?: unknown;
12
+ readonly path: PropertyKey[];
13
+ readonly message: string;
14
+ // [k: string]: unknown;
15
+ }
16
+
17
+ ////////////////////////////////
18
+ //// issue subtypes ////
19
+ ////////////////////////////////
20
+ export interface $ZodIssueInvalidType<Input = unknown> extends $ZodIssueBase {
21
+ readonly code: "invalid_type";
22
+ readonly expected: $ZodType["_zod"]["def"]["type"];
23
+ readonly input: Input;
24
+ }
25
+
26
+ export interface $ZodIssueTooBig<Input = unknown> extends $ZodIssueBase {
27
+ readonly code: "too_big";
28
+ readonly origin: "number" | "int" | "bigint" | "date" | "string" | "array" | "set" | "file" | (string & {});
29
+ readonly maximum: number | bigint;
30
+ readonly inclusive?: boolean;
31
+ readonly exact?: boolean;
32
+ readonly input: Input;
33
+ }
34
+
35
+ export interface $ZodIssueTooSmall<Input = unknown> extends $ZodIssueBase {
36
+ readonly code: "too_small";
37
+ readonly origin: "number" | "int" | "bigint" | "date" | "string" | "array" | "set" | "file" | (string & {});
38
+ readonly minimum: number | bigint;
39
+ /** True if the allowable range includes the minimum */
40
+ readonly inclusive?: boolean;
41
+ /** True if the allowed value is fixed (e.g.` z.length(5)`), not a range (`z.minLength(5)`) */
42
+ readonly exact?: boolean;
43
+ readonly input: Input;
44
+ }
45
+
46
+ export interface $ZodIssueInvalidStringFormat extends $ZodIssueBase {
47
+ readonly code: "invalid_format";
48
+ readonly format: $ZodStringFormats | (string & {});
49
+ readonly pattern?: string;
50
+ readonly input: string;
51
+ }
52
+
53
+ export interface $ZodIssueNotMultipleOf<Input extends number | bigint = number | bigint> extends $ZodIssueBase {
54
+ readonly code: "not_multiple_of";
55
+ readonly divisor: number;
56
+ readonly input: Input;
57
+ }
58
+
59
+ export interface $ZodIssueUnrecognizedKeys extends $ZodIssueBase {
60
+ readonly code: "unrecognized_keys";
61
+ readonly keys: string[];
62
+ readonly input: Record<string, unknown>;
63
+ }
64
+
65
+ export interface $ZodIssueInvalidUnion extends $ZodIssueBase {
66
+ readonly code: "invalid_union";
67
+ readonly errors: $ZodIssue[][];
68
+ readonly input: unknown;
69
+ }
70
+
71
+ export interface $ZodIssueInvalidKey<Input = unknown> extends $ZodIssueBase {
72
+ readonly code: "invalid_key";
73
+ readonly origin: "map" | "record";
74
+ readonly issues: $ZodIssue[];
75
+ readonly input: Input;
76
+ }
77
+
78
+ export interface $ZodIssueInvalidElement<Input = unknown> extends $ZodIssueBase {
79
+ readonly code: "invalid_element";
80
+ readonly origin: "map" | "set";
81
+ readonly key: unknown;
82
+ readonly issues: $ZodIssue[];
83
+ readonly input: Input;
84
+ }
85
+
86
+ export interface $ZodIssueInvalidValue<Input = unknown> extends $ZodIssueBase {
87
+ readonly code: "invalid_value";
88
+ readonly values: util.Primitive[];
89
+ readonly input: Input;
90
+ }
91
+
92
+ export interface $ZodIssueCustom extends $ZodIssueBase {
93
+ readonly code: "custom";
94
+ readonly params?: Record<string, any> | undefined;
95
+ readonly input: unknown;
96
+ }
97
+
98
+ ////////////////////////////////////////////
99
+ //// first-party string formats ////
100
+ ////////////////////////////////////////////
101
+
102
+ export interface $ZodIssueStringCommonFormats extends $ZodIssueInvalidStringFormat {
103
+ format: Exclude<$ZodStringFormats, "regex" | "jwt" | "starts_with" | "ends_with" | "includes">;
104
+ }
105
+
106
+ export interface $ZodIssueStringInvalidRegex extends $ZodIssueInvalidStringFormat {
107
+ format: "regex";
108
+ pattern: string;
109
+ }
110
+
111
+ export interface $ZodIssueStringInvalidJWT extends $ZodIssueInvalidStringFormat {
112
+ format: "jwt";
113
+ algorithm?: string;
114
+ }
115
+
116
+ export interface $ZodIssueStringStartsWith extends $ZodIssueInvalidStringFormat {
117
+ format: "starts_with";
118
+ prefix: string;
119
+ }
120
+
121
+ export interface $ZodIssueStringEndsWith extends $ZodIssueInvalidStringFormat {
122
+ format: "ends_with";
123
+ suffix: string;
124
+ }
125
+
126
+ export interface $ZodIssueStringIncludes extends $ZodIssueInvalidStringFormat {
127
+ format: "includes";
128
+ includes: string;
129
+ }
130
+
131
+ export type $ZodStringFormatIssues =
132
+ | $ZodIssueStringCommonFormats
133
+ | $ZodIssueStringInvalidRegex
134
+ | $ZodIssueStringInvalidJWT
135
+ | $ZodIssueStringStartsWith
136
+ | $ZodIssueStringEndsWith
137
+ | $ZodIssueStringIncludes;
138
+
139
+ ////////////////////////
140
+ //// utils /////
141
+ ////////////////////////
142
+
143
+ export type $ZodIssue =
144
+ | $ZodIssueInvalidType
145
+ | $ZodIssueTooBig
146
+ | $ZodIssueTooSmall
147
+ | $ZodIssueInvalidStringFormat
148
+ | $ZodIssueNotMultipleOf
149
+ | $ZodIssueUnrecognizedKeys
150
+ | $ZodIssueInvalidUnion
151
+ | $ZodIssueInvalidKey
152
+ | $ZodIssueInvalidElement
153
+ | $ZodIssueInvalidValue
154
+ | $ZodIssueCustom;
155
+
156
+ export type $ZodIssueCode = $ZodIssue["code"];
157
+
158
+ export type $ZodRawIssue<T extends $ZodIssueBase = $ZodIssue> = T extends any ? RawIssue<T> : never;
159
+ type RawIssue<T extends $ZodIssueBase> = util.Flatten<
160
+ util.MakePartial<T, "message" | "path"> & {
161
+ /** The input data */
162
+ readonly input?: unknown;
163
+ /** The schema or check that originated this issue. */
164
+ readonly inst?: $ZodType | $ZodCheck;
165
+ /** @deprecated Internal use only. If `true`, Zod will continue executing validation despite this issue. */
166
+ readonly continue?: boolean | undefined;
167
+ } & Record<string, any>
168
+ >;
169
+
170
+ export interface $ZodErrorMap<T extends $ZodIssueBase = $ZodIssue> {
171
+ // biome-ignore lint:
172
+ (issue: $ZodRawIssue<T>): { message: string } | string | undefined | null;
173
+ }
174
+
175
+ //////////////////////// ERROR CLASS ////////////////////////
176
+
177
+ // const ZOD_ERROR: symbol = Symbol.for("{{zod.error}}");
178
+ export interface $ZodError<T = unknown> extends Error {
179
+ type: T;
180
+ issues: $ZodIssue[];
181
+ _zod: {
182
+ output: T;
183
+ def: $ZodIssue[];
184
+ };
185
+ stack?: string;
186
+ name: string;
187
+ }
188
+
189
+ const initializer = (inst: $ZodError, def: $ZodIssue[]): void => {
190
+ inst.name = "$ZodError";
191
+ Object.defineProperty(inst, "_zod", {
192
+ value: inst._zod,
193
+ enumerable: false,
194
+ });
195
+ Object.defineProperty(inst, "issues", {
196
+ value: def,
197
+ enumerable: false,
198
+ });
199
+ Object.defineProperty(inst, "message", {
200
+ get() {
201
+ return JSON.stringify(def, util.jsonStringifyReplacer, 2);
202
+ },
203
+ enumerable: true,
204
+ // configurable: false,
205
+ });
206
+ Object.defineProperty(inst, "toString", {
207
+ value: () => inst.message,
208
+ enumerable: false,
209
+ });
210
+ };
211
+
212
+ export const $ZodError: $constructor<$ZodError> = $constructor("$ZodError", initializer);
213
+ interface $ZodRealError<T = any> extends $ZodError<T> {}
214
+ export const $ZodRealError: $constructor<$ZodRealError> = $constructor("$ZodError", initializer, { Parent: Error });
215
+
216
+ /////////////////// ERROR UTILITIES ////////////////////////
217
+
218
+ // flatten
219
+ export type $ZodFlattenedError<T, U = string> = _FlattenedError<T, U>;
220
+ type _FlattenedError<T, U = string> = {
221
+ formErrors: U[];
222
+ fieldErrors: {
223
+ [P in keyof T]?: U[];
224
+ };
225
+ };
226
+
227
+ export function flattenError<T>(error: $ZodError<T>): _FlattenedError<T>;
228
+ export function flattenError<T, U>(error: $ZodError<T>, mapper?: (issue: $ZodIssue) => U): _FlattenedError<T, U>;
229
+ export function flattenError(error: $ZodError, mapper = (issue: $ZodIssue) => issue.message): any {
230
+ const fieldErrors: any = {};
231
+ const formErrors: any[] = [];
232
+ for (const sub of error.issues) {
233
+ if (sub.path.length > 0) {
234
+ fieldErrors[sub.path[0]!] = fieldErrors[sub.path[0]!] || [];
235
+ fieldErrors[sub.path[0]!].push(mapper(sub));
236
+ } else {
237
+ formErrors.push(mapper(sub));
238
+ }
239
+ }
240
+ return { formErrors, fieldErrors };
241
+ }
242
+
243
+ type _ZodFormattedError<T, U = string> = T extends [any, ...any[]]
244
+ ? { [K in keyof T]?: $ZodFormattedError<T[K], U> }
245
+ : T extends any[]
246
+ ? { [k: number]: $ZodFormattedError<T[number], U> }
247
+ : T extends object
248
+ ? util.Flatten<{ [K in keyof T]?: $ZodFormattedError<T[K], U> }>
249
+ : any;
250
+
251
+ export type $ZodFormattedError<T, U = string> = {
252
+ _errors: U[];
253
+ } & util.Flatten<_ZodFormattedError<T, U>>;
254
+
255
+ export function formatError<T>(error: $ZodError<T>): $ZodFormattedError<T>;
256
+ export function formatError<T, U>(error: $ZodError<T>, mapper?: (issue: $ZodIssue) => U): $ZodFormattedError<T, U>;
257
+ export function formatError<T>(error: $ZodError, _mapper?: any) {
258
+ const mapper: (issue: $ZodIssue) => any =
259
+ _mapper ||
260
+ function (issue: $ZodIssue) {
261
+ return issue.message;
262
+ };
263
+ const fieldErrors: $ZodFormattedError<T> = { _errors: [] } as any;
264
+ const processError = (error: { issues: $ZodIssue[] }) => {
265
+ for (const issue of error.issues) {
266
+ if (issue.code === "invalid_union" && issue.errors.length) {
267
+ issue.errors.map((issues) => processError({ issues }));
268
+ } else if (issue.code === "invalid_key") {
269
+ processError({ issues: issue.issues });
270
+ } else if (issue.code === "invalid_element") {
271
+ processError({ issues: issue.issues });
272
+ } else if (issue.path.length === 0) {
273
+ (fieldErrors as any)._errors.push(mapper(issue));
274
+ } else {
275
+ let curr: any = fieldErrors;
276
+ let i = 0;
277
+ while (i < issue.path.length) {
278
+ const el = issue.path[i]!;
279
+ const terminal = i === issue.path.length - 1;
280
+
281
+ if (!terminal) {
282
+ curr[el] = curr[el] || { _errors: [] };
283
+ } else {
284
+ curr[el] = curr[el] || { _errors: [] };
285
+ curr[el]._errors.push(mapper(issue));
286
+ }
287
+
288
+ curr = curr[el];
289
+ i++;
290
+ }
291
+ }
292
+ }
293
+ };
294
+ processError(error);
295
+ return fieldErrors;
296
+ }
297
+
298
+ export type $ZodErrorTree<T, U = string> = T extends [any, ...any[]]
299
+ ? { errors: U[]; items?: { [K in keyof T]?: $ZodErrorTree<T[K], U> } }
300
+ : T extends any[]
301
+ ? { errors: U[]; items?: Array<$ZodErrorTree<T[number], U>> }
302
+ : T extends object
303
+ ? { errors: U[]; properties?: { [K in keyof T]?: $ZodErrorTree<T[K], U> } }
304
+ : { errors: U[] };
305
+
306
+ export function treeifyError<T>(error: $ZodError<T>): $ZodErrorTree<T>;
307
+ export function treeifyError<T, U>(error: $ZodError<T>, mapper?: (issue: $ZodIssue) => U): $ZodErrorTree<T, U>;
308
+ export function treeifyError<T>(error: $ZodError, _mapper?: any) {
309
+ const mapper: (issue: $ZodIssue) => any =
310
+ _mapper ||
311
+ function (issue: $ZodIssue) {
312
+ return issue.message;
313
+ };
314
+ const result: $ZodErrorTree<T> = { errors: [] } as any;
315
+ const processError = (error: { issues: $ZodIssue[] }, path: PropertyKey[] = []) => {
316
+ for (const issue of error.issues) {
317
+ if (issue.code === "invalid_union" && issue.errors.length) {
318
+ // regular union error
319
+ issue.errors.map((issues) => processError({ issues }, issue.path));
320
+ } else if (issue.code === "invalid_key") {
321
+ processError({ issues: issue.issues }, issue.path);
322
+ } else if (issue.code === "invalid_element") {
323
+ processError({ issues: issue.issues }, issue.path);
324
+ } else {
325
+ const fullpath = [...path, ...issue.path];
326
+ if (fullpath.length === 0) {
327
+ result.errors.push(mapper(issue));
328
+ continue;
329
+ }
330
+
331
+ let curr: any = result;
332
+ let i = 0;
333
+ while (i < fullpath.length) {
334
+ const el = fullpath[i]!;
335
+
336
+ const terminal = i === fullpath.length - 1;
337
+ if (typeof el === "string") {
338
+ curr.properties ??= {};
339
+ curr.properties[el] ??= { errors: [] };
340
+ curr = curr.properties[el];
341
+ } else {
342
+ curr.items ??= [];
343
+ curr.items[el] ??= { errors: [] };
344
+ curr = curr.items[el];
345
+ }
346
+
347
+ if (terminal) {
348
+ curr.errors.push(mapper(issue));
349
+ }
350
+
351
+ i++;
352
+ }
353
+ }
354
+ }
355
+ };
356
+ processError(error);
357
+ return result;
358
+ }
359
+
360
+ /** Format a ZodError as a human-readable string in the following form.
361
+ *
362
+ * From
363
+ *
364
+ * ```ts
365
+ * ZodError {
366
+ * issues: [
367
+ * {
368
+ * expected: 'string',
369
+ * code: 'invalid_type',
370
+ * path: [ 'username' ],
371
+ * message: 'Invalid input: expected string'
372
+ * },
373
+ * {
374
+ * expected: 'number',
375
+ * code: 'invalid_type',
376
+ * path: [ 'favoriteNumbers', 1 ],
377
+ * message: 'Invalid input: expected number'
378
+ * }
379
+ * ];
380
+ * }
381
+ * ```
382
+ *
383
+ * to
384
+ *
385
+ * ```
386
+ * username
387
+ * ✖ Expected number, received string at "username
388
+ * favoriteNumbers[0]
389
+ * ✖ Invalid input: expected number
390
+ * ```
391
+ */
392
+ export function toDotPath(path: (string | number | symbol)[]): string {
393
+ const segs: string[] = [];
394
+ for (const seg of path) {
395
+ if (typeof seg === "number") segs.push(`[${seg}]`);
396
+ else if (typeof seg === "symbol") segs.push(`[${JSON.stringify(String(seg))}]`);
397
+ else if (/[^\w$]/.test(seg)) segs.push(`[${JSON.stringify(seg)}]`);
398
+ else {
399
+ if (segs.length) segs.push(".");
400
+ segs.push(seg);
401
+ }
402
+ }
403
+
404
+ return segs.join("");
405
+ }
406
+
407
+ interface BaseError {
408
+ issues: $ZodIssueBase[];
409
+ }
410
+
411
+ export function prettifyError(error: BaseError): string {
412
+ const lines: string[] = [];
413
+ // sort by path length
414
+ const issues = [...error.issues].sort((a, b) => a.path.length - b.path.length);
415
+
416
+ // Process each issue
417
+ for (const issue of issues) {
418
+ lines.push(`✖ ${issue.message}`);
419
+ if (issue.path?.length) lines.push(` → at ${toDotPath(issue.path)}`);
420
+ }
421
+
422
+ // Convert Map to formatted string
423
+ return lines.join("\n");
424
+ }
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/function.ts ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { _array, _tuple, _unknown } from "./api.js";
2
+ import type * as core from "./core.js";
3
+ import { parse, parseAsync } from "./parse.js";
4
+ import * as schemas from "./schemas.js";
5
+ import { $ZodTuple } from "./schemas.js";
6
+ import type * as util from "./util.js";
7
+
8
+ //////////////////////////////////////////
9
+ //////////////////////////////////////////
10
+ ////////// //////////
11
+ ////////// $ZodFunction //////////
12
+ ////////// //////////
13
+ //////////////////////////////////////////
14
+ //////////////////////////////////////////
15
+ export interface $ZodFunctionDef<
16
+ In extends $ZodFunctionIn = $ZodFunctionIn,
17
+ Out extends $ZodFunctionOut = $ZodFunctionOut,
18
+ > {
19
+ type: "function";
20
+ input: In;
21
+ output: Out;
22
+ }
23
+
24
+ export type $ZodFunctionArgs = schemas.$ZodType<unknown[], unknown[]>;
25
+ export type $ZodFunctionIn = $ZodFunctionArgs;
26
+ export type $ZodFunctionOut = schemas.$ZodType;
27
+
28
+ export type $InferInnerFunctionType<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (
29
+ ...args: $ZodFunctionIn extends Args ? never[] : core.output<Args>
30
+ ) => core.input<Returns>;
31
+
32
+ export type $InferInnerFunctionTypeAsync<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (
33
+ ...args: $ZodFunctionIn extends Args ? never[] : core.output<Args>
34
+ ) => util.MaybeAsync<core.input<Returns>>;
35
+
36
+ export type $InferOuterFunctionType<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (
37
+ ...args: $ZodFunctionIn extends Args ? never[] : core.input<Args>
38
+ ) => core.output<Returns>;
39
+
40
+ export type $InferOuterFunctionTypeAsync<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (
41
+ ...args: $ZodFunctionIn extends Args ? never[] : core.input<Args>
42
+ ) => util.MaybeAsync<core.output<Returns>>;
43
+
44
+ export class $ZodFunction<
45
+ Args extends $ZodFunctionIn = $ZodFunctionIn,
46
+ Returns extends $ZodFunctionOut = $ZodFunctionOut,
47
+ > {
48
+ def: $ZodFunctionDef<Args, Returns>;
49
+
50
+ /** @deprecated */
51
+ _def!: $ZodFunctionDef<Args, Returns>;
52
+ _input!: $InferInnerFunctionType<Args, Returns>;
53
+ _output!: $InferOuterFunctionType<Args, Returns>;
54
+
55
+ constructor(def: $ZodFunctionDef<Args, Returns>) {
56
+ this._def = def;
57
+ this.def = def;
58
+ }
59
+
60
+ implement<F extends $InferInnerFunctionType<Args, Returns>>(
61
+ func: F
62
+ ): // allow for return type inference
63
+ (
64
+ ...args: Parameters<this["_output"]>
65
+ ) => ReturnType<F> extends ReturnType<this["_output"]> ? ReturnType<F> : ReturnType<this["_output"]> {
66
+ if (typeof func !== "function") {
67
+ throw new Error("implement() must be called with a function");
68
+ }
69
+ const impl = ((...args: any[]) => {
70
+ const parsedArgs = this._def.input ? parse(this._def.input, args, undefined, { callee: impl }) : args;
71
+ if (!Array.isArray(parsedArgs)) {
72
+ throw new Error("Invalid arguments schema: not an array or tuple schema.");
73
+ }
74
+ const output = func(...(parsedArgs as any));
75
+ return this._def.output ? parse(this._def.output, output, undefined, { callee: impl }) : output;
76
+ }) as any;
77
+ return impl;
78
+ }
79
+
80
+ implementAsync<F extends $InferInnerFunctionTypeAsync<Args, Returns>>(
81
+ func: F
82
+ ): F extends $InferOuterFunctionTypeAsync<Args, Returns> ? F : $InferOuterFunctionTypeAsync<Args, Returns> {
83
+ if (typeof func !== "function") {
84
+ throw new Error("implement() must be called with a function");
85
+ }
86
+
87
+ const impl = (async (...args: any[]) => {
88
+ const parsedArgs = this._def.input ? await parseAsync(this._def.input, args, undefined, { callee: impl }) : args;
89
+ if (!Array.isArray(parsedArgs)) {
90
+ throw new Error("Invalid arguments schema: not an array or tuple schema.");
91
+ }
92
+ const output = await func(...(parsedArgs as any));
93
+ return this._def.output ? parseAsync(this._def.output, output, undefined, { callee: impl }) : output;
94
+ }) as any;
95
+ return impl;
96
+ }
97
+
98
+ input<const Items extends util.TupleItems, const Rest extends $ZodFunctionOut = $ZodFunctionOut>(
99
+ args: Items,
100
+ rest?: Rest
101
+ ): $ZodFunction<schemas.$ZodTuple<Items, Rest>, Returns>;
102
+ input<NewArgs extends $ZodFunctionIn>(args: NewArgs): $ZodFunction<NewArgs, Returns>;
103
+ input(...args: any[]): $ZodFunction<any, Returns> {
104
+ const F: any = this.constructor;
105
+ if (Array.isArray(args[0])) {
106
+ return new F({
107
+ type: "function",
108
+ input: new $ZodTuple({
109
+ type: "tuple",
110
+ items: args[0],
111
+ rest: args[1],
112
+ }),
113
+ output: this._def.output,
114
+ });
115
+ }
116
+
117
+ return new F({
118
+ type: "function",
119
+ input: args[0],
120
+ output: this._def.output,
121
+ });
122
+ }
123
+
124
+ output<NewReturns extends schemas.$ZodType>(output: NewReturns): $ZodFunction<Args, NewReturns> {
125
+ const F: any = this.constructor;
126
+ return new F({
127
+ type: "function",
128
+ input: this._def.input,
129
+ output,
130
+ });
131
+ }
132
+ }
133
+
134
+ export interface $ZodFunctionParams<I extends $ZodFunctionIn, O extends schemas.$ZodType> {
135
+ input?: I;
136
+ output?: O;
137
+ }
138
+
139
+ function _function(): $ZodFunction;
140
+ function _function<const In extends Array<schemas.$ZodType> = Array<schemas.$ZodType>>(params: {
141
+ input: In;
142
+ }): $ZodFunction<$ZodTuple<In, null>, $ZodFunctionOut>;
143
+ function _function<
144
+ const In extends Array<schemas.$ZodType> = Array<schemas.$ZodType>,
145
+ const Out extends $ZodFunctionOut = $ZodFunctionOut,
146
+ >(params: {
147
+ input: In;
148
+ output: Out;
149
+ }): $ZodFunction<$ZodTuple<In, null>, Out>;
150
+ function _function<const In extends $ZodFunctionIn = $ZodFunctionIn>(params: {
151
+ input: In;
152
+ }): $ZodFunction<In, $ZodFunctionOut>;
153
+ function _function<const Out extends $ZodFunctionOut = $ZodFunctionOut>(params: {
154
+ output: Out;
155
+ }): $ZodFunction<$ZodFunctionIn, Out>;
156
+ function _function<
157
+ In extends $ZodFunctionIn = $ZodFunctionIn,
158
+ Out extends schemas.$ZodType = schemas.$ZodType,
159
+ >(params?: {
160
+ input: In;
161
+ output: Out;
162
+ }): $ZodFunction<In, Out>;
163
+ function _function(params?: {
164
+ output?: schemas.$ZodType;
165
+ input?: $ZodFunctionArgs | Array<schemas.$ZodType>;
166
+ }): any {
167
+ return new $ZodFunction({
168
+ type: "function",
169
+ input: Array.isArray(params?.input)
170
+ ? _tuple(schemas.$ZodTuple, params?.input as any)
171
+ : (params?.input ?? _array(schemas.$ZodArray, _unknown(schemas.$ZodUnknown))),
172
+ output: params?.output ?? _unknown(schemas.$ZodUnknown),
173
+ });
174
+ }
175
+
176
+ export { _function as function };
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/index.ts ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export * from "./core.js";
2
+ export * from "./parse.js";
3
+ export * from "./errors.js";
4
+ export * from "./schemas.js";
5
+ export * from "./checks.js";
6
+ export * from "./versions.js";
7
+ export * as util from "./util.js";
8
+ export * as regexes from "./regexes.js";
9
+ export * as locales from "../locales/index.js";
10
+ export * from "./registries.js";
11
+ export * from "./doc.js";
12
+ export * from "./function.js";
13
+ export * from "./api.js";
14
+ export * from "./to-json-schema.js";
15
+ export * as JSONSchema from "./json-schema.js";
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/json-schema.ts ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export type Schema =
2
+ | ObjectSchema
3
+ | ArraySchema
4
+ | StringSchema
5
+ | NumberSchema
6
+ | IntegerSchema
7
+ | BooleanSchema
8
+ | NullSchema;
9
+
10
+ // export type JsonType = "object" | "array" | "string" | "number" | "boolean" | "null" | "integer";
11
+
12
+ // export interface JSONSchema {
13
+ // type?: string ;
14
+ // $id?: string ;
15
+ // id?: string ;
16
+ // $schema?: string ;
17
+ // $ref?: string ;
18
+ // $anchor?: string ;
19
+ // $defs?: { [key: string]: JSONSchema } ;
20
+ // definitions?: { [key: string]: JSONSchema } ;
21
+ // $comment?: string ;
22
+ // title?: string ;
23
+ // description?: string ;
24
+ // default?: unknown ;
25
+ // examples?: unknown[] ;
26
+ // readOnly?: boolean ;
27
+ // writeOnly?: boolean ;
28
+ // deprecated?: boolean ;
29
+ // allOf?: JSONSchema[] ;
30
+ // anyOf?: JSONSchema[] ;
31
+ // oneOf?: JSONSchema[] ;
32
+ // not?: JSONSchema ;
33
+ // if?: JSONSchema ;
34
+ // then?: JSONSchema ;
35
+ // else?: JSONSchema ;
36
+ // enum?: Array<string | number | boolean | null> ;
37
+ // const?: string | number | boolean | null ;
38
+ // [k: string]: unknown;
39
+
40
+ // /** A special key used as an intermediate representation of extends-style relationships. Omitted as a $ref with additional properties. */
41
+ // // _ref?: JSONSchema;
42
+ // _prefault?: unknown ;
43
+ // }
44
+
45
+ export type _JSONSchema = boolean | JSONSchema;
46
+ export type JSONSchema = {
47
+ [k: string]: unknown;
48
+ $schema?: "https://json-schema.org/draft/2020-12/schema" | "http://json-schema.org/draft-07/schema#";
49
+ $id?: string;
50
+ $anchor?: string;
51
+ $ref?: string;
52
+ $dynamicRef?: string;
53
+ $dynamicAnchor?: string;
54
+ $vocabulary?: Record<string, boolean>;
55
+ $comment?: string;
56
+ $defs?: Record<string, JSONSchema>;
57
+ type?: "object" | "array" | "string" | "number" | "boolean" | "null" | "integer";
58
+ additionalItems?: _JSONSchema;
59
+ unevaluatedItems?: _JSONSchema;
60
+ prefixItems?: _JSONSchema[];
61
+ items?: _JSONSchema | _JSONSchema[];
62
+ contains?: _JSONSchema;
63
+ additionalProperties?: _JSONSchema;
64
+ unevaluatedProperties?: _JSONSchema;
65
+ properties?: Record<string, _JSONSchema>;
66
+ patternProperties?: Record<string, _JSONSchema>;
67
+ dependentSchemas?: Record<string, _JSONSchema>;
68
+ propertyNames?: _JSONSchema;
69
+ if?: _JSONSchema;
70
+ then?: _JSONSchema;
71
+ else?: _JSONSchema;
72
+ allOf?: JSONSchema[];
73
+ anyOf?: JSONSchema[];
74
+ oneOf?: JSONSchema[];
75
+ not?: _JSONSchema;
76
+ multipleOf?: number;
77
+ maximum?: number;
78
+ exclusiveMaximum?: number;
79
+ minimum?: number;
80
+ exclusiveMinimum?: number;
81
+ maxLength?: number;
82
+ minLength?: number;
83
+ pattern?: string;
84
+ maxItems?: number;
85
+ minItems?: number;
86
+ uniqueItems?: boolean;
87
+ maxContains?: number;
88
+ minContains?: number;
89
+ maxProperties?: number;
90
+ minProperties?: number;
91
+ required?: string[];
92
+ dependentRequired?: Record<string, string[]>;
93
+ enum?: Array<string | number | boolean | null>;
94
+ const?: string | number | boolean | null;
95
+
96
+ // metadata
97
+ id?: string;
98
+ title?: string;
99
+ description?: string;
100
+ default?: unknown;
101
+ deprecated?: boolean;
102
+ readOnly?: boolean;
103
+ writeOnly?: boolean;
104
+ examples?: unknown[];
105
+ format?: string;
106
+ contentMediaType?: string;
107
+ contentEncoding?: string;
108
+ contentSchema?: JSONSchema;
109
+
110
+ // internal
111
+ _prefault?: unknown;
112
+ };
113
+
114
+ // for backwards compatibility
115
+ export type BaseSchema = JSONSchema;
116
+
117
+ export interface ObjectSchema extends JSONSchema {
118
+ type: "object";
119
+ }
120
+
121
+ export interface ArraySchema extends JSONSchema {
122
+ type: "array";
123
+ }
124
+
125
+ export interface StringSchema extends JSONSchema {
126
+ type: "string";
127
+ }
128
+
129
+ export interface NumberSchema extends JSONSchema {
130
+ type: "number";
131
+ }
132
+
133
+ export interface IntegerSchema extends JSONSchema {
134
+ type: "integer";
135
+ }
136
+
137
+ export interface BooleanSchema extends JSONSchema {
138
+ type: "boolean";
139
+ }
140
+
141
+ export interface NullSchema extends JSONSchema {
142
+ type: "null";
143
+ }
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/parse.ts ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as core from "./core.js";
2
+ import * as errors from "./errors.js";
3
+ import type * as schemas from "./schemas.js";
4
+ import * as util from "./util.js";
5
+
6
+ export type $ZodErrorClass = { new (issues: errors.$ZodIssue[]): errors.$ZodError };
7
+
8
+ /////////// METHODS ///////////
9
+ export type $Parse = <T extends schemas.$ZodType>(
10
+ schema: T,
11
+ value: unknown,
12
+ _ctx?: schemas.ParseContext<errors.$ZodIssue>,
13
+ _params?: { callee?: util.AnyFunc; Err?: $ZodErrorClass }
14
+ ) => core.output<T>;
15
+
16
+ export const _parse: (_Err: $ZodErrorClass) => $Parse = (_Err) => (schema, value, _ctx, _params) => {
17
+ const ctx: schemas.ParseContextInternal = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
18
+ const result = schema._zod.run({ value, issues: [] }, ctx);
19
+ if (result instanceof Promise) {
20
+ throw new core.$ZodAsyncError();
21
+ }
22
+ if (result.issues.length) {
23
+ const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())));
24
+ util.captureStackTrace(e, _params?.callee);
25
+ throw e;
26
+ }
27
+ return result.value as core.output<typeof schema>;
28
+ };
29
+
30
+ export const parse: $Parse = /* @__PURE__*/ _parse(errors.$ZodRealError);
31
+
32
+ export type $ParseAsync = <T extends schemas.$ZodType>(
33
+ schema: T,
34
+ value: unknown,
35
+ _ctx?: schemas.ParseContext<errors.$ZodIssue>,
36
+ _params?: { callee?: util.AnyFunc; Err?: $ZodErrorClass }
37
+ ) => Promise<core.output<T>>;
38
+
39
+ export const _parseAsync: (_Err: $ZodErrorClass) => $ParseAsync = (_Err) => async (schema, value, _ctx, params) => {
40
+ const ctx: schemas.ParseContextInternal = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
41
+ let result = schema._zod.run({ value, issues: [] }, ctx);
42
+ if (result instanceof Promise) result = await result;
43
+ if (result.issues.length) {
44
+ const e = new (params?.Err ?? _Err)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())));
45
+ util.captureStackTrace(e, params?.callee);
46
+ throw e;
47
+ }
48
+ return result.value as core.output<typeof schema>;
49
+ };
50
+
51
+ export const parseAsync: $ParseAsync = /* @__PURE__*/ _parseAsync(errors.$ZodRealError);
52
+
53
+ export type $SafeParse = <T extends schemas.$ZodType>(
54
+ schema: T,
55
+ value: unknown,
56
+ _ctx?: schemas.ParseContext<errors.$ZodIssue>
57
+ ) => util.SafeParseResult<core.output<T>>;
58
+
59
+ export const _safeParse: (_Err: $ZodErrorClass) => $SafeParse = (_Err) => (schema, value, _ctx) => {
60
+ const ctx: schemas.ParseContextInternal = _ctx ? { ..._ctx, async: false } : { async: false };
61
+ const result = schema._zod.run({ value, issues: [] }, ctx);
62
+ if (result instanceof Promise) {
63
+ throw new core.$ZodAsyncError();
64
+ }
65
+
66
+ return result.issues.length
67
+ ? {
68
+ success: false,
69
+ error: new (_Err ?? errors.$ZodError)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
70
+ }
71
+ : ({ success: true, data: result.value } as any);
72
+ };
73
+ export const safeParse: $SafeParse = /* @__PURE__*/ _safeParse(errors.$ZodRealError);
74
+
75
+ export type $SafeParseAsync = <T extends schemas.$ZodType>(
76
+ schema: T,
77
+ value: unknown,
78
+ _ctx?: schemas.ParseContext<errors.$ZodIssue>
79
+ ) => Promise<util.SafeParseResult<core.output<T>>>;
80
+
81
+ export const _safeParseAsync: (_Err: $ZodErrorClass) => $SafeParseAsync = (_Err) => async (schema, value, _ctx) => {
82
+ const ctx: schemas.ParseContextInternal = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
83
+ let result = schema._zod.run({ value, issues: [] }, ctx);
84
+ if (result instanceof Promise) result = await result;
85
+
86
+ return result.issues.length
87
+ ? {
88
+ success: false,
89
+ error: new _Err(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
90
+ }
91
+ : ({ success: true, data: result.value } as any);
92
+ };
93
+
94
+ export const safeParseAsync: $SafeParseAsync = /* @__PURE__*/ _safeParseAsync(errors.$ZodRealError);
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/regexes.ts ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export const cuid: RegExp = /^[cC][^\s-]{8,}$/;
2
+ export const cuid2: RegExp = /^[0-9a-z]+$/;
3
+ export const ulid: RegExp = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
4
+ export const xid: RegExp = /^[0-9a-vA-V]{20}$/;
5
+ export const ksuid: RegExp = /^[A-Za-z0-9]{27}$/;
6
+ export const nanoid: RegExp = /^[a-zA-Z0-9_-]{21}$/;
7
+
8
+ /** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
9
+ export const duration: RegExp =
10
+ /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
11
+
12
+ /** Implements ISO 8601-2 extensions like explicit +- prefixes, mixing weeks with other units, and fractional/negative components. */
13
+ export const extendedDuration: RegExp =
14
+ /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
15
+
16
+ /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
17
+ export const guid: RegExp = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
18
+
19
+ /** Returns a regex for validating an RFC 4122 UUID.
20
+ *
21
+ * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
22
+ export const uuid = (version?: number | undefined): RegExp => {
23
+ if (!version)
24
+ return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/;
25
+ return new RegExp(
26
+ `^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`
27
+ );
28
+ };
29
+ export const uuid4: RegExp = /*@__PURE__*/ uuid(4);
30
+ export const uuid6: RegExp = /*@__PURE__*/ uuid(6);
31
+ export const uuid7: RegExp = /*@__PURE__*/ uuid(7);
32
+
33
+ /** Practical email validation */
34
+ export const email: RegExp =
35
+ /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
36
+
37
+ /** Equivalent to the HTML5 input[type=email] validation implemented by browsers. Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email */
38
+ export const html5Email: RegExp =
39
+ /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
40
+
41
+ /** The classic emailregex.com regex for RFC 5322-compliant emails */
42
+ export const rfc5322Email =
43
+ /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
44
+
45
+ /** A loose regex that allows Unicode characters, enforces length limits, and that's about it. */
46
+ export const unicodeEmail = /^[^\s@"]{1,64}@[^\s@]{1,255}$/u;
47
+
48
+ export const browserEmail: RegExp =
49
+ /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
50
+ // from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression
51
+
52
+ export const _emoji = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
53
+ export function emoji(): RegExp {
54
+ return new RegExp(_emoji, "u");
55
+ }
56
+
57
+ export const ipv4: RegExp =
58
+ /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
59
+ export const ipv6: RegExp =
60
+ /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/;
61
+
62
+ export const cidrv4: RegExp =
63
+ /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
64
+ export const cidrv6: RegExp =
65
+ /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
66
+
67
+ // https://stackoverflow.com/questions/7860392/determine-if-string-is-in-base64-using-javascript
68
+ export const base64: RegExp = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
69
+ export const base64url: RegExp = /^[A-Za-z0-9_-]*$/;
70
+
71
+ // based on https://stackoverflow.com/questions/106179/regular-expression-to-match-dns-hostname-or-ip-address
72
+ // export const hostname: RegExp =
73
+ // /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)+([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/;
74
+ export const hostname: RegExp = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
75
+ export const domain: RegExp = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
76
+
77
+ // https://blog.stevenlevithan.com/archives/validate-phone-number#r4-3 (regex sans spaces)
78
+ export const e164: RegExp = /^\+(?:[0-9]){6,14}[0-9]$/;
79
+
80
+ // const dateSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
81
+ const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
82
+ export const date: RegExp = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
83
+
84
+ function timeSource(args: { precision?: number | null | undefined }) {
85
+ const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
86
+ const regex =
87
+ typeof args.precision === "number"
88
+ ? args.precision === -1
89
+ ? `${hhmm}`
90
+ : args.precision === 0
91
+ ? `${hhmm}:[0-5]\\d`
92
+ : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}`
93
+ : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
94
+ return regex;
95
+ }
96
+ export function time(args: {
97
+ precision?: number | null;
98
+ // local?: boolean;
99
+ }): RegExp {
100
+ return new RegExp(`^${timeSource(args)}$`);
101
+ }
102
+
103
+ // Adapted from https://stackoverflow.com/a/3143231
104
+ export function datetime(args: {
105
+ precision?: number | null;
106
+ offset?: boolean;
107
+ local?: boolean;
108
+ }): RegExp {
109
+ const time = timeSource({ precision: args.precision });
110
+ const opts = ["Z"];
111
+ if (args.local) opts.push("");
112
+ if (args.offset) opts.push(`([+-]\\d{2}:\\d{2})`);
113
+ const timeRegex = `${time}(?:${opts.join("|")})`;
114
+
115
+ return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
116
+ }
117
+
118
+ export const string = (params?: { minimum?: number | undefined; maximum?: number | undefined }): RegExp => {
119
+ const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
120
+ return new RegExp(`^${regex}$`);
121
+ };
122
+
123
+ export const bigint: RegExp = /^\d+n?$/;
124
+ export const integer: RegExp = /^\d+$/;
125
+ export const number: RegExp = /^-?\d+(?:\.\d+)?/i;
126
+ export const boolean: RegExp = /true|false/i;
127
+ const _null: RegExp = /null/i;
128
+ export { _null as null };
129
+ const _undefined: RegExp = /undefined/i;
130
+ export { _undefined as undefined };
131
+
132
+ // regex for string with no uppercase letters
133
+ export const lowercase: RegExp = /^[^A-Z]*$/;
134
+ // regex for string with no lowercase letters
135
+ export const uppercase: RegExp = /^[^a-z]*$/;
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/registries.ts ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type * as core from "./core.js";
2
+ import type { $ZodType } from "./schemas.js";
3
+
4
+ export const $output: unique symbol = Symbol("ZodOutput");
5
+ export type $output = typeof $output;
6
+ export const $input: unique symbol = Symbol("ZodInput");
7
+ export type $input = typeof $input;
8
+
9
+ export type $replace<Meta, S extends $ZodType> = Meta extends $output
10
+ ? core.output<S>
11
+ : Meta extends $input
12
+ ? core.input<S>
13
+ : Meta extends (infer M)[]
14
+ ? $replace<M, S>[]
15
+ : Meta extends (...args: infer P) => infer R
16
+ ? (
17
+ ...args: {
18
+ [K in keyof P]: $replace<P[K], S>; // tuple
19
+ }
20
+ ) => $replace<R, S>
21
+ : // handle objects
22
+ Meta extends object
23
+ ? { [K in keyof Meta]: $replace<Meta[K], S> }
24
+ : Meta;
25
+
26
+ type MetadataType = Record<string, unknown> | undefined;
27
+ export class $ZodRegistry<Meta extends MetadataType = MetadataType, Schema extends $ZodType = $ZodType> {
28
+ _meta!: Meta;
29
+ _schema!: Schema;
30
+ _map: Map<Schema, $replace<Meta, Schema>> = new Map();
31
+ _idmap: Map<string, Schema> = new Map();
32
+
33
+ add<S extends Schema>(
34
+ schema: S,
35
+ ..._meta: undefined extends Meta ? [$replace<Meta, S>?] : [$replace<Meta, S>]
36
+ ): this {
37
+ const meta: any = _meta[0];
38
+ this._map.set(schema, meta!);
39
+ if (meta && typeof meta === "object" && "id" in meta) {
40
+ if (this._idmap.has(meta.id!)) {
41
+ throw new Error(`ID ${meta.id} already exists in the registry`);
42
+ }
43
+ this._idmap.set(meta.id!, schema);
44
+ }
45
+ return this as any;
46
+ }
47
+
48
+ clear(): this {
49
+ this._map = new Map();
50
+ this._idmap = new Map();
51
+ return this;
52
+ }
53
+
54
+ remove(schema: Schema): this {
55
+ const meta: any = this._map.get(schema);
56
+ if (meta && typeof meta === "object" && "id" in meta) {
57
+ this._idmap.delete(meta.id!);
58
+ }
59
+ this._map.delete(schema);
60
+ return this;
61
+ }
62
+
63
+ get<S extends Schema>(schema: S): $replace<Meta, S> | undefined {
64
+ // return this._map.get(schema) as any;
65
+
66
+ // inherit metadata
67
+ const p = schema._zod.parent as Schema;
68
+ if (p) {
69
+ const pm: any = { ...(this.get(p) ?? {}) };
70
+ delete pm.id; // do not inherit id
71
+ return { ...pm, ...this._map.get(schema) } as any;
72
+ }
73
+ return this._map.get(schema) as any;
74
+ }
75
+
76
+ has(schema: Schema): boolean {
77
+ return this._map.has(schema);
78
+ }
79
+ }
80
+
81
+ export interface JSONSchemaMeta {
82
+ id?: string | undefined;
83
+ title?: string | undefined;
84
+ description?: string | undefined;
85
+ deprecated?: boolean | undefined;
86
+ [k: string]: unknown;
87
+ }
88
+
89
+ export interface GlobalMeta extends JSONSchemaMeta {}
90
+
91
+ // registries
92
+ export function registry<T extends MetadataType = MetadataType, S extends $ZodType = $ZodType>(): $ZodRegistry<T, S> {
93
+ return new $ZodRegistry<T, S>();
94
+ }
95
+
96
+ export const globalRegistry: $ZodRegistry<GlobalMeta> = /*@__PURE__*/ registry<GlobalMeta>();
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/schemas.ts ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/standard-schema.ts ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /** The Standard Schema interface. */
2
+ export interface StandardSchemaV1<Input = unknown, Output = Input> {
3
+ /** The Standard Schema properties. */
4
+ readonly "~standard": StandardSchemaV1.Props<Input, Output>;
5
+ }
6
+
7
+ export declare namespace StandardSchemaV1 {
8
+ /** The Standard Schema properties interface. */
9
+ export interface Props<Input = unknown, Output = Input> {
10
+ /** The version number of the standard. */
11
+ readonly version: 1;
12
+ /** The vendor name of the schema library. */
13
+ readonly vendor: string;
14
+ /** Validates unknown input values. */
15
+ readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
16
+ /** Inferred types associated with the schema. */
17
+ readonly types?: Types<Input, Output> | undefined;
18
+ }
19
+
20
+ /** The result interface of the validate function. */
21
+ export type Result<Output> = SuccessResult<Output> | FailureResult;
22
+
23
+ /** The result interface if validation succeeds. */
24
+ export interface SuccessResult<Output> {
25
+ /** The typed output value. */
26
+ readonly value: Output;
27
+ /** The non-existent issues. */
28
+ readonly issues?: undefined;
29
+ }
30
+
31
+ /** The result interface if validation fails. */
32
+ export interface FailureResult {
33
+ /** The issues of failed validation. */
34
+ readonly issues: ReadonlyArray<Issue>;
35
+ }
36
+
37
+ /** The issue interface of the failure output. */
38
+ export interface Issue {
39
+ /** The error message of the issue. */
40
+ readonly message: string;
41
+ /** The path of the issue, if any. */
42
+ readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
43
+ }
44
+
45
+ /** The path segment interface of the issue. */
46
+ export interface PathSegment {
47
+ /** The key representing a path segment. */
48
+ readonly key: PropertyKey;
49
+ }
50
+
51
+ /** The Standard Schema types interface. */
52
+ export interface Types<Input = unknown, Output = Input> {
53
+ /** The input type of the schema. */
54
+ readonly input: Input;
55
+ /** The output type of the schema. */
56
+ readonly output: Output;
57
+ }
58
+
59
+ /** Infers the input type of a Standard Schema. */
60
+ export type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
61
+
62
+ /** Infers the output type of a Standard Schema. */
63
+ export type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
64
+ }
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/tests/index.test.ts ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+ import * as z from "zod/v3";
3
+
4
+ test("test", () => {
5
+ expect(true).toBe(true);
6
+ });
7
+
8
+ test("test2", () => {
9
+ expect(() => z.string().parse(234)).toThrowErrorMatchingInlineSnapshot(`
10
+ [ZodError: [
11
+ {
12
+ "code": "invalid_type",
13
+ "expected": "string",
14
+ "received": "number",
15
+ "path": [],
16
+ "message": "Expected string, received number"
17
+ }
18
+ ]]
19
+ `);
20
+ });
21
+
22
+ test("async validation", async () => {
23
+ const testTuple = z
24
+ .tuple([z.string().refine(async () => true), z.number().refine(async () => true)])
25
+ .refine(async () => true);
26
+ expectTypeOf<typeof testTuple._output>().toEqualTypeOf<[string, number]>();
27
+
28
+ const val = await testTuple.parseAsync(["asdf", 1234]);
29
+ expect(val).toEqual(val);
30
+
31
+ const r1 = await testTuple.safeParseAsync(["asdf", "asdf"]);
32
+ expect(r1.success).toEqual(false);
33
+ expect(r1.error!).toMatchInlineSnapshot(`
34
+ [ZodError: [
35
+ {
36
+ "code": "invalid_type",
37
+ "expected": "number",
38
+ "received": "string",
39
+ "path": [
40
+ 1
41
+ ],
42
+ "message": "Expected number, received string"
43
+ }
44
+ ]]
45
+ `);
46
+ });
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/tests/locales/be.test.ts ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { describe, expect, it } from "vitest";
2
+ import be from "../../../locales/be.js";
3
+
4
+ describe("Belarusian localization", () => {
5
+ const localeError = be().localeError;
6
+
7
+ describe("pluralization rules", () => {
8
+ for (const { type, cases } of TEST_CASES) {
9
+ describe(`${type} pluralization`, () => {
10
+ for (const { count, expected } of cases) {
11
+ it(`correctly pluralizes ${count} ${type}`, () => {
12
+ const error = localeError({
13
+ code: "too_small",
14
+ minimum: count,
15
+ type: "number",
16
+ inclusive: true,
17
+ path: [],
18
+ origin: type,
19
+ input: count - 1,
20
+ });
21
+ expect(error).toContain(expected);
22
+ });
23
+ }
24
+ });
25
+ }
26
+
27
+ it("handles negative numbers correctly", () => {
28
+ const error = localeError({
29
+ code: "too_small",
30
+ minimum: -2,
31
+ type: "number",
32
+ inclusive: true,
33
+ path: [],
34
+ origin: "array",
35
+ input: -3,
36
+ });
37
+ expect(error).toContain("-2 элементы");
38
+ });
39
+
40
+ it("handles zero correctly", () => {
41
+ const error = localeError({
42
+ code: "too_small",
43
+ minimum: 0,
44
+ type: "number",
45
+ inclusive: true,
46
+ path: [],
47
+ origin: "array",
48
+ input: -1,
49
+ });
50
+ expect(error).toContain("0 элементаў");
51
+ });
52
+
53
+ it("handles bigint values correctly", () => {
54
+ const error = localeError({
55
+ code: "too_small",
56
+ minimum: BigInt(21),
57
+ type: "number",
58
+ inclusive: true,
59
+ path: [],
60
+ origin: "array",
61
+ input: BigInt(20),
62
+ });
63
+ expect(error).toContain("21 элемент");
64
+ });
65
+ });
66
+ });
67
+
68
+ const TEST_CASES = [
69
+ {
70
+ type: "array",
71
+ cases: [
72
+ { count: 1, expected: "1 элемент" },
73
+ { count: 2, expected: "2 элементы" },
74
+ { count: 5, expected: "5 элементаў" },
75
+ { count: 11, expected: "11 элементаў" },
76
+ { count: 21, expected: "21 элемент" },
77
+ { count: 22, expected: "22 элементы" },
78
+ { count: 25, expected: "25 элементаў" },
79
+ { count: 101, expected: "101 элемент" },
80
+ { count: 111, expected: "111 элементаў" },
81
+ ],
82
+ },
83
+ {
84
+ type: "set",
85
+ cases: [
86
+ { count: 1, expected: "1 элемент" },
87
+ { count: 2, expected: "2 элементы" },
88
+ { count: 5, expected: "5 элементаў" },
89
+ { count: 11, expected: "11 элементаў" },
90
+ { count: 21, expected: "21 элемент" },
91
+ { count: 22, expected: "22 элементы" },
92
+ { count: 25, expected: "25 элементаў" },
93
+ { count: 101, expected: "101 элемент" },
94
+ { count: 111, expected: "111 элементаў" },
95
+ ],
96
+ },
97
+ {
98
+ type: "string",
99
+ cases: [
100
+ { count: 1, expected: "1 сімвал" },
101
+ { count: 2, expected: "2 сімвалы" },
102
+ { count: 5, expected: "5 сімвалаў" },
103
+ { count: 11, expected: "11 сімвалаў" },
104
+ { count: 21, expected: "21 сімвал" },
105
+ { count: 22, expected: "22 сімвалы" },
106
+ { count: 25, expected: "25 сімвалаў" },
107
+ ],
108
+ },
109
+ {
110
+ type: "file",
111
+ cases: [
112
+ { count: 0, expected: "0 байтаў" },
113
+ { count: 1, expected: "1 байт" },
114
+ { count: 2, expected: "2 байты" },
115
+ { count: 5, expected: "5 байтаў" },
116
+ { count: 11, expected: "11 байтаў" },
117
+ { count: 21, expected: "21 байт" },
118
+ { count: 22, expected: "22 байты" },
119
+ { count: 25, expected: "25 байтаў" },
120
+ { count: 101, expected: "101 байт" },
121
+ { count: 110, expected: "110 байтаў" },
122
+ ],
123
+ },
124
+ ] as const;
node_modules/@jimp/plugin-crop/node_modules/zod/src/v4/core/tests/locales/en.test.ts ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, test } from "vitest";
2
+ import { parsedType } from "../../../locales/en.js";
3
+
4
+ test("parsedType", () => {
5
+ expect(parsedType("string")).toBe("string");
6
+ expect(parsedType(1)).toBe("number");
7
+ expect(parsedType(true)).toBe("boolean");
8
+ expect(parsedType(null)).toBe("null");
9
+ expect(parsedType(undefined)).toBe("undefined");
10
+ expect(parsedType([])).toBe("array");
11
+ expect(parsedType({})).toBe("object");
12
+ expect(parsedType(new Date())).toBe("Date");
13
+ expect(parsedType(new Map())).toBe("Map");
14
+ expect(parsedType(new Set())).toBe("Set");
15
+ expect(parsedType(new Error())).toBe("Error");
16
+
17
+ const nullPrototype = Object.create(null);
18
+ expect(parsedType(nullPrototype)).toBe("object");
19
+
20
+ const doubleNullPrototype = Object.create(Object.create(null));
21
+ expect(parsedType(doubleNullPrototype)).toBe("object");
22
+ });