zod 3.14.1 → 3.14.2

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
@@ -3,11 +3,11 @@
3
3
  <h1 align="center">Zod</h1>
4
4
  </p>
5
5
  <p align="center">
6
+ <a href="https://github.com/edgedb/edgedb-js/actions"><img src="https://github.com/colinhacks/zod/workflows/test.yml/badge.svg?event=push&branch=master" alt="Zod CI status" /></a>
6
7
  <a href="https://twitter.com/colinhacks" rel="nofollow"><img src="https://img.shields.io/badge/created%20by-@colinhacks-4BBAAB.svg" alt="Created by Colin McDonnell"></a>
7
8
  <a href="https://opensource.org/licenses/MIT" rel="nofollow"><img src="https://img.shields.io/github/license/colinhacks/zod" alt="License"></a>
8
9
  <a href="https://www.npmjs.com/package/zod" rel="nofollow"><img src="https://img.shields.io/npm/dw/zod.svg" alt="npm"></a>
9
10
  <a href="https://www.npmjs.com/package/zod" rel="nofollow"><img src="https://img.shields.io/github/stars/colinhacks/zod" alt="stars"></a>
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
13
 
@@ -17,6 +17,8 @@ const manual = (str) => {
17
17
  return str;
18
18
  };
19
19
  const stringSchema = index_1.z.string();
20
+ const optionalStringSchema = index_1.z.string().optional();
21
+ const optionalNullableStringSchema = index_1.z.string().optional().nullable();
20
22
  suite
21
23
  .add("empty string", () => {
22
24
  stringSchema.parse(empty);
@@ -26,6 +28,15 @@ suite
26
28
  })
27
29
  .add("long string", () => {
28
30
  stringSchema.parse(long);
31
+ })
32
+ .add("optional string", () => {
33
+ optionalStringSchema.parse(long);
34
+ })
35
+ .add("nullable string", () => {
36
+ optionalNullableStringSchema.parse(long);
37
+ })
38
+ .add("nullable (null) string", () => {
39
+ optionalNullableStringSchema.parse(null);
29
40
  })
30
41
  .add("invalid: null", () => {
31
42
  try {
package/lib/index.mjs CHANGED
@@ -2632,12 +2632,7 @@ class ZodOptional extends ZodType {
2632
2632
  if (parsedType === ZodParsedType.undefined) {
2633
2633
  return OK(undefined);
2634
2634
  }
2635
- const { ctx } = this._processInputParams(input);
2636
- return this._def.innerType._parse({
2637
- data: ctx.data,
2638
- path: ctx.path,
2639
- parent: ctx,
2640
- });
2635
+ return this._def.innerType._parse(input);
2641
2636
  }
2642
2637
  unwrap() {
2643
2638
  return this._def.innerType;
@@ -2656,12 +2651,7 @@ class ZodNullable extends ZodType {
2656
2651
  if (parsedType === ZodParsedType.null) {
2657
2652
  return OK(null);
2658
2653
  }
2659
- const { ctx } = this._processInputParams(input);
2660
- return this._def.innerType._parse({
2661
- data: ctx.data,
2662
- path: ctx.path,
2663
- parent: ctx,
2664
- });
2654
+ return this._def.innerType._parse(input);
2665
2655
  }
2666
2656
  unwrap() {
2667
2657
  return this._def.innerType;
package/lib/types.d.ts CHANGED
@@ -441,7 +441,7 @@ export declare class ZodIntersection<T extends ZodTypeAny, U extends ZodTypeAny>
441
441
  static create: <T_1 extends ZodTypeAny, U_1 extends ZodTypeAny>(left: T_1, right: U_1, params?: RawCreateParams) => ZodIntersection<T_1, U_1>;
442
442
  }
443
443
  export declare type ZodTupleItems = [ZodTypeAny, ...ZodTypeAny[]];
444
- export declare type AssertArray<T extends any> = T extends any[] ? T : never;
444
+ export declare type AssertArray<T> = T extends any[] ? T : never;
445
445
  export declare type OutputTypeOfTuple<T extends ZodTupleItems | []> = AssertArray<{
446
446
  [k in keyof T]: T[k] extends ZodType<any, any> ? T[k]["_output"] : never;
447
447
  }>;
@@ -532,11 +532,11 @@ export declare class ZodLazy<T extends ZodTypeAny> extends ZodType<output<T>, Zo
532
532
  _parse(input: ParseInput): ParseReturnType<this["_output"]>;
533
533
  static create: <T_1 extends ZodTypeAny>(getter: () => T_1, params?: RawCreateParams) => ZodLazy<T_1>;
534
534
  }
535
- export interface ZodLiteralDef<T extends any = any> extends ZodTypeDef {
535
+ export interface ZodLiteralDef<T = any> extends ZodTypeDef {
536
536
  value: T;
537
537
  typeName: ZodFirstPartyTypeKind.ZodLiteral;
538
538
  }
539
- export declare class ZodLiteral<T extends any> extends ZodType<T, ZodLiteralDef<T>> {
539
+ export declare class ZodLiteral<T> extends ZodType<T, ZodLiteralDef<T>> {
540
540
  _parse(input: ParseInput): ParseReturnType<this["_output"]>;
541
541
  get value(): T;
542
542
  static create: <T_1 extends Primitive>(value: T_1, params?: RawCreateParams) => ZodLiteral<T_1>;
package/lib/types.js CHANGED
@@ -2251,12 +2251,7 @@ class ZodOptional extends ZodType {
2251
2251
  if (parsedType === parseUtil_1.ZodParsedType.undefined) {
2252
2252
  return (0, parseUtil_1.OK)(undefined);
2253
2253
  }
2254
- const { ctx } = this._processInputParams(input);
2255
- return this._def.innerType._parse({
2256
- data: ctx.data,
2257
- path: ctx.path,
2258
- parent: ctx,
2259
- });
2254
+ return this._def.innerType._parse(input);
2260
2255
  }
2261
2256
  unwrap() {
2262
2257
  return this._def.innerType;
@@ -2276,12 +2271,7 @@ class ZodNullable extends ZodType {
2276
2271
  if (parsedType === parseUtil_1.ZodParsedType.null) {
2277
2272
  return (0, parseUtil_1.OK)(null);
2278
2273
  }
2279
- const { ctx } = this._processInputParams(input);
2280
- return this._def.innerType._parse({
2281
- data: ctx.data,
2282
- path: ctx.path,
2283
- parent: ctx,
2284
- });
2274
+ return this._def.innerType._parse(input);
2285
2275
  }
2286
2276
  unwrap() {
2287
2277
  return this._def.innerType;
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "zod",
3
- "version": "3.14.1",
3
+ "version": "3.14.2",
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",
7
7
  "module": "./lib/index.mjs",
8
+ "dependencies": {},
8
9
  "exports": {
9
10
  ".": {
10
11
  "require": "./lib/index.js",
@@ -41,12 +42,12 @@
41
42
  "inference"
42
43
  ],
43
44
  "scripts": {
44
- "check:format": "prettier --check \"src/**/*.ts\" \"deno/lib/**/*.ts\"",
45
- "fix:format": "prettier --write \"src/**/*.ts\" \"deno/lib/**/*.ts\"",
46
- "check:lint": "eslint --ext .ts ./src",
47
- "fix:lint": "eslint --fix --ext .ts ./src",
48
- "check": "yarn check:lint && yarn check:format",
49
- "fix": "yarn fix:lint && yarn fix:format",
45
+ "prettier:check": "prettier --check src/**/*.ts deno/lib/**/*.ts --no-error-on-unmatched-pattern",
46
+ "prettier:fix": "prettier --write src/**/*.ts deno/lib/**/*.ts --no-error-on-unmatched-pattern",
47
+ "lint:check": "eslint --ext .ts ./src",
48
+ "lint:fix": "eslint --fix --ext .ts ./src",
49
+ "check": "yarn lint:check && yarn prettier:check",
50
+ "fix": "yarn lint:fix && yarn prettier:fix",
50
51
  "clean": "rm -rf lib/* deno/lib/*",
51
52
  "build": "yarn run clean && npm run build:cjs && npm run build:esm && npm run build:deno",
52
53
  "build:deno": "node ./deno/build.mjs",
@@ -67,8 +68,8 @@
67
68
  "@types/benchmark": "^2.1.0",
68
69
  "@types/jest": "^26.0.17",
69
70
  "@types/node": "^14.14.10",
70
- "@typescript-eslint/eslint-plugin": "^4.11.1",
71
- "@typescript-eslint/parser": "^4.11.1",
71
+ "@typescript-eslint/eslint-plugin": "^5.15.0",
72
+ "@typescript-eslint/parser": "^5.15.0",
72
73
  "benchmark": "^2.1.4",
73
74
  "dependency-cruiser": "^9.19.0",
74
75
  "eslint": "^7.15.0",
@@ -89,18 +90,18 @@
89
90
  "ts-jest": "^26.4.4",
90
91
  "ts-node": "^9.1.0",
91
92
  "tslib": "^2.3.1",
92
- "typescript": "^4.5.2"
93
+ "typescript": "^4.6.2"
93
94
  },
94
95
  "husky": {
95
96
  "hooks": {
96
- "pre-commit": "lint-staged && yarn build:deno && git add .",
97
- "pre-push": "lint-staged && yarn build && yarn test && yarn badge"
97
+ "pre-commit": "lint-staged",
98
+ "pre-push": "lint-staged"
98
99
  }
99
100
  },
100
101
  "lint-staged": {
101
102
  "*.ts": [
102
- "yarn fix:lint",
103
- "yarn fix:format"
103
+ "yarn lint:fix",
104
+ "yarn prettier:fix"
104
105
  ]
105
106
  }
106
107
  }