zod 4.3.0-canary.20251216T172808 → 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
|
@@ -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");
|
package/v4/classic/schemas.d.cts
CHANGED
|
@@ -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;
|
package/v4/classic/schemas.d.ts
CHANGED
|
@@ -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;
|