zod 4.2.0-canary.20250828T181323 → 4.2.0-canary.20250911T044505

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.
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "module",
3
+ "main": "./index.cjs",
4
+ "module": "./index.js",
5
+ "types": "./index.d.cts"
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "module",
3
+ "main": "./index.cjs",
4
+ "module": "./index.js",
5
+ "types": "./index.d.cts"
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zod",
3
- "version": "4.2.0-canary.20250828T181323",
3
+ "version": "4.2.0-canary.20250911T044505",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Colin McDonnell <zod@colinhacks.com>",
@@ -18,7 +18,8 @@
18
18
  "**/*.cjs",
19
19
  "**/*.d.ts",
20
20
  "**/*.d.mts",
21
- "**/*.d.cts"
21
+ "**/*.d.cts",
22
+ "**/package.json"
22
23
  ],
23
24
  "keywords": [
24
25
  "typescript",
@@ -126,7 +127,7 @@
126
127
  "scripts": {
127
128
  "clean": "git clean -xdf . -e node_modules",
128
129
  "build": "zshy --project tsconfig.build.json",
129
- "postbuild": "pnpm biome check --write .",
130
+ "postbuild": "tsx ../../scripts/write-stub-package-jsons.ts && pnpm biome check --write .",
130
131
  "test:watch": "pnpm vitest",
131
132
  "test": "pnpm vitest run",
132
133
  "prepublishOnly": "tsx ../../scripts/check-versions.ts"
@@ -89,7 +89,7 @@ export interface ZodType<
89
89
  nonoptional(params?: string | core.$ZodNonOptionalParams): ZodNonOptional<this>;
90
90
  nullable(): ZodNullable<this>;
91
91
  nullish(): ZodOptional<ZodNullable<this>>;
92
- default(def: core.output<this>): ZodDefault<this>;
92
+ default(def: util.NoUndefined<core.output<this>>): ZodDefault<this>;
93
93
  default(def: () => util.NoUndefined<core.output<this>>): ZodDefault<this>;
94
94
  prefault(def: () => core.input<this>): ZodPrefault<this>;
95
95
  prefault(def: core.input<this>): ZodPrefault<this>;
@@ -1931,8 +1931,8 @@ export function codec<const A extends core.SomeType, B extends core.SomeType = c
1931
1931
  in_: A,
1932
1932
  out: B,
1933
1933
  params: {
1934
- decode: (value: core.output<A>, payload: core.ParsePayload<core.output<A>>) => core.input<B>;
1935
- encode: (value: core.input<B>, payload: core.ParsePayload<core.input<B>>) => core.output<A>;
1934
+ decode: (value: core.output<A>, payload: core.ParsePayload<core.output<A>>) => core.util.MaybeAsync<core.input<B>>;
1935
+ encode: (value: core.input<B>, payload: core.ParsePayload<core.input<B>>) => core.util.MaybeAsync<core.output<A>>;
1936
1936
  }
1937
1937
  ): ZodCodec<A, B> {
1938
1938
  return new ZodCodec({
@@ -414,11 +414,11 @@ test("codec type enforcement - correct encode/decode signatures", () => {
414
414
  encode: (value: number) => String(value), // core.input<B> -> core.output<A>
415
415
  });
416
416
 
417
- // These should compile without errors - correct types
418
- expectTypeOf<(value: string, payload: z.core.ParsePayload<string>) => number>(
417
+ // These should compile without errors - correct types (async support)
418
+ expectTypeOf<(value: string, payload: z.core.ParsePayload<string>) => z.core.util.MaybeAsync<number>>(
419
419
  stringToNumberCodec.def.transform
420
420
  ).toBeFunction();
421
- expectTypeOf<(value: number, payload: z.core.ParsePayload<number>) => string>(
421
+ expectTypeOf<(value: number, payload: z.core.ParsePayload<number>) => z.core.util.MaybeAsync<string>>(
422
422
  stringToNumberCodec.def.reverseTransform
423
423
  ).toBeFunction();
424
424
 
@@ -468,11 +468,11 @@ test("codec type enforcement - complex types", () => {
468
468
  }
469
469
  );
470
470
 
471
- // Verify correct types are inferred
472
- expectTypeOf<(input: UserInput, payload: z.core.ParsePayload<UserInput>) => User>(
471
+ // Verify correct types are inferred (async support)
472
+ expectTypeOf<(input: UserInput, payload: z.core.ParsePayload<UserInput>) => z.core.util.MaybeAsync<User>>(
473
473
  userCodec.def.transform
474
474
  ).toBeFunction();
475
- expectTypeOf<(user: User, payload: z.core.ParsePayload<User>) => UserInput>(
475
+ expectTypeOf<(user: User, payload: z.core.ParsePayload<User>) => z.core.util.MaybeAsync<UserInput>>(
476
476
  userCodec.def.reverseTransform
477
477
  ).toBeFunction();
478
478
 
@@ -530,3 +530,33 @@ test("codex with overwrites", () => {
530
530
  }
531
531
  `);
532
532
  });
533
+
534
+ test("async codec functionality", async () => {
535
+ // Test that async encode/decode functions work properly
536
+ const asyncCodec = z.codec(z.string(), z.number(), {
537
+ decode: async (str) => {
538
+ await new Promise((resolve) => setTimeout(resolve, 1)); // Simulate async work
539
+ return Number.parseFloat(str);
540
+ },
541
+ encode: async (num) => {
542
+ await new Promise((resolve) => setTimeout(resolve, 1)); // Simulate async work
543
+ return num.toString();
544
+ },
545
+ });
546
+
547
+ // Test async decode/encode
548
+ const decoded = await z.decodeAsync(asyncCodec, "42.5");
549
+ expect(decoded).toBe(42.5);
550
+
551
+ const encoded = await z.encodeAsync(asyncCodec, 42.5);
552
+ expect(encoded).toBe("42.5");
553
+
554
+ // Test that both sync and async work
555
+ const mixedCodec = z.codec(z.string(), z.number(), {
556
+ decode: async (str) => Number.parseFloat(str),
557
+ encode: (num) => num.toString(), // sync encode
558
+ });
559
+
560
+ const mixedResult = await z.decodeAsync(mixedCodec, "123");
561
+ expect(mixedResult).toBe(123);
562
+ });
@@ -919,6 +919,7 @@ test("CIDR v6 validation", () => {
919
919
  expect(cidrV6.safeParse("2001:db8::/abc").success).toBe(false); // Invalid prefix format
920
920
  expect(cidrV6.safeParse("not a cidr").success).toBe(false); // Invalid format
921
921
  expect(cidrV6.safeParse("192.168.0.0/24").success).toBe(false); // IPv4 CIDR in v6 validation
922
+ expect(cidrV6.safeParse("2001:0db8:85a3::/64/whatever-after").success).toBe(false);
922
923
  });
923
924
 
924
925
  test("E.164 validation", () => {
@@ -830,9 +830,10 @@ export const $ZodCIDRv6: core.$constructor<$ZodCIDRv6> = /*@__PURE__*/ core.$con
830
830
  $ZodStringFormat.init(inst, def);
831
831
 
832
832
  inst._zod.check = (payload) => {
833
- const [address, prefix] = payload.value.split("/");
833
+ const segments = payload.value.split("/");
834
+ const [address, prefix] = segments;
834
835
  try {
835
- if (!prefix) throw new Error();
836
+ if (segments.length !== 2) throw new Error();
836
837
  const prefixNum = Number(prefix);
837
838
  if (`${prefixNum}` !== prefix) throw new Error();
838
839
  if (prefixNum < 0 || prefixNum > 128) throw new Error();
@@ -1862,6 +1863,7 @@ export const $ZodObject: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$con
1862
1863
 
1863
1864
  const proms: Promise<any>[] = [];
1864
1865
  const shape = value.shape;
1866
+
1865
1867
  for (const key of value.keys) {
1866
1868
  const el = shape[key]!;
1867
1869
  const r = el._zod.run({ value: input[key], issues: [] }, ctx);
@@ -1907,7 +1909,7 @@ export const $ZodObjectJIT: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$
1907
1909
  }
1908
1910
 
1909
1911
  // A: preserve key order {
1910
- doc.write(`const newResult = {}`);
1912
+ doc.write(`const newResult = {};`);
1911
1913
  for (const key of normalized.keys) {
1912
1914
  const id = ids[key];
1913
1915
  const k = util.esc(key);
@@ -1920,6 +1922,7 @@ export const $ZodObjectJIT: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$
1920
1922
  })));
1921
1923
  }
1922
1924
 
1925
+
1923
1926
  if (${id}.value === undefined) {
1924
1927
  if (${k} in input) {
1925
1928
  newResult[${k}] = undefined;
@@ -1927,6 +1930,7 @@ export const $ZodObjectJIT: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$
1927
1930
  } else {
1928
1931
  newResult[${k}] = ${id}.value;
1929
1932
  }
1933
+
1930
1934
  `);
1931
1935
  }
1932
1936
 
@@ -3590,9 +3594,9 @@ export interface $ZodPipeDef<A extends SomeType = $ZodType, B extends SomeType =
3590
3594
  in: A;
3591
3595
  out: B;
3592
3596
  /** Only defined inside $ZodCodec instances. */
3593
- transform?: (value: core.output<A>, payload: ParsePayload<core.output<A>>) => core.input<B>;
3597
+ transform?: (value: core.output<A>, payload: ParsePayload<core.output<A>>) => util.MaybeAsync<core.input<B>>;
3594
3598
  /** Only defined inside $ZodCodec instances. */
3595
- reverseTransform?: (value: core.input<B>, payload: ParsePayload<core.input<B>>) => core.output<A>;
3599
+ reverseTransform?: (value: core.input<B>, payload: ParsePayload<core.input<B>>) => util.MaybeAsync<core.output<A>>;
3596
3600
  }
3597
3601
 
3598
3602
  export interface $ZodPipeInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType>
@@ -3650,8 +3654,8 @@ function handlePipeResult(left: ParsePayload, next: $ZodType, ctx: ParseContextI
3650
3654
  ////////////////////////////////////////////
3651
3655
  ////////////////////////////////////////////
3652
3656
  export interface $ZodCodecDef<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodPipeDef<A, B> {
3653
- transform: (value: core.output<A>, payload: ParsePayload<core.output<A>>) => core.input<B>;
3654
- reverseTransform: (value: core.input<B>, payload: ParsePayload<core.input<B>>) => core.output<A>;
3657
+ transform: (value: core.output<A>, payload: ParsePayload<core.output<A>>) => util.MaybeAsync<core.input<B>>;
3658
+ reverseTransform: (value: core.input<B>, payload: ParsePayload<core.input<B>>) => util.MaybeAsync<core.output<A>>;
3655
3659
  }
3656
3660
 
3657
3661
  export interface $ZodCodecInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType>
@@ -1,5 +1,5 @@
1
1
  export const version = {
2
2
  major: 4,
3
3
  minor: 1,
4
- patch: 4 as number,
4
+ patch: 6 as number,
5
5
  } as const;
@@ -1460,8 +1460,8 @@ export function codec<const A extends SomeType, B extends core.SomeType = core.$
1460
1460
  in_: A,
1461
1461
  out: B,
1462
1462
  params: {
1463
- decode: (value: core.output<A>, payload: core.ParsePayload<core.output<A>>) => core.input<B>;
1464
- encode: (value: core.input<B>, payload: core.ParsePayload<core.input<B>>) => core.output<A>;
1463
+ decode: (value: core.output<A>, payload: core.ParsePayload<core.output<A>>) => core.util.MaybeAsync<core.input<B>>;
1464
+ encode: (value: core.input<B>, payload: core.ParsePayload<core.input<B>>) => core.util.MaybeAsync<core.output<A>>;
1465
1465
  }
1466
1466
  ): ZodMiniCodec<A, B> {
1467
1467
  return new ZodMiniCodec({
@@ -409,11 +409,11 @@ test("codec type enforcement - correct encode/decode signatures", () => {
409
409
  encode: (value: number) => String(value), // core.input<B> -> core.output<A>
410
410
  });
411
411
 
412
- // These should compile without errors - correct types
413
- expectTypeOf<(value: string, payload: z.core.ParsePayload<string>) => number>(
412
+ // These should compile without errors - correct types (async support)
413
+ expectTypeOf<(value: string, payload: z.core.ParsePayload<string>) => z.core.util.MaybeAsync<number>>(
414
414
  stringToNumberCodec.def.transform
415
415
  ).toBeFunction();
416
- expectTypeOf<(value: number, payload: z.core.ParsePayload<number>) => string>(
416
+ expectTypeOf<(value: number, payload: z.core.ParsePayload<number>) => z.core.util.MaybeAsync<string>>(
417
417
  stringToNumberCodec.def.reverseTransform
418
418
  ).toBeFunction();
419
419
 
@@ -450,6 +450,36 @@ test("codec type enforcement - correct encode/decode signatures", () => {
450
450
  });
451
451
  });
452
452
 
453
+ test("async codec functionality", async () => {
454
+ // Test that async encode/decode functions work properly
455
+ const asyncCodec = z.codec(z.string(), z.number(), {
456
+ decode: async (str) => {
457
+ await new Promise((resolve) => setTimeout(resolve, 1)); // Simulate async work
458
+ return Number.parseFloat(str);
459
+ },
460
+ encode: async (num) => {
461
+ await new Promise((resolve) => setTimeout(resolve, 1)); // Simulate async work
462
+ return num.toString();
463
+ },
464
+ });
465
+
466
+ // Test async decode/encode
467
+ const decoded = await z.decodeAsync(asyncCodec, "42.5");
468
+ expect(decoded).toBe(42.5);
469
+
470
+ const encoded = await z.encodeAsync(asyncCodec, 42.5);
471
+ expect(encoded).toBe("42.5");
472
+
473
+ // Test that both sync and async work
474
+ const mixedCodec = z.codec(z.string(), z.number(), {
475
+ decode: async (str) => Number.parseFloat(str),
476
+ encode: (num) => num.toString(), // sync encode
477
+ });
478
+
479
+ const mixedResult = await z.decodeAsync(mixedCodec, "123");
480
+ expect(mixedResult).toBe(123);
481
+ });
482
+
453
483
  test("codec type enforcement - complex types", () => {
454
484
  type User = { id: number; name: string };
455
485
  type UserInput = { id: string; name: string };
@@ -463,11 +493,11 @@ test("codec type enforcement - complex types", () => {
463
493
  }
464
494
  );
465
495
 
466
- // Verify correct types are inferred
467
- expectTypeOf<(input: UserInput, payload: z.core.ParsePayload<UserInput>) => User>(
496
+ // Verify correct types are inferred (async support)
497
+ expectTypeOf<(input: UserInput, payload: z.core.ParsePayload<UserInput>) => z.core.util.MaybeAsync<User>>(
468
498
  userCodec.def.transform
469
499
  ).toBeFunction();
470
- expectTypeOf<(user: User, payload: z.core.ParsePayload<User>) => UserInput>(
500
+ expectTypeOf<(user: User, payload: z.core.ParsePayload<User>) => z.core.util.MaybeAsync<UserInput>>(
471
501
  userCodec.def.reverseTransform
472
502
  ).toBeFunction();
473
503
 
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "module",
3
+ "main": "./index.cjs",
4
+ "module": "./index.js",
5
+ "types": "./index.d.cts"
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "module",
3
+ "main": "./index.cjs",
4
+ "module": "./index.js",
5
+ "types": "./index.d.cts"
6
+ }
@@ -36,7 +36,7 @@ export interface ZodType<out Output = unknown, out Input = unknown, out Internal
36
36
  nonoptional(params?: string | core.$ZodNonOptionalParams): ZodNonOptional<this>;
37
37
  nullable(): ZodNullable<this>;
38
38
  nullish(): ZodOptional<ZodNullable<this>>;
39
- default(def: core.output<this>): ZodDefault<this>;
39
+ default(def: util.NoUndefined<core.output<this>>): ZodDefault<this>;
40
40
  default(def: () => util.NoUndefined<core.output<this>>): ZodDefault<this>;
41
41
  prefault(def: () => core.input<this>): ZodPrefault<this>;
42
42
  prefault(def: core.input<this>): ZodPrefault<this>;
@@ -591,8 +591,8 @@ export interface ZodCodec<A extends core.SomeType = core.$ZodType, B extends cor
591
591
  }
592
592
  export declare const ZodCodec: core.$constructor<ZodCodec>;
593
593
  export declare function codec<const A extends core.SomeType, B extends core.SomeType = core.$ZodType>(in_: A, out: B, params: {
594
- decode: (value: core.output<A>, payload: core.ParsePayload<core.output<A>>) => core.input<B>;
595
- encode: (value: core.input<B>, payload: core.ParsePayload<core.input<B>>) => core.output<A>;
594
+ decode: (value: core.output<A>, payload: core.ParsePayload<core.output<A>>) => core.util.MaybeAsync<core.input<B>>;
595
+ encode: (value: core.input<B>, payload: core.ParsePayload<core.input<B>>) => core.util.MaybeAsync<core.output<A>>;
596
596
  }): ZodCodec<A, B>;
597
597
  export interface ZodReadonly<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodReadonlyInternals<T>>, core.$ZodReadonly<T> {
598
598
  unwrap(): T;
@@ -36,7 +36,7 @@ export interface ZodType<out Output = unknown, out Input = unknown, out Internal
36
36
  nonoptional(params?: string | core.$ZodNonOptionalParams): ZodNonOptional<this>;
37
37
  nullable(): ZodNullable<this>;
38
38
  nullish(): ZodOptional<ZodNullable<this>>;
39
- default(def: core.output<this>): ZodDefault<this>;
39
+ default(def: util.NoUndefined<core.output<this>>): ZodDefault<this>;
40
40
  default(def: () => util.NoUndefined<core.output<this>>): ZodDefault<this>;
41
41
  prefault(def: () => core.input<this>): ZodPrefault<this>;
42
42
  prefault(def: core.input<this>): ZodPrefault<this>;
@@ -591,8 +591,8 @@ export interface ZodCodec<A extends core.SomeType = core.$ZodType, B extends cor
591
591
  }
592
592
  export declare const ZodCodec: core.$constructor<ZodCodec>;
593
593
  export declare function codec<const A extends core.SomeType, B extends core.SomeType = core.$ZodType>(in_: A, out: B, params: {
594
- decode: (value: core.output<A>, payload: core.ParsePayload<core.output<A>>) => core.input<B>;
595
- encode: (value: core.input<B>, payload: core.ParsePayload<core.input<B>>) => core.output<A>;
594
+ decode: (value: core.output<A>, payload: core.ParsePayload<core.output<A>>) => core.util.MaybeAsync<core.input<B>>;
595
+ encode: (value: core.input<B>, payload: core.ParsePayload<core.input<B>>) => core.util.MaybeAsync<core.output<A>>;
596
596
  }): ZodCodec<A, B>;
597
597
  export interface ZodReadonly<T extends core.SomeType = core.$ZodType> extends _ZodType<core.$ZodReadonlyInternals<T>>, core.$ZodReadonly<T> {
598
598
  unwrap(): T;
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "module",
3
+ "main": "./index.cjs",
4
+ "module": "./index.js",
5
+ "types": "./index.d.cts"
6
+ }
@@ -364,9 +364,10 @@ exports.$ZodCIDRv6 = core.$constructor("$ZodCIDRv6", (inst, def) => {
364
364
  def.pattern ?? (def.pattern = regexes.cidrv6); // not used for validation
365
365
  exports.$ZodStringFormat.init(inst, def);
366
366
  inst._zod.check = (payload) => {
367
- const [address, prefix] = payload.value.split("/");
367
+ const segments = payload.value.split("/");
368
+ const [address, prefix] = segments;
368
369
  try {
369
- if (!prefix)
370
+ if (segments.length !== 2)
370
371
  throw new Error();
371
372
  const prefixNum = Number(prefix);
372
373
  if (`${prefixNum}` !== prefix)
@@ -864,7 +865,7 @@ exports.$ZodObjectJIT = core.$constructor("$ZodObjectJIT", (inst, def) => {
864
865
  ids[key] = `key_${counter++}`;
865
866
  }
866
867
  // A: preserve key order {
867
- doc.write(`const newResult = {}`);
868
+ doc.write(`const newResult = {};`);
868
869
  for (const key of normalized.keys) {
869
870
  const id = ids[key];
870
871
  const k = util.esc(key);
@@ -877,6 +878,7 @@ exports.$ZodObjectJIT = core.$constructor("$ZodObjectJIT", (inst, def) => {
877
878
  })));
878
879
  }
879
880
 
881
+
880
882
  if (${id}.value === undefined) {
881
883
  if (${k} in input) {
882
884
  newResult[${k}] = undefined;
@@ -884,6 +886,7 @@ exports.$ZodObjectJIT = core.$constructor("$ZodObjectJIT", (inst, def) => {
884
886
  } else {
885
887
  newResult[${k}] = ${id}.value;
886
888
  }
889
+
887
890
  `);
888
891
  }
889
892
  doc.write(`payload.value = newResult;`);
@@ -945,9 +945,9 @@ export interface $ZodPipeDef<A extends SomeType = $ZodType, B extends SomeType =
945
945
  in: A;
946
946
  out: B;
947
947
  /** Only defined inside $ZodCodec instances. */
948
- transform?: (value: core.output<A>, payload: ParsePayload<core.output<A>>) => core.input<B>;
948
+ transform?: (value: core.output<A>, payload: ParsePayload<core.output<A>>) => util.MaybeAsync<core.input<B>>;
949
949
  /** Only defined inside $ZodCodec instances. */
950
- reverseTransform?: (value: core.input<B>, payload: ParsePayload<core.input<B>>) => core.output<A>;
950
+ reverseTransform?: (value: core.input<B>, payload: ParsePayload<core.input<B>>) => util.MaybeAsync<core.output<A>>;
951
951
  }
952
952
  export interface $ZodPipeInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<B>, core.input<A>> {
953
953
  def: $ZodPipeDef<A, B>;
@@ -962,8 +962,8 @@ export interface $ZodPipe<A extends SomeType = $ZodType, B extends SomeType = $Z
962
962
  }
963
963
  export declare const $ZodPipe: core.$constructor<$ZodPipe>;
964
964
  export interface $ZodCodecDef<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodPipeDef<A, B> {
965
- transform: (value: core.output<A>, payload: ParsePayload<core.output<A>>) => core.input<B>;
966
- reverseTransform: (value: core.input<B>, payload: ParsePayload<core.input<B>>) => core.output<A>;
965
+ transform: (value: core.output<A>, payload: ParsePayload<core.output<A>>) => util.MaybeAsync<core.input<B>>;
966
+ reverseTransform: (value: core.input<B>, payload: ParsePayload<core.input<B>>) => util.MaybeAsync<core.output<A>>;
967
967
  }
968
968
  export interface $ZodCodecInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<B>, core.input<A>> {
969
969
  def: $ZodCodecDef<A, B>;
@@ -945,9 +945,9 @@ export interface $ZodPipeDef<A extends SomeType = $ZodType, B extends SomeType =
945
945
  in: A;
946
946
  out: B;
947
947
  /** Only defined inside $ZodCodec instances. */
948
- transform?: (value: core.output<A>, payload: ParsePayload<core.output<A>>) => core.input<B>;
948
+ transform?: (value: core.output<A>, payload: ParsePayload<core.output<A>>) => util.MaybeAsync<core.input<B>>;
949
949
  /** Only defined inside $ZodCodec instances. */
950
- reverseTransform?: (value: core.input<B>, payload: ParsePayload<core.input<B>>) => core.output<A>;
950
+ reverseTransform?: (value: core.input<B>, payload: ParsePayload<core.input<B>>) => util.MaybeAsync<core.output<A>>;
951
951
  }
952
952
  export interface $ZodPipeInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<B>, core.input<A>> {
953
953
  def: $ZodPipeDef<A, B>;
@@ -962,8 +962,8 @@ export interface $ZodPipe<A extends SomeType = $ZodType, B extends SomeType = $Z
962
962
  }
963
963
  export declare const $ZodPipe: core.$constructor<$ZodPipe>;
964
964
  export interface $ZodCodecDef<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodPipeDef<A, B> {
965
- transform: (value: core.output<A>, payload: ParsePayload<core.output<A>>) => core.input<B>;
966
- reverseTransform: (value: core.input<B>, payload: ParsePayload<core.input<B>>) => core.output<A>;
965
+ transform: (value: core.output<A>, payload: ParsePayload<core.output<A>>) => util.MaybeAsync<core.input<B>>;
966
+ reverseTransform: (value: core.input<B>, payload: ParsePayload<core.input<B>>) => util.MaybeAsync<core.output<A>>;
967
967
  }
968
968
  export interface $ZodCodecInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<B>, core.input<A>> {
969
969
  def: $ZodCodecDef<A, B>;
@@ -333,9 +333,10 @@ export const $ZodCIDRv6 = /*@__PURE__*/ core.$constructor("$ZodCIDRv6", (inst, d
333
333
  def.pattern ?? (def.pattern = regexes.cidrv6); // not used for validation
334
334
  $ZodStringFormat.init(inst, def);
335
335
  inst._zod.check = (payload) => {
336
- const [address, prefix] = payload.value.split("/");
336
+ const segments = payload.value.split("/");
337
+ const [address, prefix] = segments;
337
338
  try {
338
- if (!prefix)
339
+ if (segments.length !== 2)
339
340
  throw new Error();
340
341
  const prefixNum = Number(prefix);
341
342
  if (`${prefixNum}` !== prefix)
@@ -833,7 +834,7 @@ export const $ZodObjectJIT = /*@__PURE__*/ core.$constructor("$ZodObjectJIT", (i
833
834
  ids[key] = `key_${counter++}`;
834
835
  }
835
836
  // A: preserve key order {
836
- doc.write(`const newResult = {}`);
837
+ doc.write(`const newResult = {};`);
837
838
  for (const key of normalized.keys) {
838
839
  const id = ids[key];
839
840
  const k = util.esc(key);
@@ -846,6 +847,7 @@ export const $ZodObjectJIT = /*@__PURE__*/ core.$constructor("$ZodObjectJIT", (i
846
847
  })));
847
848
  }
848
849
 
850
+
849
851
  if (${id}.value === undefined) {
850
852
  if (${k} in input) {
851
853
  newResult[${k}] = undefined;
@@ -853,6 +855,7 @@ export const $ZodObjectJIT = /*@__PURE__*/ core.$constructor("$ZodObjectJIT", (i
853
855
  } else {
854
856
  newResult[${k}] = ${id}.value;
855
857
  }
858
+
856
859
  `);
857
860
  }
858
861
  doc.write(`payload.value = newResult;`);
@@ -4,5 +4,5 @@ exports.version = void 0;
4
4
  exports.version = {
5
5
  major: 4,
6
6
  minor: 1,
7
- patch: 4,
7
+ patch: 6,
8
8
  };
@@ -1,5 +1,5 @@
1
1
  export const version = {
2
2
  major: 4,
3
3
  minor: 1,
4
- patch: 4,
4
+ patch: 6,
5
5
  };
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "module",
3
+ "main": "./index.cjs",
4
+ "module": "./index.js",
5
+ "types": "./index.d.cts"
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "module",
3
+ "main": "./index.cjs",
4
+ "module": "./index.js",
5
+ "types": "./index.d.cts"
6
+ }
@@ -326,8 +326,8 @@ export interface ZodMiniCodec<A extends SomeType = core.$ZodType, B extends Some
326
326
  }
327
327
  export declare const ZodMiniCodec: core.$constructor<ZodMiniCodec>;
328
328
  export declare function codec<const A extends SomeType, B extends core.SomeType = core.$ZodType>(in_: A, out: B, params: {
329
- decode: (value: core.output<A>, payload: core.ParsePayload<core.output<A>>) => core.input<B>;
330
- encode: (value: core.input<B>, payload: core.ParsePayload<core.input<B>>) => core.output<A>;
329
+ decode: (value: core.output<A>, payload: core.ParsePayload<core.output<A>>) => core.util.MaybeAsync<core.input<B>>;
330
+ encode: (value: core.input<B>, payload: core.ParsePayload<core.input<B>>) => core.util.MaybeAsync<core.output<A>>;
331
331
  }): ZodMiniCodec<A, B>;
332
332
  export interface ZodMiniReadonly<T extends SomeType = core.$ZodType> extends _ZodMiniType<core.$ZodReadonlyInternals<T>> {
333
333
  }
@@ -326,8 +326,8 @@ export interface ZodMiniCodec<A extends SomeType = core.$ZodType, B extends Some
326
326
  }
327
327
  export declare const ZodMiniCodec: core.$constructor<ZodMiniCodec>;
328
328
  export declare function codec<const A extends SomeType, B extends core.SomeType = core.$ZodType>(in_: A, out: B, params: {
329
- decode: (value: core.output<A>, payload: core.ParsePayload<core.output<A>>) => core.input<B>;
330
- encode: (value: core.input<B>, payload: core.ParsePayload<core.input<B>>) => core.output<A>;
329
+ decode: (value: core.output<A>, payload: core.ParsePayload<core.output<A>>) => core.util.MaybeAsync<core.input<B>>;
330
+ encode: (value: core.input<B>, payload: core.ParsePayload<core.input<B>>) => core.util.MaybeAsync<core.output<A>>;
331
331
  }): ZodMiniCodec<A, B>;
332
332
  export interface ZodMiniReadonly<T extends SomeType = core.$ZodType> extends _ZodMiniType<core.$ZodReadonlyInternals<T>> {
333
333
  }
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "module",
3
+ "main": "./index.cjs",
4
+ "module": "./index.js",
5
+ "types": "./index.d.cts"
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "module",
3
+ "main": "./index.cjs",
4
+ "module": "./index.js",
5
+ "types": "./index.d.cts"
6
+ }