zod 3.22.2 → 3.22.3
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/README.md +30 -45
- package/lib/index.mjs +1 -1
- package/lib/index.umd.js +1 -1
- package/lib/types.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -185,23 +185,19 @@ Sponsorship at any level is appreciated and encouraged. For individual developer
|
|
|
185
185
|
<table>
|
|
186
186
|
<tr>
|
|
187
187
|
<td align="center">
|
|
188
|
-
<a href="https://
|
|
189
|
-
<img src="https://avatars.githubusercontent.com/u/
|
|
188
|
+
<a href="https://speakeasyapi.dev/">
|
|
189
|
+
<img src="https://avatars.githubusercontent.com/u/91446104?s=200&v=4" width="200px;" alt="Speakeasy API" />
|
|
190
190
|
</a>
|
|
191
191
|
<br />
|
|
192
|
-
<b>
|
|
192
|
+
<b>Speakeasy</b>
|
|
193
193
|
<br />
|
|
194
|
-
<a href="https://
|
|
194
|
+
<a href="https://speakeasyapi.dev/">speakeasyapi.dev</a>
|
|
195
195
|
<br />
|
|
196
|
-
<p width="200px">
|
|
197
|
-
Astro is a new kind of static <br/>
|
|
198
|
-
site builder for the modern web. <br/>
|
|
199
|
-
Powerful developer experience meets <br/>
|
|
200
|
-
lightweight output.</p>
|
|
196
|
+
<p width="200px">SDKs, Terraform, Docs.<br/>Your API made enterprise-ready.</p>
|
|
201
197
|
</td>
|
|
202
198
|
<td align="center">
|
|
203
199
|
<a href="https://glow.app/">
|
|
204
|
-
<img src="https://i.imgur.com/R0R43S2.jpg" width="200px;" alt="" />
|
|
200
|
+
<img src="https://i.imgur.com/R0R43S2.jpg" width="200px;" alt="Glow Wallet" />
|
|
205
201
|
</a>
|
|
206
202
|
<br />
|
|
207
203
|
<b>Glow Wallet</b>
|
|
@@ -223,17 +219,6 @@ Sponsorship at any level is appreciated and encouraged. For individual developer
|
|
|
223
219
|
<br />
|
|
224
220
|
<a href="https://deletype.com">deletype.com</a>
|
|
225
221
|
</td>
|
|
226
|
-
<td align="center">
|
|
227
|
-
<a href="https://proxy.com/">
|
|
228
|
-
<img src="https://avatars.githubusercontent.com/u/14321439?s=200&v=4" width="200px;" alt="Proxy logo" />
|
|
229
|
-
</a>
|
|
230
|
-
<br />
|
|
231
|
-
<b>Proxy</b>
|
|
232
|
-
<br />
|
|
233
|
-
<a href="https://proxy.com">proxy.com</a>
|
|
234
|
-
</td>
|
|
235
|
-
</tr>
|
|
236
|
-
<tr>
|
|
237
222
|
<td align="center">
|
|
238
223
|
<a href="https://trigger.dev/">
|
|
239
224
|
<img src="https://avatars.githubusercontent.com/u/95297378?s=200&v=4" width="200px;" alt="Trigger.dev logo" />
|
|
@@ -245,19 +230,19 @@ Sponsorship at any level is appreciated and encouraged. For individual developer
|
|
|
245
230
|
<br/>
|
|
246
231
|
<p>Effortless automation for developers.</p>
|
|
247
232
|
</td>
|
|
233
|
+
</tr>
|
|
234
|
+
<tr>
|
|
248
235
|
<td align="center">
|
|
249
|
-
<a href="https://transloadit.com
|
|
236
|
+
<a href="https://transloadit.com/?utm_source=zod&utm_medium=referral&utm_campaign=sponsorship&utm_content=github">
|
|
250
237
|
<img src="https://avatars.githubusercontent.com/u/125754?s=200&v=4" width="200px;" alt="Transloadit logo" />
|
|
251
238
|
</a>
|
|
252
239
|
<br />
|
|
253
240
|
<b>Transloadit</b>
|
|
254
241
|
<br />
|
|
255
|
-
<a href="https://transloadit.com">transloadit.com</a>
|
|
242
|
+
<a href="https://transloadit.com/?utm_source=zod&utm_medium=referral&utm_campaign=sponsorship&utm_content=github">transloadit.com</a>
|
|
256
243
|
<br/>
|
|
257
244
|
<p>Simple file processing for developers.</p>
|
|
258
245
|
</td>
|
|
259
|
-
</tr>
|
|
260
|
-
<tr>
|
|
261
246
|
<td align="center">
|
|
262
247
|
<a href="https://infisical.com">
|
|
263
248
|
<img src="https://avatars.githubusercontent.com/u/107880645?s=200&v=4" width="200px;" alt="Infisical logo" />
|
|
@@ -270,13 +255,25 @@ Sponsorship at any level is appreciated and encouraged. For individual developer
|
|
|
270
255
|
<p>Open-source platform for secret<br/>management: sync secrets across your<br/>team/infrastructure and prevent secret leaks.</p>
|
|
271
256
|
</td>
|
|
272
257
|
</tr>
|
|
258
|
+
<tr>
|
|
259
|
+
<td align="center">
|
|
260
|
+
<a href="https://whop.com/">
|
|
261
|
+
<img src="https://avatars.githubusercontent.com/u/91036480?s=200&v=4" width="200px;" alt="Whop logo" />
|
|
262
|
+
</a>
|
|
263
|
+
<br />
|
|
264
|
+
<b>Whop</b>
|
|
265
|
+
<br />
|
|
266
|
+
<a href="https://whop.com/">whop.com</a>
|
|
267
|
+
<br />
|
|
268
|
+
<p width="200px">A marketplace for really cool internet products.</p>
|
|
269
|
+
</td>
|
|
273
270
|
</table>
|
|
274
271
|
|
|
275
272
|
#### Silver
|
|
276
273
|
|
|
277
274
|
<table>
|
|
278
275
|
<tr>
|
|
279
|
-
|
|
276
|
+
<td align="center" colspan="2">
|
|
280
277
|
<a href="https://www.numeric.io">
|
|
281
278
|
<img src="https://i.imgur.com/kTiLtZt.png" width="250px;" alt="Numeric logo" />
|
|
282
279
|
</a>
|
|
@@ -286,17 +283,6 @@ Sponsorship at any level is appreciated and encouraged. For individual developer
|
|
|
286
283
|
<a href="https://www.numeric.io">numeric.io</a>
|
|
287
284
|
</td>
|
|
288
285
|
<td align="center">
|
|
289
|
-
<a href="https://snaplet.dev">
|
|
290
|
-
<img src="https://avatars.githubusercontent.com/u/69029941?s=200&v=4" width="150px;" alt="Snaplet logo" />
|
|
291
|
-
</a>
|
|
292
|
-
<br />
|
|
293
|
-
<b>Snaplet</b>
|
|
294
|
-
<br />
|
|
295
|
-
<a href="https://snaplet.dev">snaplet.dev</a>
|
|
296
|
-
</td>
|
|
297
|
-
</tr>
|
|
298
|
-
<tr>
|
|
299
|
-
<td align="center">
|
|
300
286
|
<a href="https://marcatopartners.com/">
|
|
301
287
|
<img src="https://avatars.githubusercontent.com/u/84106192?s=200&v=4" width="150px;" alt="Marcato Partners" />
|
|
302
288
|
</a>
|
|
@@ -305,7 +291,9 @@ Sponsorship at any level is appreciated and encouraged. For individual developer
|
|
|
305
291
|
<br />
|
|
306
292
|
<a href="https://marcatopartners.com/">marcatopartners.com</a>
|
|
307
293
|
</td>
|
|
308
|
-
|
|
294
|
+
</tr>
|
|
295
|
+
<tr>
|
|
296
|
+
<td align="center">
|
|
309
297
|
<a href="https://interval.com">
|
|
310
298
|
<img src="https://avatars.githubusercontent.com/u/67802063?s=200&v=4" width="150px;" alt="" />
|
|
311
299
|
</a>
|
|
@@ -323,8 +311,6 @@ Sponsorship at any level is appreciated and encouraged. For individual developer
|
|
|
323
311
|
<br />
|
|
324
312
|
<a href="https://seasoned.cc">seasoned.cc</a>
|
|
325
313
|
</td>
|
|
326
|
-
</tr>
|
|
327
|
-
<tr>
|
|
328
314
|
<td align="center">
|
|
329
315
|
<a href="https://www.bamboocreative.nz/">
|
|
330
316
|
<img src="https://avatars.githubusercontent.com/u/41406870?v=4" width="150px;" alt="Bamboo Creative logo" />
|
|
@@ -721,7 +707,7 @@ z.string().regex(regex);
|
|
|
721
707
|
z.string().includes(string);
|
|
722
708
|
z.string().startsWith(string);
|
|
723
709
|
z.string().endsWith(string);
|
|
724
|
-
z.string().datetime(); //
|
|
710
|
+
z.string().datetime(); // ISO 8601; default is without UTC offset, see below for options
|
|
725
711
|
z.string().ip(); // defaults to IPv4 and IPv6, see below for options
|
|
726
712
|
|
|
727
713
|
// transformations
|
|
@@ -760,7 +746,7 @@ z.string().ip({ message: "Invalid IP address" });
|
|
|
760
746
|
|
|
761
747
|
### ISO datetimes
|
|
762
748
|
|
|
763
|
-
The `z.string().datetime()` method
|
|
749
|
+
The `z.string().datetime()` method enforces ISO 8601; default is no timezone offsets and arbitrary sub-second decimal precision.
|
|
764
750
|
|
|
765
751
|
```ts
|
|
766
752
|
const datetime = z.string().datetime();
|
|
@@ -1893,7 +1879,7 @@ You can create a Zod schema for any TypeScript type by using `z.custom()`. This
|
|
|
1893
1879
|
|
|
1894
1880
|
```ts
|
|
1895
1881
|
const px = z.custom<`${number}px`>((val) => {
|
|
1896
|
-
return /^\d+px$/.test(val
|
|
1882
|
+
return typeof val === "string" ? /^\d+px$/.test(val) : false;
|
|
1897
1883
|
});
|
|
1898
1884
|
|
|
1899
1885
|
type px = z.infer<typeof px>; // `${number}px`
|
|
@@ -2825,10 +2811,9 @@ This more declarative API makes schema definitions vastly more concise.
|
|
|
2825
2811
|
|
|
2826
2812
|
[https://github.com/pelotom/runtypes](https://github.com/pelotom/runtypes)
|
|
2827
2813
|
|
|
2828
|
-
Good type inference support.
|
|
2814
|
+
Good type inference support.
|
|
2829
2815
|
|
|
2830
2816
|
- Supports "pattern matching": computed properties that distribute over unions
|
|
2831
|
-
- Supports readonly types
|
|
2832
2817
|
- Missing object methods: (deepPartial, merge)
|
|
2833
2818
|
- Missing nonempty arrays with proper typing (`[T, ...T[]]`)
|
|
2834
2819
|
- Missing promise schemas
|
package/lib/index.mjs
CHANGED
|
@@ -832,7 +832,7 @@ const uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-
|
|
|
832
832
|
// /^[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])?)*$/;
|
|
833
833
|
// const emailRegex =
|
|
834
834
|
// /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/i;
|
|
835
|
-
const emailRegex = /^([A-Z0-9_
|
|
835
|
+
const emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
|
836
836
|
// const emailRegex =
|
|
837
837
|
// /^[a-z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-z0-9-]+(?:\.[a-z0-9\-]+)*$/i;
|
|
838
838
|
// from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression
|
package/lib/index.umd.js
CHANGED
|
@@ -838,7 +838,7 @@
|
|
|
838
838
|
// /^[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])?)*$/;
|
|
839
839
|
// const emailRegex =
|
|
840
840
|
// /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/i;
|
|
841
|
-
const emailRegex = /^([A-Z0-9_
|
|
841
|
+
const emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
|
842
842
|
// const emailRegex =
|
|
843
843
|
// /^[a-z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-z0-9-]+(?:\.[a-z0-9\-]+)*$/i;
|
|
844
844
|
// from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression
|
package/lib/types.js
CHANGED
|
@@ -325,7 +325,7 @@ const cuidRegex = /^c[^\s-]{8,}$/i;
|
|
|
325
325
|
const cuid2Regex = /^[a-z][a-z0-9]*$/;
|
|
326
326
|
const ulidRegex = /[0-9A-HJKMNP-TV-Z]{26}/;
|
|
327
327
|
const uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
|
|
328
|
-
const emailRegex = /^([A-Z0-9_
|
|
328
|
+
const emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
|
329
329
|
const emojiRegex = /^(\p{Extended_Pictographic}|\p{Emoji_Component})+$/u;
|
|
330
330
|
const ipv4Regex = /^(((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}))$/;
|
|
331
331
|
const ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-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})))$/;
|