zod 3.13.2 → 3.13.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 CHANGED
@@ -10,23 +10,19 @@
10
10
  <a href="./src/__tests__" rel="nofollow"><img src="./coverage.svg" alt="coverage"></a>
11
11
  <a href="https://discord.gg/KaSRdyX2vc" rel="nofollow"><img src="https://img.shields.io/discord/893487829802418277?label=Discord&logo=discord&logoColor=white" alt="discord server"></a>
12
12
  </p>
13
- <p align="center">
14
- by <a href="https://twitter.com/colinhacks">@colinhacks</a>
15
- </p>
16
-
17
- > Hi! Colin here, creator of Zod. I hope you find it easy to use and powerful enough for all your use cases. If you have any issues or suggestions, please [open an issue](https://github.com/colinhacks/zod/issues/new)!
18
- >
19
- > If you like typesafety, check out my other library [tRPC](https://trpc.io). It works in concert with Zod to provide a seamless way to build end-to-end typesafe APIs without GraphQL or code generation — just TypeScript.
20
- >
21
- > Colin (AKA [@colinhacks](https://twitter.com/colinhacks))
22
13
 
23
- <h3 align="center">
24
- <a href="https://discord.gg/RcG33DQJdf">💬 Chat on Discord</a>
25
- ·
26
- <a href="https://zod.js.org/">📝 Explore the Docs</a>
27
- ·
28
- <a href="https://www.npmjs.com/package/zod">✨ Install Zod</a>
29
- </h3>
14
+ <div align="center">
15
+ <a href="https://discord.gg/RcG33DQJdf">Discord</a>
16
+ <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
17
+ <a href="https://www.npmjs.com/package/zod">NPM</a>
18
+ <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
19
+ <a href="https://github.com/colinhacks/zod/issues/new">Issues</a>
20
+ <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
21
+ <a href="https://twitter.com/colinhacks">@colinhacks</a>
22
+ <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
23
+ <a href="https://trpc.io">tRPC</a>
24
+ <br />
25
+ </div>
30
26
 
31
27
  <br/>
32
28
 
@@ -34,6 +30,10 @@ These docs have been translated into [Chinese](./README_ZH.md).
34
30
 
35
31
  # Table of contents
36
32
 
33
+ The full documentation is available both on the [official documentation site](https://zod.js.org/) (recommended) and in `README.md`.
34
+
35
+ ### Go to [zod.js.org](https://zod.js.org) >>
36
+
37
37
  - [What is Zod](#what-is-zod)
38
38
  - [Installation](#installation)
39
39
  - [Ecosystem](#ecosystem)
@@ -427,26 +427,25 @@ const isActive = z.boolean({
427
427
  ```
428
428
 
429
429
  ## Dates
430
+
430
431
  z.date() accepts a date, not a date string
432
+
431
433
  ```ts
432
- z.date().safeParse( new Date() ) // success: true
433
- z.date().safeParse( '2022-01-12T00:00:00.000Z' ) // success: false
434
+ z.date().safeParse(new Date()); // success: true
435
+ z.date().safeParse("2022-01-12T00:00:00.000Z"); // success: false
434
436
  ```
435
437
 
436
438
  To allow for dates or date strings, you can use preprocess
439
+
437
440
  ```ts
438
- const dateSchema = z.preprocess(
439
- arg => {
440
- if ( typeof arg == 'string' || arg instanceof Date )
441
- return new Date( arg )
442
- },
443
- z.date()
444
- )
445
- type DateSchema = z.infer<typeof dateSchema>
441
+ const dateSchema = z.preprocess((arg) => {
442
+ if (typeof arg == "string" || arg instanceof Date) return new Date(arg);
443
+ }, z.date());
444
+ type DateSchema = z.infer<typeof dateSchema>;
446
445
  // type DateSchema = Date
447
446
 
448
- dateSchema.safeParse( new Date( '1/12/22' ) ) // success: true
449
- dateSchema.safeParse( '2022-01-12T00:00:00.000Z' ) // success: true
447
+ dateSchema.safeParse(new Date("1/12/22")); // success: true
448
+ dateSchema.safeParse("2022-01-12T00:00:00.000Z"); // success: true
450
449
  ```
451
450
 
452
451
  ## Zod enums
package/lib/external.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
package/lib/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
package/lib/index.mjs CHANGED
@@ -3412,5 +3412,4 @@ var mod = /*#__PURE__*/Object.freeze({
3412
3412
  setErrorMap: setErrorMap
3413
3413
  });
3414
3414
 
3415
- export default mod;
3416
- export { DIRTY, EMPTY_PATH, INVALID, OK, ParseStatus, ZodType as Schema, ZodAny, ZodArray, ZodBigInt, ZodBoolean, ZodDate, ZodDefault, ZodDiscriminatedUnion, ZodEffects, ZodEnum, ZodError, ZodFirstPartyTypeKind, ZodFunction, ZodIntersection, ZodIssueCode, ZodLazy, ZodLiteral, ZodMap, ZodNaN, ZodNativeEnum, ZodNever, ZodNull, ZodNullable, ZodNumber, ZodObject, ZodOptional, ZodParsedType, ZodPromise, ZodRecord, ZodType as ZodSchema, ZodSet, ZodString, ZodEffects as ZodTransformer, ZodTuple, ZodType, ZodUndefined, ZodUnion, ZodUnknown, ZodVoid, addIssueToContext, anyType as any, arrayType as array, bigIntType as bigint, booleanType as boolean, custom, dateType as date, defaultErrorMap, discriminatedUnionType as discriminatedUnion, effectsType as effect, enumType as enum, functionType as function, getParsedType, instanceOfType as instanceof, intersectionType as intersection, isAborted, isAsync, isDirty, isValid, late, lazyType as lazy, literalType as literal, makeIssue, mapType as map, nanType as nan, nativeEnumType as nativeEnum, neverType as never, nullType as null, nullableType as nullable, numberType as number, objectType as object, objectUtil, oboolean, onumber, optionalType as optional, ostring, overrideErrorMap, preprocessType as preprocess, promiseType as promise, quotelessJson, recordType as record, setType as set, setErrorMap, strictObjectType as strictObject, stringType as string, effectsType as transformer, tupleType as tuple, undefinedType as undefined, unionType as union, unknownType as unknown, voidType as void, mod as z };
3415
+ export { DIRTY, EMPTY_PATH, INVALID, OK, ParseStatus, ZodType as Schema, ZodAny, ZodArray, ZodBigInt, ZodBoolean, ZodDate, ZodDefault, ZodDiscriminatedUnion, ZodEffects, ZodEnum, ZodError, ZodFirstPartyTypeKind, ZodFunction, ZodIntersection, ZodIssueCode, ZodLazy, ZodLiteral, ZodMap, ZodNaN, ZodNativeEnum, ZodNever, ZodNull, ZodNullable, ZodNumber, ZodObject, ZodOptional, ZodParsedType, ZodPromise, ZodRecord, ZodType as ZodSchema, ZodSet, ZodString, ZodEffects as ZodTransformer, ZodTuple, ZodType, ZodUndefined, ZodUnion, ZodUnknown, ZodVoid, addIssueToContext, anyType as any, arrayType as array, bigIntType as bigint, booleanType as boolean, custom, dateType as date, mod as default, defaultErrorMap, discriminatedUnionType as discriminatedUnion, effectsType as effect, enumType as enum, functionType as function, getParsedType, instanceOfType as instanceof, intersectionType as intersection, isAborted, isAsync, isDirty, isValid, late, lazyType as lazy, literalType as literal, makeIssue, mapType as map, nanType as nan, nativeEnumType as nativeEnum, neverType as never, nullType as null, nullableType as nullable, numberType as number, objectType as object, objectUtil, oboolean, onumber, optionalType as optional, ostring, overrideErrorMap, preprocessType as preprocess, promiseType as promise, quotelessJson, recordType as record, setType as set, setErrorMap, strictObjectType as strictObject, stringType as string, effectsType as transformer, tupleType as tuple, undefinedType as undefined, unionType as union, unknownType as unknown, voidType as void, mod as z };
package/lib/types.d.ts CHANGED
@@ -465,7 +465,8 @@ export interface ZodRecordDef<Key extends KeySchema = ZodString, Value extends Z
465
465
  typeName: ZodFirstPartyTypeKind.ZodRecord;
466
466
  }
467
467
  declare type KeySchema = ZodType<string | number | symbol, any, any>;
468
- export declare class ZodRecord<Key extends KeySchema = ZodString, Value extends ZodTypeAny = ZodTypeAny> extends ZodType<Partial<Record<Key["_output"], Value["_output"]>>, ZodRecordDef<Key, Value>, Partial<Record<Key["_input"], Value["_input"]>>> {
468
+ declare type RecordType<K extends string | number | symbol, V> = [string] extends [K] ? Record<K, V> : [number] extends [K] ? Record<K, V> : [symbol] extends [K] ? Record<K, V> : Partial<Record<K, V>>;
469
+ export declare class ZodRecord<Key extends KeySchema = ZodString, Value extends ZodTypeAny = ZodTypeAny> extends ZodType<RecordType<Key["_output"], Value["_output"]>, ZodRecordDef<Key, Value>, RecordType<Key["_input"], Value["_input"]>> {
469
470
  get keySchema(): Key;
470
471
  get valueSchema(): Value;
471
472
  _parse(input: ParseInput): ParseReturnType<this["_output"]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zod",
3
- "version": "3.13.2",
3
+ "version": "3.13.3",
4
4
  "description": "TypeScript-first schema declaration and validation library with static type inference",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -101,6 +101,5 @@
101
101
  "yarn fix:lint",
102
102
  "yarn fix:format"
103
103
  ]
104
- },
105
- "dependencies": {}
104
+ }
106
105
  }