zod 4.3.0-canary.20251216T031837 → 4.3.0-canary.20251222T061611

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.3.0-canary.20251216T031837",
3
+ "version": "4.3.0-canary.20251222T061611",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Colin McDonnell <zod@colinhacks.com>",
@@ -253,7 +253,7 @@ export interface _ZodString<T extends core.$ZodStringInternals<unknown> = core.$
253
253
 
254
254
  // miscellaneous checks
255
255
  regex(regex: RegExp, params?: string | core.$ZodCheckRegexParams): this;
256
- includes(value: string, params?: core.$ZodCheckIncludesParams): this;
256
+ includes(value: string, params?: string | core.$ZodCheckIncludesParams): this;
257
257
  startsWith(value: string, params?: string | core.$ZodCheckStartsWithParams): this;
258
258
  endsWith(value: string, params?: string | core.$ZodCheckEndsWithParams): this;
259
259
  min(minLength: number, params?: string | core.$ZodCheckMinLengthParams): this;
@@ -35,6 +35,27 @@ test("includes", () => {
35
35
  expect(() => includesFromIndex2.parse("XincludesXX")).toThrow();
36
36
  });
37
37
 
38
+ test("includes with string error message", () => {
39
+ const schema = z.string().includes("test", "must contain test");
40
+ schema.parse("this is a test");
41
+
42
+ expect(schema.safeParse("this is invalid")).toMatchInlineSnapshot(`
43
+ {
44
+ "error": [ZodError: [
45
+ {
46
+ "origin": "string",
47
+ "code": "invalid_format",
48
+ "format": "includes",
49
+ "includes": "test",
50
+ "path": [],
51
+ "message": "must contain test"
52
+ }
53
+ ]],
54
+ "success": false,
55
+ }
56
+ `);
57
+ });
58
+
38
59
  test("startswith/endswith", () => {
39
60
  startsWith.parse("startsWithX");
40
61
  endsWith.parse("XendsWith");
@@ -298,7 +298,8 @@ export const $ZodType: core.$constructor<$ZodType> = /*@__PURE__*/ core.$constru
298
298
  };
299
299
  }
300
300
 
301
- inst["~standard"] = {
301
+ // Lazy initialize ~standard to avoid creating objects for every schema
302
+ util.defineLazy(inst, "~standard", () => ({
302
303
  validate: (value: unknown) => {
303
304
  try {
304
305
  const r = safeParse(inst, value);
@@ -309,7 +310,7 @@ export const $ZodType: core.$constructor<$ZodType> = /*@__PURE__*/ core.$constru
309
310
  },
310
311
  vendor: "zod",
311
312
  version: 1 as const,
312
- };
313
+ }));
313
314
  });
314
315
 
315
316
  export { clone } from "./util.js";
@@ -86,7 +86,7 @@ export interface _ZodString<T extends core.$ZodStringInternals<unknown> = core.$
86
86
  minLength: number | null;
87
87
  maxLength: number | null;
88
88
  regex(regex: RegExp, params?: string | core.$ZodCheckRegexParams): this;
89
- includes(value: string, params?: core.$ZodCheckIncludesParams): this;
89
+ includes(value: string, params?: string | core.$ZodCheckIncludesParams): this;
90
90
  startsWith(value: string, params?: string | core.$ZodCheckStartsWithParams): this;
91
91
  endsWith(value: string, params?: string | core.$ZodCheckEndsWithParams): this;
92
92
  min(minLength: number, params?: string | core.$ZodCheckMinLengthParams): this;
@@ -86,7 +86,7 @@ export interface _ZodString<T extends core.$ZodStringInternals<unknown> = core.$
86
86
  minLength: number | null;
87
87
  maxLength: number | null;
88
88
  regex(regex: RegExp, params?: string | core.$ZodCheckRegexParams): this;
89
- includes(value: string, params?: core.$ZodCheckIncludesParams): this;
89
+ includes(value: string, params?: string | core.$ZodCheckIncludesParams): this;
90
90
  startsWith(value: string, params?: string | core.$ZodCheckStartsWithParams): this;
91
91
  endsWith(value: string, params?: string | core.$ZodCheckEndsWithParams): this;
92
92
  min(minLength: number, params?: string | core.$ZodCheckMinLengthParams): this;
@@ -142,7 +142,8 @@ exports.$ZodType = core.$constructor("$ZodType", (inst, def) => {
142
142
  return runChecks(result, checks, ctx);
143
143
  };
144
144
  }
145
- inst["~standard"] = {
145
+ // Lazy initialize ~standard to avoid creating objects for every schema
146
+ util.defineLazy(inst, "~standard", () => ({
146
147
  validate: (value) => {
147
148
  try {
148
149
  const r = (0, parse_js_1.safeParse)(inst, value);
@@ -154,7 +155,7 @@ exports.$ZodType = core.$constructor("$ZodType", (inst, def) => {
154
155
  },
155
156
  vendor: "zod",
156
157
  version: 1,
157
- };
158
+ }));
158
159
  });
159
160
  var util_js_1 = require("./util.cjs");
160
161
  Object.defineProperty(exports, "clone", { enumerable: true, get: function () { return util_js_1.clone; } });
@@ -112,7 +112,8 @@ export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def)
112
112
  return runChecks(result, checks, ctx);
113
113
  };
114
114
  }
115
- inst["~standard"] = {
115
+ // Lazy initialize ~standard to avoid creating objects for every schema
116
+ util.defineLazy(inst, "~standard", () => ({
116
117
  validate: (value) => {
117
118
  try {
118
119
  const r = safeParse(inst, value);
@@ -124,7 +125,7 @@ export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def)
124
125
  },
125
126
  vendor: "zod",
126
127
  version: 1,
127
- };
128
+ }));
128
129
  });
129
130
  export { clone } from "./util.js";
130
131
  export const $ZodString = /*@__PURE__*/ core.$constructor("$ZodString", (inst, def) => {