zod 3.25.4 → 3.25.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/v3/types.d.ts +1 -1
- package/dist/commonjs/v4/classic/errors.d.ts +1 -1
- package/dist/commonjs/v4/classic/errors.js +1 -0
- package/dist/commonjs/v4/classic/parse.d.ts +1 -1
- package/dist/commonjs/v4/classic/parse.js +2 -2
- package/dist/commonjs/v4/core/errors.d.ts +1 -1
- package/dist/commonjs/v4/core/errors.js +44 -0
- package/dist/commonjs/v4/core/parse.js +2 -2
- package/dist/esm/v3/types.d.ts +1 -1
- package/dist/esm/v4/classic/errors.d.ts +1 -1
- package/dist/esm/v4/classic/errors.js +1 -0
- package/dist/esm/v4/classic/parse.d.ts +1 -1
- package/dist/esm/v4/classic/parse.js +3 -3
- package/dist/esm/v4/core/errors.d.ts +1 -1
- package/dist/esm/v4/core/errors.js +11 -0
- package/dist/esm/v4/core/parse.js +2 -2
- package/package.json +1 -1
- package/src/v3/types.ts +1 -1
- package/src/v4/classic/errors.ts +2 -1
- package/src/v4/classic/parse.ts +3 -3
- package/src/v4/classic/tests/array.test.ts +42 -46
- package/src/v4/classic/tests/async-refinements.test.ts +14 -18
- package/src/v4/classic/tests/catch.test.ts +10 -12
- package/src/v4/classic/tests/discriminated-unions.test.ts +77 -87
- package/src/v4/classic/tests/enum.test.ts +33 -39
- package/src/v4/classic/tests/error-utils.test.ts +25 -27
- package/src/v4/classic/tests/error.test.ts +115 -128
- package/src/v4/classic/tests/literal.test.ts +10 -12
- package/src/v4/classic/tests/map.test.ts +60 -68
- package/src/v4/classic/tests/nested-refine.test.ts +68 -72
- package/src/v4/classic/tests/nonoptional.test.ts +36 -44
- package/src/v4/classic/tests/number.test.ts +36 -44
- package/src/v4/classic/tests/pipe.test.ts +18 -22
- package/src/v4/classic/tests/preprocess.test.ts +91 -107
- package/src/v4/classic/tests/primitive.test.ts +9 -11
- package/src/v4/classic/tests/record.test.ts +101 -121
- package/src/v4/classic/tests/set.test.ts +30 -36
- package/src/v4/classic/tests/string.test.ts +50 -60
- package/src/v4/classic/tests/template-literal.test.ts +45 -55
- package/src/v4/classic/tests/transform.test.ts +36 -46
- package/src/v4/classic/tests/tuple.test.ts +54 -66
- package/src/v4/core/errors.ts +12 -1
- package/src/v4/core/parse.ts +2 -2
- package/src/v4/core/tests/index.test.ts +42 -1
- package/src/v4/mini/tests/error.test.ts +1 -1
|
@@ -34,35 +34,31 @@ test("enum exhaustiveness", () => {
|
|
|
34
34
|
|
|
35
35
|
expect(schema.safeParse({ Tuna: "asdf", Salmon: "asdf", Trout: "asdf" })).toMatchInlineSnapshot(`
|
|
36
36
|
{
|
|
37
|
-
"error": ZodError
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"Trout",
|
|
43
|
-
],
|
|
44
|
-
"message": "Unrecognized key: "Trout"",
|
|
45
|
-
"path": [],
|
|
46
|
-
},
|
|
37
|
+
"error": [ZodError: [
|
|
38
|
+
{
|
|
39
|
+
"code": "unrecognized_keys",
|
|
40
|
+
"keys": [
|
|
41
|
+
"Trout"
|
|
47
42
|
],
|
|
48
|
-
|
|
43
|
+
"path": [],
|
|
44
|
+
"message": "Unrecognized key: \\"Trout\\""
|
|
45
|
+
}
|
|
46
|
+
]],
|
|
49
47
|
"success": false,
|
|
50
48
|
}
|
|
51
49
|
`);
|
|
52
50
|
expect(schema.safeParse({ Tuna: "asdf" })).toMatchInlineSnapshot(`
|
|
53
51
|
{
|
|
54
|
-
"error": ZodError
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"path": [
|
|
61
|
-
"Salmon",
|
|
62
|
-
],
|
|
63
|
-
},
|
|
52
|
+
"error": [ZodError: [
|
|
53
|
+
{
|
|
54
|
+
"expected": "string",
|
|
55
|
+
"code": "invalid_type",
|
|
56
|
+
"path": [
|
|
57
|
+
"Salmon"
|
|
64
58
|
],
|
|
65
|
-
|
|
59
|
+
"message": "Invalid input: expected string, received undefined"
|
|
60
|
+
}
|
|
61
|
+
]],
|
|
66
62
|
"success": false,
|
|
67
63
|
}
|
|
68
64
|
`);
|
|
@@ -77,35 +73,31 @@ test("literal exhaustiveness", () => {
|
|
|
77
73
|
|
|
78
74
|
expect(schema.safeParse({ Tuna: "asdf", Salmon: "asdf", Trout: "asdf" })).toMatchInlineSnapshot(`
|
|
79
75
|
{
|
|
80
|
-
"error": ZodError
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
"Trout",
|
|
86
|
-
],
|
|
87
|
-
"message": "Unrecognized key: "Trout"",
|
|
88
|
-
"path": [],
|
|
89
|
-
},
|
|
76
|
+
"error": [ZodError: [
|
|
77
|
+
{
|
|
78
|
+
"code": "unrecognized_keys",
|
|
79
|
+
"keys": [
|
|
80
|
+
"Trout"
|
|
90
81
|
],
|
|
91
|
-
|
|
82
|
+
"path": [],
|
|
83
|
+
"message": "Unrecognized key: \\"Trout\\""
|
|
84
|
+
}
|
|
85
|
+
]],
|
|
92
86
|
"success": false,
|
|
93
87
|
}
|
|
94
88
|
`);
|
|
95
89
|
expect(schema.safeParse({ Tuna: "asdf" })).toMatchInlineSnapshot(`
|
|
96
90
|
{
|
|
97
|
-
"error": ZodError
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
"path": [
|
|
104
|
-
"Salmon",
|
|
105
|
-
],
|
|
106
|
-
},
|
|
91
|
+
"error": [ZodError: [
|
|
92
|
+
{
|
|
93
|
+
"expected": "string",
|
|
94
|
+
"code": "invalid_type",
|
|
95
|
+
"path": [
|
|
96
|
+
"Salmon"
|
|
107
97
|
],
|
|
108
|
-
|
|
98
|
+
"message": "Invalid input: expected string, received undefined"
|
|
99
|
+
}
|
|
100
|
+
]],
|
|
109
101
|
"success": false,
|
|
110
102
|
}
|
|
111
103
|
`);
|
|
@@ -120,35 +112,31 @@ test("pipe exhaustiveness", () => {
|
|
|
120
112
|
|
|
121
113
|
expect(schema.safeParse({ Tuna: "asdf", Salmon: "asdf", Trout: "asdf" })).toMatchInlineSnapshot(`
|
|
122
114
|
{
|
|
123
|
-
"error": ZodError
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
"Trout",
|
|
129
|
-
],
|
|
130
|
-
"message": "Unrecognized key: "Trout"",
|
|
131
|
-
"path": [],
|
|
132
|
-
},
|
|
115
|
+
"error": [ZodError: [
|
|
116
|
+
{
|
|
117
|
+
"code": "unrecognized_keys",
|
|
118
|
+
"keys": [
|
|
119
|
+
"Trout"
|
|
133
120
|
],
|
|
134
|
-
|
|
121
|
+
"path": [],
|
|
122
|
+
"message": "Unrecognized key: \\"Trout\\""
|
|
123
|
+
}
|
|
124
|
+
]],
|
|
135
125
|
"success": false,
|
|
136
126
|
}
|
|
137
127
|
`);
|
|
138
128
|
expect(schema.safeParse({ Tuna: "asdf" })).toMatchInlineSnapshot(`
|
|
139
129
|
{
|
|
140
|
-
"error": ZodError
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
"path": [
|
|
147
|
-
"Salmon",
|
|
148
|
-
],
|
|
149
|
-
},
|
|
130
|
+
"error": [ZodError: [
|
|
131
|
+
{
|
|
132
|
+
"expected": "string",
|
|
133
|
+
"code": "invalid_type",
|
|
134
|
+
"path": [
|
|
135
|
+
"Salmon"
|
|
150
136
|
],
|
|
151
|
-
|
|
137
|
+
"message": "Invalid input: expected string, received undefined"
|
|
138
|
+
}
|
|
139
|
+
]],
|
|
152
140
|
"success": false,
|
|
153
141
|
}
|
|
154
142
|
`);
|
|
@@ -163,35 +151,31 @@ test("union exhaustiveness", () => {
|
|
|
163
151
|
|
|
164
152
|
expect(schema.safeParse({ Tuna: "asdf", Salmon: "asdf", Trout: "asdf" })).toMatchInlineSnapshot(`
|
|
165
153
|
{
|
|
166
|
-
"error": ZodError
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
"Trout",
|
|
172
|
-
],
|
|
173
|
-
"message": "Unrecognized key: "Trout"",
|
|
174
|
-
"path": [],
|
|
175
|
-
},
|
|
154
|
+
"error": [ZodError: [
|
|
155
|
+
{
|
|
156
|
+
"code": "unrecognized_keys",
|
|
157
|
+
"keys": [
|
|
158
|
+
"Trout"
|
|
176
159
|
],
|
|
177
|
-
|
|
160
|
+
"path": [],
|
|
161
|
+
"message": "Unrecognized key: \\"Trout\\""
|
|
162
|
+
}
|
|
163
|
+
]],
|
|
178
164
|
"success": false,
|
|
179
165
|
}
|
|
180
166
|
`);
|
|
181
167
|
expect(schema.safeParse({ Tuna: "asdf" })).toMatchInlineSnapshot(`
|
|
182
168
|
{
|
|
183
|
-
"error": ZodError
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
"path": [
|
|
190
|
-
"Salmon",
|
|
191
|
-
],
|
|
192
|
-
},
|
|
169
|
+
"error": [ZodError: [
|
|
170
|
+
{
|
|
171
|
+
"expected": "string",
|
|
172
|
+
"code": "invalid_type",
|
|
173
|
+
"path": [
|
|
174
|
+
"Salmon"
|
|
193
175
|
],
|
|
194
|
-
|
|
176
|
+
"message": "Invalid input: expected string, received undefined"
|
|
177
|
+
}
|
|
178
|
+
]],
|
|
195
179
|
"success": false,
|
|
196
180
|
}
|
|
197
181
|
`);
|
|
@@ -208,16 +192,14 @@ test("string record parse - pass", () => {
|
|
|
208
192
|
expect(schema.safeParse({ asdf: 1234 }).success).toEqual(false);
|
|
209
193
|
expect(schema.safeParse("asdf")).toMatchInlineSnapshot(`
|
|
210
194
|
{
|
|
211
|
-
"error": ZodError
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
],
|
|
220
|
-
},
|
|
195
|
+
"error": [ZodError: [
|
|
196
|
+
{
|
|
197
|
+
"expected": "record",
|
|
198
|
+
"code": "invalid_type",
|
|
199
|
+
"path": [],
|
|
200
|
+
"message": "Invalid input: expected record, received string"
|
|
201
|
+
}
|
|
202
|
+
]],
|
|
221
203
|
"success": false,
|
|
222
204
|
}
|
|
223
205
|
`);
|
|
@@ -325,28 +307,26 @@ test("async parsing", async () => {
|
|
|
325
307
|
const result = await schema.safeParseAsync(data);
|
|
326
308
|
expect(result.success).toEqual(false);
|
|
327
309
|
expect(result.error).toMatchInlineSnapshot(`
|
|
328
|
-
ZodError
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
"
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
"
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
],
|
|
350
|
-
}
|
|
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
|
+
]]
|
|
351
331
|
`);
|
|
352
332
|
});
|
|
@@ -94,16 +94,14 @@ test("throws when a Map is given", () => {
|
|
|
94
94
|
const result = stringSet.safeParse(new Map([]));
|
|
95
95
|
expect(result.success).toEqual(false);
|
|
96
96
|
expect(result.error).toMatchInlineSnapshot(`
|
|
97
|
-
ZodError
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
],
|
|
106
|
-
}
|
|
97
|
+
[ZodError: [
|
|
98
|
+
{
|
|
99
|
+
"expected": "set",
|
|
100
|
+
"code": "invalid_type",
|
|
101
|
+
"path": [],
|
|
102
|
+
"message": "Invalid input: expected set, received Map"
|
|
103
|
+
}
|
|
104
|
+
]]
|
|
107
105
|
`);
|
|
108
106
|
});
|
|
109
107
|
|
|
@@ -112,16 +110,14 @@ test("throws when the given set has invalid input", () => {
|
|
|
112
110
|
expect(result.success).toEqual(false);
|
|
113
111
|
expect(result.error!.issues.length).toEqual(1);
|
|
114
112
|
expect(result.error).toMatchInlineSnapshot(`
|
|
115
|
-
ZodError
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
],
|
|
124
|
-
}
|
|
113
|
+
[ZodError: [
|
|
114
|
+
{
|
|
115
|
+
"expected": "string",
|
|
116
|
+
"code": "invalid_type",
|
|
117
|
+
"path": [],
|
|
118
|
+
"message": "Invalid input: expected string, received symbol"
|
|
119
|
+
}
|
|
120
|
+
]]
|
|
125
121
|
`);
|
|
126
122
|
});
|
|
127
123
|
|
|
@@ -130,22 +126,20 @@ test("throws when the given set has multiple invalid entries", () => {
|
|
|
130
126
|
expect(result.success).toEqual(false);
|
|
131
127
|
expect(result.error!.issues.length).toEqual(2);
|
|
132
128
|
expect(result.error).toMatchInlineSnapshot(`
|
|
133
|
-
ZodError
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
],
|
|
148
|
-
}
|
|
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
|
+
]]
|
|
149
143
|
`);
|
|
150
144
|
});
|
|
151
145
|
|
|
@@ -393,18 +393,16 @@ test("nanoid", () => {
|
|
|
393
393
|
|
|
394
394
|
expect(result.error!.issues[0].message).toEqual("custom error");
|
|
395
395
|
expect(result.error).toMatchInlineSnapshot(`
|
|
396
|
-
ZodError
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
],
|
|
407
|
-
}
|
|
396
|
+
[ZodError: [
|
|
397
|
+
{
|
|
398
|
+
"origin": "string",
|
|
399
|
+
"code": "invalid_format",
|
|
400
|
+
"format": "nanoid",
|
|
401
|
+
"pattern": "/^[a-zA-Z0-9_-]{21}$/",
|
|
402
|
+
"path": [],
|
|
403
|
+
"message": "custom error"
|
|
404
|
+
}
|
|
405
|
+
]]
|
|
408
406
|
`);
|
|
409
407
|
});
|
|
410
408
|
|
|
@@ -416,18 +414,16 @@ test("bad nanoid", () => {
|
|
|
416
414
|
|
|
417
415
|
expect(result.error!.issues[0].message).toEqual("custom error");
|
|
418
416
|
expect(result.error).toMatchInlineSnapshot(`
|
|
419
|
-
ZodError
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
],
|
|
430
|
-
}
|
|
417
|
+
[ZodError: [
|
|
418
|
+
{
|
|
419
|
+
"origin": "string",
|
|
420
|
+
"code": "invalid_format",
|
|
421
|
+
"format": "nanoid",
|
|
422
|
+
"pattern": "/^[a-zA-Z0-9_-]{21}$/",
|
|
423
|
+
"path": [],
|
|
424
|
+
"message": "custom error"
|
|
425
|
+
}
|
|
426
|
+
]]
|
|
431
427
|
`);
|
|
432
428
|
});
|
|
433
429
|
|
|
@@ -501,18 +497,16 @@ test("cuid", () => {
|
|
|
501
497
|
|
|
502
498
|
expect(result.error!.issues[0].message).toEqual("Invalid cuid");
|
|
503
499
|
expect(result.error).toMatchInlineSnapshot(`
|
|
504
|
-
ZodError
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
],
|
|
515
|
-
}
|
|
500
|
+
[ZodError: [
|
|
501
|
+
{
|
|
502
|
+
"origin": "string",
|
|
503
|
+
"code": "invalid_format",
|
|
504
|
+
"format": "cuid",
|
|
505
|
+
"pattern": "/^[cC][^\\\\s-]{8,}$/",
|
|
506
|
+
"path": [],
|
|
507
|
+
"message": "Invalid cuid"
|
|
508
|
+
}
|
|
509
|
+
]]
|
|
516
510
|
`);
|
|
517
511
|
});
|
|
518
512
|
|
|
@@ -552,18 +546,16 @@ test("ulid", () => {
|
|
|
552
546
|
|
|
553
547
|
expect(result.error!.issues[0].message).toEqual("Invalid ULID");
|
|
554
548
|
expect(result.error).toMatchInlineSnapshot(`
|
|
555
|
-
ZodError
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
],
|
|
566
|
-
}
|
|
549
|
+
[ZodError: [
|
|
550
|
+
{
|
|
551
|
+
"origin": "string",
|
|
552
|
+
"code": "invalid_format",
|
|
553
|
+
"format": "ulid",
|
|
554
|
+
"pattern": "/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/",
|
|
555
|
+
"path": [],
|
|
556
|
+
"message": "Invalid ULID"
|
|
557
|
+
}
|
|
558
|
+
]]
|
|
567
559
|
`);
|
|
568
560
|
});
|
|
569
561
|
|
|
@@ -575,18 +567,16 @@ test("xid", () => {
|
|
|
575
567
|
|
|
576
568
|
expect(result.error!.issues[0].message).toEqual("Invalid XID");
|
|
577
569
|
expect(result.error).toMatchInlineSnapshot(`
|
|
578
|
-
ZodError
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
],
|
|
589
|
-
}
|
|
570
|
+
[ZodError: [
|
|
571
|
+
{
|
|
572
|
+
"origin": "string",
|
|
573
|
+
"code": "invalid_format",
|
|
574
|
+
"format": "xid",
|
|
575
|
+
"pattern": "/^[0-9a-vA-V]{20}$/",
|
|
576
|
+
"path": [],
|
|
577
|
+
"message": "Invalid XID"
|
|
578
|
+
}
|
|
579
|
+
]]
|
|
590
580
|
`);
|
|
591
581
|
});
|
|
592
582
|
|
|
@@ -686,82 +686,72 @@ test("template literal parsing - failure - complex cases", () => {
|
|
|
686
686
|
test("template literal parsing - failure - issue format", () => {
|
|
687
687
|
expect(anotherNull.safeParse("1null")).toMatchInlineSnapshot(`
|
|
688
688
|
{
|
|
689
|
-
"error": ZodError
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
],
|
|
699
|
-
},
|
|
689
|
+
"error": [ZodError: [
|
|
690
|
+
{
|
|
691
|
+
"code": "invalid_format",
|
|
692
|
+
"format": "template_literal",
|
|
693
|
+
"pattern": "^null$",
|
|
694
|
+
"path": [],
|
|
695
|
+
"message": "Invalid input"
|
|
696
|
+
}
|
|
697
|
+
]],
|
|
700
698
|
"success": false,
|
|
701
699
|
}
|
|
702
700
|
`);
|
|
703
701
|
expect(cuidZZZ.safeParse("1cjld2cyuq0000t3rmniod1foyZZZ")).toMatchInlineSnapshot(`
|
|
704
702
|
{
|
|
705
|
-
"error": ZodError
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
],
|
|
715
|
-
},
|
|
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
|
+
]],
|
|
716
712
|
"success": false,
|
|
717
713
|
}
|
|
718
714
|
`);
|
|
719
715
|
expect(stringMin5Max10.safeParse("1234")).toMatchInlineSnapshot(`
|
|
720
716
|
{
|
|
721
|
-
"error": ZodError
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
],
|
|
731
|
-
},
|
|
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
|
+
]],
|
|
732
726
|
"success": false,
|
|
733
727
|
}
|
|
734
728
|
`);
|
|
735
729
|
expect(connectionString.safeParse("mongodb://host:1234/defaultauthdb?authSourceadmin")).toMatchInlineSnapshot(`
|
|
736
730
|
{
|
|
737
|
-
"error": ZodError
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
],
|
|
747
|
-
},
|
|
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
|
+
]],
|
|
748
740
|
"success": false,
|
|
749
741
|
}
|
|
750
742
|
`);
|
|
751
743
|
|
|
752
744
|
expect(stringStartsWithMax5.safeParse("1hell")).toMatchInlineSnapshot(`
|
|
753
745
|
{
|
|
754
|
-
"error": ZodError
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
],
|
|
764
|
-
},
|
|
746
|
+
"error": [ZodError: [
|
|
747
|
+
{
|
|
748
|
+
"code": "invalid_format",
|
|
749
|
+
"format": "template_literal",
|
|
750
|
+
"pattern": "^hello.*$",
|
|
751
|
+
"path": [],
|
|
752
|
+
"message": "Invalid input"
|
|
753
|
+
}
|
|
754
|
+
]],
|
|
765
755
|
"success": false,
|
|
766
756
|
}
|
|
767
757
|
`);
|