zod 4.2.0-canary.20251118T192410 → 4.2.0-canary.20251124T022609

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zod",
3
- "version": "4.2.0-canary.20251118T192410",
3
+ "version": "4.2.0-canary.20251124T022609",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Colin McDonnell <zod@colinhacks.com>",
@@ -607,25 +607,3 @@ test("safeExtend() on object with refinements should not throw", () => {
607
607
 
608
608
  expect(() => schema.safeExtend({ b: z.string() })).not.toThrow();
609
609
  });
610
-
611
- test("pick() on object with refinements should throw", () => {
612
- const schema = z
613
- .object({
614
- a: z.string(),
615
- b: z.number(),
616
- })
617
- .refine(() => true);
618
-
619
- expect(() => schema.pick({ a: true })).toThrow("Invalid .pick() on object schemas containing refinements");
620
- });
621
-
622
- test("omit() on object with refinements should throw", () => {
623
- const schema = z
624
- .object({
625
- a: z.string(),
626
- b: z.number(),
627
- })
628
- .refine(() => true);
629
-
630
- expect(() => schema.omit({ b: true })).toThrow("Invalid .omit() on object schemas containing refinements");
631
- });
@@ -592,10 +592,8 @@ export const BIGINT_FORMAT_RANGES: Record<checks.$ZodBigIntFormats, [bigint, big
592
592
 
593
593
  export function pick(schema: schemas.$ZodObject, mask: Record<string, unknown>): any {
594
594
  const currDef = schema._zod.def;
595
- if ((currDef.checks ?? []).length > 0) {
596
- throw new Error("Invalid .pick() on object schemas containing refinements");
597
- }
598
- const def = mergeDefs(currDef, {
595
+
596
+ const def = mergeDefs(schema._zod.def, {
599
597
  get shape() {
600
598
  const newShape: Writeable<schemas.$ZodShape> = {};
601
599
  for (const key in mask) {
@@ -617,13 +615,10 @@ export function pick(schema: schemas.$ZodObject, mask: Record<string, unknown>):
617
615
 
618
616
  export function omit(schema: schemas.$ZodObject, mask: object): any {
619
617
  const currDef = schema._zod.def;
620
- if ((currDef.checks ?? []).length > 0) {
621
- throw new Error("Invalid .omit() on object schemas containing refinements");
622
- }
623
618
 
624
- const def = mergeDefs(currDef, {
619
+ const def = mergeDefs(schema._zod.def, {
625
620
  get shape() {
626
- const newShape: Writeable<schemas.$ZodShape> = { ...currDef.shape };
621
+ const newShape: Writeable<schemas.$ZodShape> = { ...schema._zod.def.shape };
627
622
  for (const key in mask) {
628
623
  if (!(key in currDef.shape)) {
629
624
  throw new Error(`Unrecognized key: "${key}"`);
@@ -649,7 +644,7 @@ export function extend(schema: schemas.$ZodObject, shape: schemas.$ZodShape): an
649
644
  const checks = schema._zod.def.checks;
650
645
  const hasChecks = checks && checks.length > 0;
651
646
  if (hasChecks) {
652
- throw new Error("Invalid .extend() on object schemas containing refinements. Use .safeExtend() instead.");
647
+ throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");
653
648
  }
654
649
 
655
650
  const def = mergeDefs(schema._zod.def, {
package/v4/core/util.cjs CHANGED
@@ -384,10 +384,7 @@ exports.BIGINT_FORMAT_RANGES = {
384
384
  };
385
385
  function pick(schema, mask) {
386
386
  const currDef = schema._zod.def;
387
- if ((currDef.checks ?? []).length > 0) {
388
- throw new Error("Invalid .pick() on object schemas containing refinements");
389
- }
390
- const def = mergeDefs(currDef, {
387
+ const def = mergeDefs(schema._zod.def, {
391
388
  get shape() {
392
389
  const newShape = {};
393
390
  for (const key in mask) {
@@ -407,12 +404,9 @@ function pick(schema, mask) {
407
404
  }
408
405
  function omit(schema, mask) {
409
406
  const currDef = schema._zod.def;
410
- if ((currDef.checks ?? []).length > 0) {
411
- throw new Error("Invalid .omit() on object schemas containing refinements");
412
- }
413
- const def = mergeDefs(currDef, {
407
+ const def = mergeDefs(schema._zod.def, {
414
408
  get shape() {
415
- const newShape = { ...currDef.shape };
409
+ const newShape = { ...schema._zod.def.shape };
416
410
  for (const key in mask) {
417
411
  if (!(key in currDef.shape)) {
418
412
  throw new Error(`Unrecognized key: "${key}"`);
@@ -435,7 +429,7 @@ function extend(schema, shape) {
435
429
  const checks = schema._zod.def.checks;
436
430
  const hasChecks = checks && checks.length > 0;
437
431
  if (hasChecks) {
438
- throw new Error("Invalid .extend() on object schemas containing refinements. Use .safeExtend() instead.");
432
+ throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");
439
433
  }
440
434
  const def = mergeDefs(schema._zod.def, {
441
435
  get shape() {
package/v4/core/util.js CHANGED
@@ -327,10 +327,7 @@ export const BIGINT_FORMAT_RANGES = {
327
327
  };
328
328
  export function pick(schema, mask) {
329
329
  const currDef = schema._zod.def;
330
- if ((currDef.checks ?? []).length > 0) {
331
- throw new Error("Invalid .pick() on object schemas containing refinements");
332
- }
333
- const def = mergeDefs(currDef, {
330
+ const def = mergeDefs(schema._zod.def, {
334
331
  get shape() {
335
332
  const newShape = {};
336
333
  for (const key in mask) {
@@ -350,12 +347,9 @@ export function pick(schema, mask) {
350
347
  }
351
348
  export function omit(schema, mask) {
352
349
  const currDef = schema._zod.def;
353
- if ((currDef.checks ?? []).length > 0) {
354
- throw new Error("Invalid .omit() on object schemas containing refinements");
355
- }
356
- const def = mergeDefs(currDef, {
350
+ const def = mergeDefs(schema._zod.def, {
357
351
  get shape() {
358
- const newShape = { ...currDef.shape };
352
+ const newShape = { ...schema._zod.def.shape };
359
353
  for (const key in mask) {
360
354
  if (!(key in currDef.shape)) {
361
355
  throw new Error(`Unrecognized key: "${key}"`);
@@ -378,7 +372,7 @@ export function extend(schema, shape) {
378
372
  const checks = schema._zod.def.checks;
379
373
  const hasChecks = checks && checks.length > 0;
380
374
  if (hasChecks) {
381
- throw new Error("Invalid .extend() on object schemas containing refinements. Use .safeExtend() instead.");
375
+ throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");
382
376
  }
383
377
  const def = mergeDefs(schema._zod.def, {
384
378
  get shape() {