agent_patch
runs/2026-02-27__21-30-28__gpt-5-4/flux-pr-3820/flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-4/agent-logs/agent.patch
60912 bytes
diff --git a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-4/app/README.md b/app/README.md
index 3cf25ab..11a6c90 100644
--- a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-4/app/README.md
+++ b/app/README.md
@@ -613,7 +613,6 @@ bun add zod@canary # bun
pnpm add zod@canary # pnpm
```
-
> The rest of this README assumes you are using npm and importing directly from the `"zod"` package.
## Basic usage
@@ -777,6 +776,7 @@ z.string().startsWith(string);
z.string().endsWith(string);
z.string().datetime(); // ISO 8601; by default only `Z` timezone allowed
z.string().ip(); // defaults to allow both IPv4 and IPv6
+z.string().cidr(); // defaults to allow both IPv4 and IPv6 CIDR blocks
// transforms
z.string().trim(); // trim whitespace
@@ -818,6 +818,7 @@ z.string().datetime({ message: "Invalid datetime string! Must be UTC." });
z.string().date({ message: "Invalid date string!" });
z.string().time({ message: "Invalid time string!" });
z.string().ip({ message: "Invalid IP address" });
+z.string().cidr({ message: "Invalid CIDR block" });
```
### Datetimes
@@ -923,6 +924,33 @@ const ipv6 = z.string().ip({ version: "v6" });
ipv6.parse("192.168.1.1"); // fail
```
+### CIDR blocks
+
+The `z.string().cidr()` method validates CIDR notation for IPv4 and IPv6 ranges.
+
+```ts
+const cidr = z.string().cidr();
+
+cidr.parse("192.168.0.0/24"); // pass
+cidr.parse("2001:db8::/32"); // pass
+
+cidr.parse("192.168.0.1"); // fail
+cidr.parse("10.0.0.0/33"); // fail
+cidr.parse("2001:db8::/129"); // fail
+```
+
+You can additionally set the CIDR `version`.
+
+```ts
+const ipv4Range = z.string().cidr({ version: "v4" });
+ipv4Range.parse("10.0.0.0/8"); // pass
+ipv4Range.parse("2001:db8::/32"); // fail
+
+const ipv6Range = z.string().cidr({ version: "v6" });
+ipv6Range.parse("2001:db8::/48"); // pass
+ipv6Range.parse("10.0.0.0/8"); // fail
+```
+
## Numbers
You can customize certain error messages when creating a number schema.
diff --git a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-4/app/deno/lib/README.md b/app/deno/lib/README.md
index a3c8886..1d55f10 100644
--- a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-4/app/deno/lib/README.md
+++ b/app/deno/lib/README.md
@@ -787,6 +787,7 @@ z.string().startsWith(string);
z.string().endsWith(string);
z.string().datetime(); // ISO 8601; by default only `Z` timezone allowed
z.string().ip(); // defaults to allow both IPv4 and IPv6
+z.string().cidr(); // defaults to allow both IPv4 and IPv6 CIDR blocks
// transforms
z.string().trim(); // trim whitespace
@@ -828,6 +829,7 @@ z.string().datetime({ message: "Invalid datetime string! Must be UTC." });
z.string().date({ message: "Invalid date string!" });
z.string().time({ message: "Invalid time string!" });
z.string().ip({ message: "Invalid IP address" });
+z.string().cidr({ message: "Invalid CIDR block" });
```
### Datetimes
@@ -933,6 +935,33 @@ const ipv6 = z.string().ip({ version: "v6" });
ipv6.parse("192.168.1.1"); // fail
```
+### CIDR blocks
+
+The `z.string().cidr()` method validates CIDR notation for IPv4 and IPv6 ranges.
+
+```ts
+const cidr = z.string().cidr();
+
+cidr.parse("192.168.0.0/24"); // pass
+cidr.parse("2001:db8::/32"); // pass
+
+cidr.parse("192.168.0.1"); // fail
+cidr.parse("10.0.0.0/33"); // fail
+cidr.parse("2001:db8::/129"); // fail
+```
+
+You can additionally set the CIDR `version`.
+
+```ts
+const ipv4Range = z.string().cidr({ version: "v4" });
+ipv4Range.parse("10.0.0.0/8"); // pass
+ipv4Range.parse("2001:db8::/32"); // fail
+
+const ipv6Range = z.string().cidr({ version: "v6" });
+ipv6Range.parse("2001:db8::/48"); // pass
+ipv6Range.parse("10.0.0.0/8"); // fail
+```
+
## Numbers
You can customize certain error messages when creating a number schema.
diff --git a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-4/app/deno/lib/ZodError.ts b/app/deno/lib/ZodError.ts
index e757cd8..f0c51ef 100644
--- a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-4/app/deno/lib/ZodError.ts
+++ b/app/deno/lib/ZodError.ts
@@ -6,7 +6,7 @@ type allKeys<T> = T extends any ? keyof T : never;
export type inferFlattenedErrors<
T extends ZodType<any, any, any>,
- U = string
+ U = string,
> = typeToFlattenedError<TypeOf<T>, U>;
export type typeToFlattenedError<T, U = string> = {
formErrors: U[];
@@ -103,6 +103,7 @@ export type StringValidation =
| "time"
| "duration"
| "ip"
+ | "cidr"
| "base64"
| { includes: string; position?: number }
| { startsWith: string }
@@ -180,10 +181,10 @@ export const quotelessJson = (obj: any) => {
type recursiveZodFormattedError<T> = T extends [any, ...any[]]
? { [K in keyof T]?: ZodFormattedError<T[K]> }
: T extends any[]
- ? { [k: number]: ZodFormattedError<T[number]> }
- : T extends object
- ? { [K in keyof T]?: ZodFormattedError<T[K]> }
- : unknown;
+ ? { [k: number]: ZodFormattedError<T[number]> }
+ : T extends object
+ ? { [K in keyof T]?: ZodFormattedError<T[K]> }
+ : unknown;
export type ZodFormattedError<T, U = string> = {
_errors: U[];
@@ -191,7 +192,7 @@ export type ZodFormattedError<T, U = string> = {
export type inferFormattedError<
T extends ZodType<any, any, any>,
- U = string
+ U = string,
> = ZodFormattedError<TypeOf<T>, U>;
export class ZodError<T = any> extends Error {
diff --git a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-4/app/deno/lib/__tests__/string.test.ts b/app/deno/lib/__tests__/string.test.ts
index 6443871..f6c3d80 100644
--- a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-4/app/deno/lib/__tests__/string.test.ts
+++ b/app/deno/lib/__tests__/string.test.ts
@@ -427,6 +427,9 @@ test("checks getters", () => {
expect(z.string().ip().isUUID).toEqual(false);
expect(z.string().ip().isNANOID).toEqual(false);
expect(z.string().ip().isIP).toEqual(true);
+ expect(z.string().ip().isCIDR).toEqual(false);
+ expect(z.string().cidr().isIP).toEqual(false);
+ expect(z.string().cidr().isCIDR).toEqual(true);
expect(z.string().ip().isULID).toEqual(false);
expect(z.string().ulid().isEmail).toEqual(false);
@@ -769,3 +772,46 @@ test("IP validation", () => {
invalidIPs.every((ip) => ipSchema.safeParse(ip).success === false)
).toBe(true);
});
+
+test("CIDR validation", () => {
+ const cidr = z.string().cidr();
+ expect(cidr.safeParse("192.168.0.0/24").success).toBe(true);
+ expect(cidr.safeParse("2001:db8::/32").success).toBe(true);
+
+ const ipv4Cidr = z.string().cidr({ version: "v4" });
+ expect(ipv4Cidr.safeParse("10.0.0.0/8").success).toBe(true);
+ expect(() => ipv4Cidr.parse("2001:db8::/32")).toThrow();
+
+ const ipv6Cidr = z.string().cidr({ version: "v6" });
+ expect(ipv6Cidr.safeParse("2001:db8::/48").success).toBe(true);
+ expect(() => ipv6Cidr.parse("10.0.0.0/8")).toThrow();
+
+ const validCidrs = [
+ "0.0.0.0/0",
+ "192.168.1.0/24",
+ "255.255.255.255/32",
+ "2001:db8::/32",
+ "::1/128",
+ "::ffff:192.168.1.1/128",
+ ];
+ const invalidCidrs = [
+ "192.168.1.1",
+ "192.168.1.0/-1",
+ "192.168.1.0/33",
+ "256.0.0.0/24",
+ "2001:db8::/129",
+ "2001:db8::/-1",
+ "2001:db8::",
+ "10.0.0.0/",
+ "/24",
+ "10.0.0.0/24/1",
+ ];
+
+ expect(validCidrs.every((value) => cidr.safeParse(value).success)).toBe(true);
+ expect(
+ invalidCidrs.every((value) => cidr.safeParse(value).success === false)
+ ).toBe(true);
+ expect(cidr.safeParse("10.0.0.0/33").error?.issues[0].message).toEqual(
+ "Invalid CIDR block"
+ );
+});
diff --git a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-4/app/deno/lib/locales/en.ts b/app/deno/lib/locales/en.ts
index 0665af2..ba4ca9b 100644
--- a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-4/app/deno/lib/locales/en.ts
+++ b/app/deno/lib/locales/en.ts
@@ -61,7 +61,13 @@ const errorMap: ZodErrorMap = (issue, _ctx) => {
util.assertNever(issue.validation);
}
} else if (issue.validation !== "regex") {
- message = `Invalid ${issue.validation}`;
+ if (issue.validation === "ip") {
+ message = "Invalid IP address";
+ } else if (issue.validation === "cidr") {
+ message = "Invalid CIDR block";
+ } else {
+ message = `Invalid ${issue.validation}`;
+ }
} else {
message = "Invalid";
}
@@ -80,16 +86,16 @@ const errorMap: ZodErrorMap = (issue, _ctx) => {
issue.exact
? `exactly equal to `
: issue.inclusive
- ? `greater than or equal to `
- : `greater than `
+ ? `greater than or equal to `
+ : `greater than `
}${issue.minimum}`;
else if (issue.type === "date")
message = `Date must be ${
issue.exact
? `exactly equal to `
: issue.inclusive
- ? `greater than or equal to `
- : `greater than `
+ ? `greater than or equal to `
+ : `greater than `
}${new Date(Number(issue.minimum))}`;
else message = "Invalid input";
break;
@@ -107,24 +113,24 @@ const errorMap: ZodErrorMap = (issue, _ctx) => {
issue.exact
? `exactly`
: issue.inclusive
- ? `less than or equal to`
- : `less than`
+ ? `less than or equal to`
+ : `less than`
} ${issue.maximum}`;
else if (issue.type === "bigint")
message = `BigInt must be ${
issue.exact
? `exactly`
: issue.inclusive
- ? `less than or equal to`
- : `less than`
+ ? `less than or equal to`
+ : `less than`
} ${issue.maximum}`;
else if (issue.type === "date")
message = `Date must be ${
issue.exact
? `exactly`
: issue.inclusive
- ? `smaller than or equal to`
- : `smaller than`
+ ? `smaller than or equal to`
+ : `smaller than`
} ${new Date(Number(issue.maximum))}`;
else message = "Invalid input";
break;
diff --git a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-4/app/deno/lib/types.ts b/app/deno/lib/types.ts
index 9cee39a..7242aea 100644
--- a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-4/app/deno/lib/types.ts
+++ b/app/deno/lib/types.ts
@@ -22,7 +22,12 @@ import {
} from "./helpers/parseUtil.ts";
import { partialUtil } from "./helpers/partialUtil.ts";
import { Primitive } from "./helpers/typeAliases.ts";
-import { getParsedType, objectUtil, util, ZodParsedType } from "./helpers/util.ts";
+import {
+ getParsedType,
+ objectUtil,
+ util,
+ ZodParsedType,
+} from "./helpers/util.ts";
import {
IssueData,
StringValidation,
@@ -168,7 +173,7 @@ export type SafeParseReturnType<Input, Output> =
export abstract class ZodType<
Output = any,
Def extends ZodTypeDef = ZodTypeDef,
- Input = Output
+ Input = Output,
> {
readonly _type!: Output;
readonly _output!: Output;
@@ -565,6 +570,7 @@ export type ZodStringCheck =
}
| { kind: "duration"; message?: string }
| { kind: "ip"; version?: IpVersion; message?: string }
+ | { kind: "cidr"; version?: IpVersion; message?: string }
| { kind: "base64"; message?: string };
export interface ZodStringDef extends ZodTypeDef {
@@ -671,6 +677,32 @@ function isValidIP(ip: string, version?: IpVersion) {
return false;
}
+function isValidCidr(cidr: string, version?: IpVersion) {
+ const parts = cidr.split("/");
+ if (parts.length !== 2) {
+ return false;
+ }
+
+ const [ip, prefix] = parts;
+ if (!/^\d+$/.test(prefix) || !isValidIP(ip, version)) {
+ return false;
+ }
+
+ const prefixNum = Number(prefix);
+ if (version === "v4") {
+ return prefixNum >= 0 && prefixNum <= 32;
+ }
+ if (version === "v6") {
+ return prefixNum >= 0 && prefixNum <= 128;
+ }
+
+ if (ipv4Regex.test(ip)) {
+ return prefixNum >= 0 && prefixNum <= 32;
+ }
+
+ return ipv6Regex.test(ip) && prefixNum >= 0 && prefixNum <= 128;
+}
+
export class ZodString extends ZodType<string, ZodStringDef, string> {
_parse(input: ParseInput): ParseReturnType<string> {
if (this._def.coerce) {
@@ -933,6 +965,16 @@ export class ZodString extends ZodType<string, ZodStringDef, string> {
});
status.dirty();
}
+ } else if (check.kind === "cidr") {
+ if (!isValidCidr(input.data, check.version)) {
+ ctx = this._getOrReturnCtx(input, ctx);
+ addIssueToContext(ctx, {
+ validation: "cidr",
+ code: ZodIssueCode.invalid_string,
+ message: check.message,
+ });
+ status.dirty();
+ }
} else if (check.kind === "base64") {
if (!base64Regex.test(input.data)) {
ctx = this._getOrReturnCtx(input, ctx);
@@ -1006,6 +1048,10 @@ export class ZodString extends ZodType<string, ZodStringDef, string> {
return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
}
+ cidr(options?: string | { version?: IpVersion; message?: string }) {
+ return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
+ }
+
datetime(
options?:
| string
@@ -1199,6 +1245,9 @@ export class ZodString extends ZodType<string, ZodStringDef, string> {
get isIP() {
return !!this._def.checks.find((ch) => ch.kind === "ip");
}
+ get isCIDR() {
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
+ }
get isBase64() {
return !!this._def.checks.find((ch) => ch.kind === "base64");
}
@@ -2154,8 +2203,9 @@ export class ZodVoid extends ZodType<void, ZodVoidDef, void> {
////////// //////////
////////////////////////////////////////
////////////////////////////////////////
-export interface ZodArrayDef<T extends ZodTypeAny = ZodTypeAny>
- extends ZodTypeDef {
+export interface ZodArrayDef<
+ T extends ZodTypeAny = ZodTypeAny,
+> extends ZodTypeDef {
type: T;
typeName: ZodFirstPartyTypeKind.ZodArray;
exactLength: { value: number; message?: string } | null;
@@ -2166,14 +2216,14 @@ export interface ZodArrayDef<T extends ZodTypeAny = ZodTypeAny>
export type ArrayCardinality = "many" | "atleastone";
export type arrayOutputType<
T extends ZodTypeAny,
- Cardinality extends ArrayCardinality = "many"
+ Cardinality extends ArrayCardinality = "many",
> = Cardinality extends "atleastone"
? [T["_output"], ...T["_output"][]]
: T["_output"][];
export class ZodArray<
T extends ZodTypeAny,
- Cardinality extends ArrayCardinality = "many"
+ Cardinality extends ArrayCardinality = "many",
> extends ZodType<
arrayOutputType<T, Cardinality>,
ZodArrayDef<T>,
@@ -2320,7 +2370,7 @@ export type UnknownKeysParam = "passthrough" | "strict" | "strip";
export interface ZodObjectDef<
T extends ZodRawShape = ZodRawShape,
UnknownKeys extends UnknownKeysParam = UnknownKeysParam,
- Catchall extends ZodTypeAny = ZodTypeAny
+ Catchall extends ZodTypeAny = ZodTypeAny,
> extends ZodTypeDef {
typeName: ZodFirstPartyTypeKind.ZodObject;
shape: () => T;
@@ -2332,14 +2382,14 @@ export type mergeTypes<A, B> = {
[k in keyof A | keyof B]: k extends keyof B
? B[k]
: k extends keyof A
- ? A[k]
- : never;
+ ? A[k]
+ : never;
};
export type objectOutputType<
Shape extends ZodRawShape,
Catchall extends ZodTypeAny,
- UnknownKeys extends UnknownKeysParam = UnknownKeysParam
+ UnknownKeys extends UnknownKeysParam = UnknownKeysParam,
> = objectUtil.flatten<
objectUtil.addQuestionMarks<baseObjectOutputType<Shape>>
> &
@@ -2353,7 +2403,7 @@ export type baseObjectOutputType<Shape extends ZodRawShape> = {
export type objectInputType<
Shape extends ZodRawShape,
Catchall extends ZodTypeAny,
- UnknownKeys extends UnknownKeysParam = UnknownKeysParam
+ UnknownKeys extends UnknownKeysParam = UnknownKeysParam,
> = objectUtil.flatten<baseObjectInputType<Shape>> &
CatchallInput<Catchall> &
PassthroughType<UnknownKeys>;
@@ -2373,11 +2423,12 @@ export type CatchallInput<T extends ZodType> = ZodType extends T
export type PassthroughType<T extends UnknownKeysParam> =
T extends "passthrough" ? { [k: string]: unknown } : unknown;
-export type deoptional<T extends ZodTypeAny> = T extends ZodOptional<infer U>
- ? deoptional<U>
- : T extends ZodNullable<infer U>
- ? ZodNullable<deoptional<U>>
- : T;
+export type deoptional<T extends ZodTypeAny> =
+ T extends ZodOptional<infer U>
+ ? deoptional<U>
+ : T extends ZodNullable<infer U>
+ ? ZodNullable<deoptional<U>>
+ : T;
export type SomeZodObject = ZodObject<
ZodRawShape,
@@ -2424,7 +2475,7 @@ export class ZodObject<
UnknownKeys extends UnknownKeysParam = UnknownKeysParam,
Catchall extends ZodTypeAny = ZodTypeAny,
Output = objectOutputType<T, Catchall, UnknownKeys>,
- Input = objectInputType<T, Catchall, UnknownKeys>
+ Input = objectInputType<T, Catchall, UnknownKeys>,
> extends ZodType<Output, ZodObjectDef<T, UnknownKeys, Catchall>, Input> {
private _cached: { shape: T; keys: string[] } | null = null;
@@ -2929,7 +2980,7 @@ export type ZodUnionOptions = Readonly<[ZodTypeAny, ...ZodTypeAny[]]>;
export interface ZodUnionDef<
T extends ZodUnionOptions = Readonly<
[ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]
- >
+ >,
> extends ZodTypeDef {
options: T;
typeName: ZodFirstPartyTypeKind.ZodUnion;
@@ -3046,7 +3097,7 @@ export class ZodUnion<T extends ZodUnionOptions> extends ZodType<
}
static create = <
- T extends Readonly<[ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>
+ T extends Readonly<[ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>,
>(
types: T,
params?: RawCreateParams
@@ -3109,7 +3160,8 @@ export type ZodDiscriminatedUnionOption<Discriminator extends string> =
export interface ZodDiscriminatedUnionDef<
Discriminator extends string,
- Options extends ZodDiscriminatedUnionOption<string>[] = ZodDiscriminatedUnionOption<string>[]
+ Options extends ZodDiscriminatedUnionOption<string>[] =
+ ZodDiscriminatedUnionOption<string>[],
> extends ZodTypeDef {
discriminator: Discriminator;
options: Options;
@@ -3119,7 +3171,7 @@ export interface ZodDiscriminatedUnionDef<
export class ZodDiscriminatedUnion<
Discriminator extends string,
- Options extends ZodDiscriminatedUnionOption<Discriminator>[]
+ Options extends ZodDiscriminatedUnionOption<Discriminator>[],
> extends ZodType<
output<Options[number]>,
ZodDiscriminatedUnionDef<Discriminator, Options>,
@@ -3191,8 +3243,8 @@ export class ZodDiscriminatedUnion<
Discriminator extends string,
Types extends [
ZodDiscriminatedUnionOption<Discriminator>,
- ...ZodDiscriminatedUnionOption<Discriminator>[]
- ]
+ ...ZodDiscriminatedUnionOption<Discriminator>[],
+ ],
>(
discriminator: Discriminator,
options: Types,
@@ -3245,7 +3297,7 @@ export class ZodDiscriminatedUnion<
///////////////////////////////////////////////
export interface ZodIntersectionDef<
T extends ZodTypeAny = ZodTypeAny,
- U extends ZodTypeAny = ZodTypeAny
+ U extends ZodTypeAny = ZodTypeAny,
> extends ZodTypeDef {
left: T;
right: U;
@@ -3309,7 +3361,7 @@ function mergeValues(
export class ZodIntersection<
T extends ZodTypeAny,
- U extends ZodTypeAny
+ U extends ZodTypeAny,
> extends ZodType<
T["_output"] & U["_output"],
ZodIntersectionDef<T, U>,
@@ -3398,7 +3450,7 @@ export type OutputTypeOfTuple<T extends ZodTupleItems | []> = AssertArray<{
}>;
export type OutputTypeOfTupleWithRest<
T extends ZodTupleItems | [],
- Rest extends ZodTypeAny | null = null
+ Rest extends ZodTypeAny | null = null,
> = Rest extends ZodTypeAny
? [...OutputTypeOfTuple<T>, ...Rest["_output"][]]
: OutputTypeOfTuple<T>;
@@ -3408,14 +3460,14 @@ export type InputTypeOfTuple<T extends ZodTupleItems | []> = AssertArray<{
}>;
export type InputTypeOfTupleWithRest<
T extends ZodTupleItems | [],
- Rest extends ZodTypeAny | null = null
+ Rest extends ZodTypeAny | null = null,
> = Rest extends ZodTypeAny
? [...InputTypeOfTuple<T>, ...Rest["_input"][]]
: InputTypeOfTuple<T>;
export interface ZodTupleDef<
T extends ZodTupleItems | [] = ZodTupleItems,
- Rest extends ZodTypeAny | null = null
+ Rest extends ZodTypeAny | null = null,
> extends ZodTypeDef {
items: T;
rest: Rest;
@@ -3428,7 +3480,7 @@ export type AnyZodTuple = ZodTuple<
>;
export class ZodTuple<
T extends [ZodTypeAny, ...ZodTypeAny[]] | [] = [ZodTypeAny, ...ZodTypeAny[]],
- Rest extends ZodTypeAny | null = null
+ Rest extends ZodTypeAny | null = null,
> extends ZodType<
OutputTypeOfTupleWithRest<T, Rest>,
ZodTupleDef<T, Rest>,
@@ -3525,7 +3577,7 @@ export class ZodTuple<
/////////////////////////////////////////
export interface ZodRecordDef<
Key extends KeySchema = ZodString,
- Value extends ZodTypeAny = ZodTypeAny
+ Value extends ZodTypeAny = ZodTypeAny,
> extends ZodTypeDef {
valueType: Value;
keyType: Key;
@@ -3534,19 +3586,19 @@ export interface ZodRecordDef<
export type KeySchema = ZodType<string | number | symbol, any, any>;
export type RecordType<K extends string | number | symbol, V> = [
- string
+ string,
] extends [K]
? Record<K, V>
: [number] extends [K]
- ? Record<K, V>
- : [symbol] extends [K]
- ? Record<K, V>
- : [BRAND<string | number | symbol>] extends [K]
- ? Record<K, V>
- : Partial<Record<K, V>>;
+ ? Record<K, V>
+ : [symbol] extends [K]
+ ? Record<K, V>
+ : [BRAND<string | number | symbol>] extends [K]
+ ? Record<K, V>
+ : Partial<Record<K, V>>;
export class ZodRecord<
Key extends KeySchema = ZodString,
- Value extends ZodTypeAny = ZodTypeAny
+ Value extends ZodTypeAny = ZodTypeAny,
> extends ZodType<
RecordType<Key["_output"], Value["_output"]>,
ZodRecordDef<Key, Value>,
@@ -3636,7 +3688,7 @@ export class ZodRecord<
//////////////////////////////////////
export interface ZodMapDef<
Key extends ZodTypeAny = ZodTypeAny,
- Value extends ZodTypeAny = ZodTypeAny
+ Value extends ZodTypeAny = ZodTypeAny,
> extends ZodTypeDef {
valueType: Value;
keyType: Key;
@@ -3645,7 +3697,7 @@ export interface ZodMapDef<
export class ZodMap<
Key extends ZodTypeAny = ZodTypeAny,
- Value extends ZodTypeAny = ZodTypeAny
+ Value extends ZodTypeAny = ZodTypeAny,
> extends ZodType<
Map<Key["_output"], Value["_output"]>,
ZodMapDef<Key, Value>,
@@ -3720,7 +3772,7 @@ export class ZodMap<
}
static create = <
Key extends ZodTypeAny = ZodTypeAny,
- Value extends ZodTypeAny = ZodTypeAny
+ Value extends ZodTypeAny = ZodTypeAny,
>(
keyType: Key,
valueType: Value,
@@ -3742,8 +3794,9 @@ export class ZodMap<
////////// //////////
//////////////////////////////////////
//////////////////////////////////////
-export interface ZodSetDef<Value extends ZodTypeAny = ZodTypeAny>
- extends ZodTypeDef {
+export interface ZodSetDef<
+ Value extends ZodTypeAny = ZodTypeAny,
+> extends ZodTypeDef {
valueType: Value;
typeName: ZodFirstPartyTypeKind.ZodSet;
minSize: { value: number; message?: string } | null;
@@ -3864,7 +3917,7 @@ export class ZodSet<Value extends ZodTypeAny = ZodTypeAny> extends ZodType<
///////////////////////////////////////////
export interface ZodFunctionDef<
Args extends ZodTuple<any, any> = ZodTuple<any, any>,
- Returns extends ZodTypeAny = ZodTypeAny
+ Returns extends ZodTypeAny = ZodTypeAny,
> extends ZodTypeDef {
args: Args;
returns: Returns;
@@ -3873,21 +3926,23 @@ export interface ZodFunctionDef<
export type OuterTypeOfFunction<
Args extends ZodTuple<any, any>,
- Returns extends ZodTypeAny
-> = Args["_input"] extends Array<any>
- ? (...args: Args["_input"]) => Returns["_output"]
- : never;
+ Returns extends ZodTypeAny,
+> =
+ Args["_input"] extends Array<any>
+ ? (...args: Args["_input"]) => Returns["_output"]
+ : never;
export type InnerTypeOfFunction<
Args extends ZodTuple<any, any>,
- Returns extends ZodTypeAny
-> = Args["_output"] extends Array<any>
- ? (...args: Args["_output"]) => Returns["_input"]
- : never;
+ Returns extends ZodTypeAny,
+> =
+ Args["_output"] extends Array<any>
+ ? (...args: Args["_output"]) => Returns["_input"]
+ : never;
export class ZodFunction<
Args extends ZodTuple<any, any>,
- Returns extends ZodTypeAny
+ Returns extends ZodTypeAny,
> extends ZodType<
OuterTypeOfFunction<Args, Returns>,
ZodFunctionDef<Args, Returns>,
@@ -4039,7 +4094,7 @@ export class ZodFunction<
): ZodFunction<T, U>;
static create<
T extends AnyZodTuple = ZodTuple<[], ZodUnknown>,
- U extends ZodTypeAny = ZodUnknown
+ U extends ZodTypeAny = ZodUnknown,
>(args: T, returns: U, params?: RawCreateParams): ZodFunction<T, U>;
static create(
args?: AnyZodTuple,
@@ -4064,8 +4119,9 @@ export class ZodFunction<
////////// //////////
///////////////////////////////////////
///////////////////////////////////////
-export interface ZodLazyDef<T extends ZodTypeAny = ZodTypeAny>
- extends ZodTypeDef {
+export interface ZodLazyDef<
+ T extends ZodTypeAny = ZodTypeAny,
+> extends ZodTypeDef {
getter: () => T;
typeName: ZodFirstPartyTypeKind.ZodLazy;
}
@@ -4155,8 +4211,9 @@ export type Values<T extends EnumValues> = {
[k in T[number]]: k;
};
-export interface ZodEnumDef<T extends EnumValues = EnumValues>
- extends ZodTypeDef {
+export interface ZodEnumDef<
+ T extends EnumValues = EnumValues,
+> extends ZodTypeDef {
values: T;
typeName: ZodFirstPartyTypeKind.ZodEnum;
}
@@ -4166,10 +4223,10 @@ export type Writeable<T> = { -readonly [P in keyof T]: T[P] };
export type FilterEnum<Values, ToExclude> = Values extends []
? []
: Values extends [infer Head, ...infer Rest]
- ? Head extends ToExclude
- ? FilterEnum<Rest, ToExclude>
- : [Head, ...FilterEnum<Rest, ToExclude>]
- : never;
+ ? Head extends ToExclude
+ ? FilterEnum<Rest, ToExclude>
+ : [Head, ...FilterEnum<Rest, ToExclude>]
+ : never;
export type typecast<A, T> = A extends T ? A : never;
@@ -4295,8 +4352,9 @@ export class ZodEnum<T extends [string, ...string[]]> extends ZodType<
////////// //////////
/////////////////////////////////////////////
/////////////////////////////////////////////
-export interface ZodNativeEnumDef<T extends EnumLike = EnumLike>
- extends ZodTypeDef {
+export interface ZodNativeEnumDef<
+ T extends EnumLike = EnumLike,
+> extends ZodTypeDef {
values: T;
typeName: ZodFirstPartyTypeKind.ZodNativeEnum;
}
@@ -4366,8 +4424,9 @@ export class ZodNativeEnum<T extends EnumLike> extends ZodType<
////////// //////////
//////////////////////////////////////////
//////////////////////////////////////////
-export interface ZodPromiseDef<T extends ZodTypeAny = ZodTypeAny>
- extends ZodTypeDef {
+export interface ZodPromiseDef<
+ T extends ZodTypeAny = ZodTypeAny,
+> extends ZodTypeDef {
type: T;
typeName: ZodFirstPartyTypeKind.ZodPromise;
}
@@ -4453,8 +4512,9 @@ export type Effect<T> =
| TransformEffect<T>
| PreprocessEffect<T>;
-export interface ZodEffectsDef<T extends ZodTypeAny = ZodTypeAny>
- extends ZodTypeDef {
+export interface ZodEffectsDef<
+ T extends ZodTypeAny = ZodTypeAny,
+> extends ZodTypeDef {
schema: T;
typeName: ZodFirstPartyTypeKind.ZodEffects;
effect: Effect<any>;
@@ -4463,7 +4523,7 @@ export interface ZodEffectsDef<T extends ZodTypeAny = ZodTypeAny>
export class ZodEffects<
T extends ZodTypeAny,
Output = output<T>,
- Input = input<T>
+ Input = input<T>,
> extends ZodType<Output, ZodEffectsDef<T>, Input> {
innerType() {
return this._def.schema;
@@ -4636,8 +4696,9 @@ export { ZodEffects as ZodTransformer };
////////// //////////
///////////////////////////////////////////
///////////////////////////////////////////
-export interface ZodOptionalDef<T extends ZodTypeAny = ZodTypeAny>
- extends ZodTypeDef {
+export interface ZodOptionalDef<
+ T extends ZodTypeAny = ZodTypeAny,
+> extends ZodTypeDef {
innerType: T;
typeName: ZodFirstPartyTypeKind.ZodOptional;
}
@@ -4680,8 +4741,9 @@ export class ZodOptional<T extends ZodTypeAny> extends ZodType<
////////// //////////
///////////////////////////////////////////
///////////////////////////////////////////
-export interface ZodNullableDef<T extends ZodTypeAny = ZodTypeAny>
- extends ZodTypeDef {
+export interface ZodNullableDef<
+ T extends ZodTypeAny = ZodTypeAny,
+> extends ZodTypeDef {
innerType: T;
typeName: ZodFirstPartyTypeKind.ZodNullable;
}
@@ -4724,8 +4786,9 @@ export class ZodNullable<T extends ZodTypeAny> extends ZodType<
////////// //////////
////////////////////////////////////////////
////////////////////////////////////////////
-export interface ZodDefaultDef<T extends ZodTypeAny = ZodTypeAny>
- extends ZodTypeDef {
+export interface ZodDefaultDef<
+ T extends ZodTypeAny = ZodTypeAny,
+> extends ZodTypeDef {
innerType: T;
defaultValue: () => util.noUndefined<T["_input"]>;
typeName: ZodFirstPartyTypeKind.ZodDefault;
@@ -4778,8 +4841,9 @@ export class ZodDefault<T extends ZodTypeAny> extends ZodType<
////////// //////////
//////////////////////////////////////////
//////////////////////////////////////////
-export interface ZodCatchDef<T extends ZodTypeAny = ZodTypeAny>
- extends ZodTypeDef {
+export interface ZodCatchDef<
+ T extends ZodTypeAny = ZodTypeAny,
+> extends ZodTypeDef {
innerType: T;
catchValue: (ctx: { error: ZodError; input: unknown }) => T["_input"];
typeName: ZodFirstPartyTypeKind.ZodCatch;
@@ -4917,7 +4981,7 @@ export type BRAND<T extends string | number | symbol> = {
export class ZodBranded<
T extends ZodTypeAny,
- B extends string | number | symbol
+ B extends string | number | symbol,
> extends ZodType<T["_output"] & BRAND<B>, ZodBrandedDef<T>, T["_input"]> {
_parse(input: ParseInput): ParseReturnType<any> {
const { ctx } = this._processInputParams(input);
@@ -4942,8 +5006,10 @@ export class ZodBranded<
////////////////////////////////////////////
////////////////////////////////////////////
-export interface ZodPipelineDef<A extends ZodTypeAny, B extends ZodTypeAny>
- extends ZodTypeDef {
+export interface ZodPipelineDef<
+ A extends ZodTypeAny,
+ B extends ZodTypeAny,
+> extends ZodTypeDef {
in: A;
out: B;
typeName: ZodFirstPartyTypeKind.ZodPipeline;
@@ -4951,7 +5017,7 @@ export interface ZodPipelineDef<A extends ZodTypeAny, B extends ZodTypeAny>
export class ZodPipeline<
A extends ZodTypeAny,
- B extends ZodTypeAny
+ B extends ZodTypeAny,
> extends ZodType<B["_output"], ZodPipelineDef<A, B>, A["_input"]> {
_parse(input: ParseInput): ParseReturnType<any> {
const { status, ctx } = this._processInputParams(input);
@@ -5026,20 +5092,22 @@ type BuiltIn =
| Promise<unknown>
| RegExp;
-type MakeReadonly<T> = T extends Map<infer K, infer V>
- ? ReadonlyMap<K, V>
- : T extends Set<infer V>
- ? ReadonlySet<V>
- : T extends [infer Head, ...infer Tail]
- ? readonly [Head, ...Tail]
- : T extends Array<infer V>
- ? ReadonlyArray<V>
- : T extends BuiltIn
- ? T
- : Readonly<T>;
-
-export interface ZodReadonlyDef<T extends ZodTypeAny = ZodTypeAny>
- extends ZodTypeDef {
+type MakeReadonly<T> =
+ T extends Map<infer K, infer V>
+ ? ReadonlyMap<K, V>
+ : T extends Set<infer V>
+ ? ReadonlySet<V>
+ : T extends [infer Head, ...infer Tail]
+ ? readonly [Head, ...Tail]
+ : T extends Array<infer V>
+ ? ReadonlyArray<V>
+ : T extends BuiltIn
+ ? T
+ : Readonly<T>;
+
+export interface ZodReadonlyDef<
+ T extends ZodTypeAny = ZodTypeAny,
+> extends ZodTypeDef {
innerType: T;
typeName: ZodFirstPartyTypeKind.ZodReadonly;
}
@@ -5108,8 +5176,8 @@ export function custom<T>(
typeof params === "function"
? params(data)
: typeof params === "string"
- ? { message: params }
- : params;
+ ? { message: params }
+ : params;
const _fatal = p.fatal ?? fatal ?? true;
const p2 = typeof p === "string" ? { message: p } : p;
ctx.addIssue({ code: "custom", ...p2, fatal: _fatal });
diff --git a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-4/app/src/ZodError.ts b/app/src/ZodError.ts
index c1f7aa3..8c2acbd 100644
--- a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-4/app/src/ZodError.ts
+++ b/app/src/ZodError.ts
@@ -6,7 +6,7 @@ type allKeys<T> = T extends any ? keyof T : never;
export type inferFlattenedErrors<
T extends ZodType<any, any, any>,
- U = string
+ U = string,
> = typeToFlattenedError<TypeOf<T>, U>;
export type typeToFlattenedError<T, U = string> = {
formErrors: U[];
@@ -103,6 +103,7 @@ export type StringValidation =
| "time"
| "duration"
| "ip"
+ | "cidr"
| "base64"
| { includes: string; position?: number }
| { startsWith: string }
@@ -180,10 +181,10 @@ export const quotelessJson = (obj: any) => {
type recursiveZodFormattedError<T> = T extends [any, ...any[]]
? { [K in keyof T]?: ZodFormattedError<T[K]> }
: T extends any[]
- ? { [k: number]: ZodFormattedError<T[number]> }
- : T extends object
- ? { [K in keyof T]?: ZodFormattedError<T[K]> }
- : unknown;
+ ? { [k: number]: ZodFormattedError<T[number]> }
+ : T extends object
+ ? { [K in keyof T]?: ZodFormattedError<T[K]> }
+ : unknown;
export type ZodFormattedError<T, U = string> = {
_errors: U[];
@@ -191,7 +192,7 @@ export type ZodFormattedError<T, U = string> = {
export type inferFormattedError<
T extends ZodType<any, any, any>,
- U = string
+ U = string,
> = ZodFormattedError<TypeOf<T>, U>;
export class ZodError<T = any> extends Error {
diff --git a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-4/app/src/__tests__/string.test.ts b/app/src/__tests__/string.test.ts
index f7037fc..d1f8ce4 100644
--- a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-4/app/src/__tests__/string.test.ts
+++ b/app/src/__tests__/string.test.ts
@@ -426,6 +426,9 @@ test("checks getters", () => {
expect(z.string().ip().isUUID).toEqual(false);
expect(z.string().ip().isNANOID).toEqual(false);
expect(z.string().ip().isIP).toEqual(true);
+ expect(z.string().ip().isCIDR).toEqual(false);
+ expect(z.string().cidr().isIP).toEqual(false);
+ expect(z.string().cidr().isCIDR).toEqual(true);
expect(z.string().ip().isULID).toEqual(false);
expect(z.string().ulid().isEmail).toEqual(false);
@@ -768,3 +771,46 @@ test("IP validation", () => {
invalidIPs.every((ip) => ipSchema.safeParse(ip).success === false)
).toBe(true);
});
+
+test("CIDR validation", () => {
+ const cidr = z.string().cidr();
+ expect(cidr.safeParse("192.168.0.0/24").success).toBe(true);
+ expect(cidr.safeParse("2001:db8::/32").success).toBe(true);
+
+ const ipv4Cidr = z.string().cidr({ version: "v4" });
+ expect(ipv4Cidr.safeParse("10.0.0.0/8").success).toBe(true);
+ expect(() => ipv4Cidr.parse("2001:db8::/32")).toThrow();
+
+ const ipv6Cidr = z.string().cidr({ version: "v6" });
+ expect(ipv6Cidr.safeParse("2001:db8::/48").success).toBe(true);
+ expect(() => ipv6Cidr.parse("10.0.0.0/8")).toThrow();
+
+ const validCidrs = [
+ "0.0.0.0/0",
+ "192.168.1.0/24",
+ "255.255.255.255/32",
+ "2001:db8::/32",
+ "::1/128",
+ "::ffff:192.168.1.1/128",
+ ];
+ const invalidCidrs = [
+ "192.168.1.1",
+ "192.168.1.0/-1",
+ "192.168.1.0/33",
+ "256.0.0.0/24",
+ "2001:db8::/129",
+ "2001:db8::/-1",
+ "2001:db8::",
+ "10.0.0.0/",
+ "/24",
+ "10.0.0.0/24/1",
+ ];
+
+ expect(validCidrs.every((value) => cidr.safeParse(value).success)).toBe(true);
+ expect(
+ invalidCidrs.every((value) => cidr.safeParse(value).success === false)
+ ).toBe(true);
+ expect(cidr.safeParse("10.0.0.0/33").error?.issues[0].message).toEqual(
+ "Invalid CIDR block"
+ );
+});
diff --git a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-4/app/src/locales/en.ts b/app/src/locales/en.ts
index 11325a9..76b131b 100644
--- a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-4/app/src/locales/en.ts
+++ b/app/src/locales/en.ts
@@ -61,7 +61,13 @@ const errorMap: ZodErrorMap = (issue, _ctx) => {
util.assertNever(issue.validation);
}
} else if (issue.validation !== "regex") {
- message = `Invalid ${issue.validation}`;
+ if (issue.validation === "ip") {
+ message = "Invalid IP address";
+ } else if (issue.validation === "cidr") {
+ message = "Invalid CIDR block";
+ } else {
+ message = `Invalid ${issue.validation}`;
+ }
} else {
message = "Invalid";
}
@@ -80,16 +86,16 @@ const errorMap: ZodErrorMap = (issue, _ctx) => {
issue.exact
? `exactly equal to `
: issue.inclusive
- ? `greater than or equal to `
- : `greater than `
+ ? `greater than or equal to `
+ : `greater than `
}${issue.minimum}`;
else if (issue.type === "date")
message = `Date must be ${
issue.exact
? `exactly equal to `
: issue.inclusive
- ? `greater than or equal to `
- : `greater than `
+ ? `greater than or equal to `
+ : `greater than `
}${new Date(Number(issue.minimum))}`;
else message = "Invalid input";
break;
@@ -107,24 +113,24 @@ const errorMap: ZodErrorMap = (issue, _ctx) => {
issue.exact
? `exactly`
: issue.inclusive
- ? `less than or equal to`
- : `less than`
+ ? `less than or equal to`
+ : `less than`
} ${issue.maximum}`;
else if (issue.type === "bigint")
message = `BigInt must be ${
issue.exact
? `exactly`
: issue.inclusive
- ? `less than or equal to`
- : `less than`
+ ? `less than or equal to`
+ : `less than`
} ${issue.maximum}`;
else if (issue.type === "date")
message = `Date must be ${
issue.exact
? `exactly`
: issue.inclusive
- ? `smaller than or equal to`
- : `smaller than`
+ ? `smaller than or equal to`
+ : `smaller than`
} ${new Date(Number(issue.maximum))}`;
else message = "Invalid input";
break;
diff --git a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-4/app/src/types.ts b/app/src/types.ts
index be49c70..00bcf77 100644
--- a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-4/app/src/types.ts
+++ b/app/src/types.ts
@@ -168,7 +168,7 @@ export type SafeParseReturnType<Input, Output> =
export abstract class ZodType<
Output = any,
Def extends ZodTypeDef = ZodTypeDef,
- Input = Output
+ Input = Output,
> {
readonly _type!: Output;
readonly _output!: Output;
@@ -565,6 +565,7 @@ export type ZodStringCheck =
}
| { kind: "duration"; message?: string }
| { kind: "ip"; version?: IpVersion; message?: string }
+ | { kind: "cidr"; version?: IpVersion; message?: string }
| { kind: "base64"; message?: string };
export interface ZodStringDef extends ZodTypeDef {
@@ -671,6 +672,32 @@ function isValidIP(ip: string, version?: IpVersion) {
return false;
}
+function isValidCidr(cidr: string, version?: IpVersion) {
+ const parts = cidr.split("/");
+ if (parts.length !== 2) {
+ return false;
+ }
+
+ const [ip, prefix] = parts;
+ if (!/^\d+$/.test(prefix) || !isValidIP(ip, version)) {
+ return false;
+ }
+
+ const prefixNum = Number(prefix);
+ if (version === "v4") {
+ return prefixNum >= 0 && prefixNum <= 32;
+ }
+ if (version === "v6") {
+ return prefixNum >= 0 && prefixNum <= 128;
+ }
+
+ if (ipv4Regex.test(ip)) {
+ return prefixNum >= 0 && prefixNum <= 32;
+ }
+
+ return ipv6Regex.test(ip) && prefixNum >= 0 && prefixNum <= 128;
+}
+
export class ZodString extends ZodType<string, ZodStringDef, string> {
_parse(input: ParseInput): ParseReturnType<string> {
if (this._def.coerce) {
@@ -933,6 +960,16 @@ export class ZodString extends ZodType<string, ZodStringDef, string> {
});
status.dirty();
}
+ } else if (check.kind === "cidr") {
+ if (!isValidCidr(input.data, check.version)) {
+ ctx = this._getOrReturnCtx(input, ctx);
+ addIssueToContext(ctx, {
+ validation: "cidr",
+ code: ZodIssueCode.invalid_string,
+ message: check.message,
+ });
+ status.dirty();
+ }
} else if (check.kind === "base64") {
if (!base64Regex.test(input.data)) {
ctx = this._getOrReturnCtx(input, ctx);
@@ -1006,6 +1043,10 @@ export class ZodString extends ZodType<string, ZodStringDef, string> {
return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
}
+ cidr(options?: string | { version?: IpVersion; message?: string }) {
+ return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
+ }
+
datetime(
options?:
| string
@@ -1199,6 +1240,9 @@ export class ZodString extends ZodType<string, ZodStringDef, string> {
get isIP() {
return !!this._def.checks.find((ch) => ch.kind === "ip");
}
+ get isCIDR() {
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
+ }
get isBase64() {
return !!this._def.checks.find((ch) => ch.kind === "base64");
}
@@ -2154,8 +2198,9 @@ export class ZodVoid extends ZodType<void, ZodVoidDef, void> {
////////// //////////
////////////////////////////////////////
////////////////////////////////////////
-export interface ZodArrayDef<T extends ZodTypeAny = ZodTypeAny>
- extends ZodTypeDef {
+export interface ZodArrayDef<
+ T extends ZodTypeAny = ZodTypeAny,
+> extends ZodTypeDef {
type: T;
typeName: ZodFirstPartyTypeKind.ZodArray;
exactLength: { value: number; message?: string } | null;
@@ -2166,14 +2211,14 @@ export interface ZodArrayDef<T extends ZodTypeAny = ZodTypeAny>
export type ArrayCardinality = "many" | "atleastone";
export type arrayOutputType<
T extends ZodTypeAny,
- Cardinality extends ArrayCardinality = "many"
+ Cardinality extends ArrayCardinality = "many",
> = Cardinality extends "atleastone"
? [T["_output"], ...T["_output"][]]
: T["_output"][];
export class ZodArray<
T extends ZodTypeAny,
- Cardinality extends ArrayCardinality = "many"
+ Cardinality extends ArrayCardinality = "many",
> extends ZodType<
arrayOutputType<T, Cardinality>,
ZodArrayDef<T>,
@@ -2320,7 +2365,7 @@ export type UnknownKeysParam = "passthrough" | "strict" | "strip";
export interface ZodObjectDef<
T extends ZodRawShape = ZodRawShape,
UnknownKeys extends UnknownKeysParam = UnknownKeysParam,
- Catchall extends ZodTypeAny = ZodTypeAny
+ Catchall extends ZodTypeAny = ZodTypeAny,
> extends ZodTypeDef {
typeName: ZodFirstPartyTypeKind.ZodObject;
shape: () => T;
@@ -2332,14 +2377,14 @@ export type mergeTypes<A, B> = {
[k in keyof A | keyof B]: k extends keyof B
? B[k]
: k extends keyof A
- ? A[k]
- : never;
+ ? A[k]
+ : never;
};
export type objectOutputType<
Shape extends ZodRawShape,
Catchall extends ZodTypeAny,
- UnknownKeys extends UnknownKeysParam = UnknownKeysParam
+ UnknownKeys extends UnknownKeysParam = UnknownKeysParam,
> = objectUtil.flatten<
objectUtil.addQuestionMarks<baseObjectOutputType<Shape>>
> &
@@ -2353,7 +2398,7 @@ export type baseObjectOutputType<Shape extends ZodRawShape> = {
export type objectInputType<
Shape extends ZodRawShape,
Catchall extends ZodTypeAny,
- UnknownKeys extends UnknownKeysParam = UnknownKeysParam
+ UnknownKeys extends UnknownKeysParam = UnknownKeysParam,
> = objectUtil.flatten<baseObjectInputType<Shape>> &
CatchallInput<Catchall> &
PassthroughType<UnknownKeys>;
@@ -2373,11 +2418,12 @@ export type CatchallInput<T extends ZodType> = ZodType extends T
export type PassthroughType<T extends UnknownKeysParam> =
T extends "passthrough" ? { [k: string]: unknown } : unknown;
-export type deoptional<T extends ZodTypeAny> = T extends ZodOptional<infer U>
- ? deoptional<U>
- : T extends ZodNullable<infer U>
- ? ZodNullable<deoptional<U>>
- : T;
+export type deoptional<T extends ZodTypeAny> =
+ T extends ZodOptional<infer U>
+ ? deoptional<U>
+ : T extends ZodNullable<infer U>
+ ? ZodNullable<deoptional<U>>
+ : T;
export type SomeZodObject = ZodObject<
ZodRawShape,
@@ -2424,7 +2470,7 @@ export class ZodObject<
UnknownKeys extends UnknownKeysParam = UnknownKeysParam,
Catchall extends ZodTypeAny = ZodTypeAny,
Output = objectOutputType<T, Catchall, UnknownKeys>,
- Input = objectInputType<T, Catchall, UnknownKeys>
+ Input = objectInputType<T, Catchall, UnknownKeys>,
> extends ZodType<Output, ZodObjectDef<T, UnknownKeys, Catchall>, Input> {
private _cached: { shape: T; keys: string[] } | null = null;
@@ -2929,7 +2975,7 @@ export type ZodUnionOptions = Readonly<[ZodTypeAny, ...ZodTypeAny[]]>;
export interface ZodUnionDef<
T extends ZodUnionOptions = Readonly<
[ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]
- >
+ >,
> extends ZodTypeDef {
options: T;
typeName: ZodFirstPartyTypeKind.ZodUnion;
@@ -3046,7 +3092,7 @@ export class ZodUnion<T extends ZodUnionOptions> extends ZodType<
}
static create = <
- T extends Readonly<[ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>
+ T extends Readonly<[ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>,
>(
types: T,
params?: RawCreateParams
@@ -3109,7 +3155,8 @@ export type ZodDiscriminatedUnionOption<Discriminator extends string> =
export interface ZodDiscriminatedUnionDef<
Discriminator extends string,
- Options extends ZodDiscriminatedUnionOption<string>[] = ZodDiscriminatedUnionOption<string>[]
+ Options extends ZodDiscriminatedUnionOption<string>[] =
+ ZodDiscriminatedUnionOption<string>[],
> extends ZodTypeDef {
discriminator: Discriminator;
options: Options;
@@ -3119,7 +3166,7 @@ export interface ZodDiscriminatedUnionDef<
export class ZodDiscriminatedUnion<
Discriminator extends string,
- Options extends ZodDiscriminatedUnionOption<Discriminator>[]
+ Options extends ZodDiscriminatedUnionOption<Discriminator>[],
> extends ZodType<
output<Options[number]>,
ZodDiscriminatedUnionDef<Discriminator, Options>,
@@ -3191,8 +3238,8 @@ export class ZodDiscriminatedUnion<
Discriminator extends string,
Types extends [
ZodDiscriminatedUnionOption<Discriminator>,
- ...ZodDiscriminatedUnionOption<Discriminator>[]
- ]
+ ...ZodDiscriminatedUnionOption<Discriminator>[],
+ ],
>(
discriminator: Discriminator,
options: Types,
@@ -3245,7 +3292,7 @@ export class ZodDiscriminatedUnion<
///////////////////////////////////////////////
export interface ZodIntersectionDef<
T extends ZodTypeAny = ZodTypeAny,
- U extends ZodTypeAny = ZodTypeAny
+ U extends ZodTypeAny = ZodTypeAny,
> extends ZodTypeDef {
left: T;
right: U;
@@ -3309,7 +3356,7 @@ function mergeValues(
export class ZodIntersection<
T extends ZodTypeAny,
- U extends ZodTypeAny
+ U extends ZodTypeAny,
> extends ZodType<
T["_output"] & U["_output"],
ZodIntersectionDef<T, U>,
@@ -3398,7 +3445,7 @@ export type OutputTypeOfTuple<T extends ZodTupleItems | []> = AssertArray<{
}>;
export type OutputTypeOfTupleWithRest<
T extends ZodTupleItems | [],
- Rest extends ZodTypeAny | null = null
+ Rest extends ZodTypeAny | null = null,
> = Rest extends ZodTypeAny
? [...OutputTypeOfTuple<T>, ...Rest["_output"][]]
: OutputTypeOfTuple<T>;
@@ -3408,14 +3455,14 @@ export type InputTypeOfTuple<T extends ZodTupleItems | []> = AssertArray<{
}>;
export type InputTypeOfTupleWithRest<
T extends ZodTupleItems | [],
- Rest extends ZodTypeAny | null = null
+ Rest extends ZodTypeAny | null = null,
> = Rest extends ZodTypeAny
? [...InputTypeOfTuple<T>, ...Rest["_input"][]]
: InputTypeOfTuple<T>;
export interface ZodTupleDef<
T extends ZodTupleItems | [] = ZodTupleItems,
- Rest extends ZodTypeAny | null = null
+ Rest extends ZodTypeAny | null = null,
> extends ZodTypeDef {
items: T;
rest: Rest;
@@ -3428,7 +3475,7 @@ export type AnyZodTuple = ZodTuple<
>;
export class ZodTuple<
T extends [ZodTypeAny, ...ZodTypeAny[]] | [] = [ZodTypeAny, ...ZodTypeAny[]],
- Rest extends ZodTypeAny | null = null
+ Rest extends ZodTypeAny | null = null,
> extends ZodType<
OutputTypeOfTupleWithRest<T, Rest>,
ZodTupleDef<T, Rest>,
@@ -3525,7 +3572,7 @@ export class ZodTuple<
/////////////////////////////////////////
export interface ZodRecordDef<
Key extends KeySchema = ZodString,
- Value extends ZodTypeAny = ZodTypeAny
+ Value extends ZodTypeAny = ZodTypeAny,
> extends ZodTypeDef {
valueType: Value;
keyType: Key;
@@ -3534,19 +3581,19 @@ export interface ZodRecordDef<
export type KeySchema = ZodType<string | number | symbol, any, any>;
export type RecordType<K extends string | number | symbol, V> = [
- string
+ string,
] extends [K]
? Record<K, V>
: [number] extends [K]
- ? Record<K, V>
- : [symbol] extends [K]
- ? Record<K, V>
- : [BRAND<string | number | symbol>] extends [K]
- ? Record<K, V>
- : Partial<Record<K, V>>;
+ ? Record<K, V>
+ : [symbol] extends [K]
+ ? Record<K, V>
+ : [BRAND<string | number | symbol>] extends [K]
+ ? Record<K, V>
+ : Partial<Record<K, V>>;
export class ZodRecord<
Key extends KeySchema = ZodString,
- Value extends ZodTypeAny = ZodTypeAny
+ Value extends ZodTypeAny = ZodTypeAny,
> extends ZodType<
RecordType<Key["_output"], Value["_output"]>,
ZodRecordDef<Key, Value>,
@@ -3636,7 +3683,7 @@ export class ZodRecord<
//////////////////////////////////////
export interface ZodMapDef<
Key extends ZodTypeAny = ZodTypeAny,
- Value extends ZodTypeAny = ZodTypeAny
+ Value extends ZodTypeAny = ZodTypeAny,
> extends ZodTypeDef {
valueType: Value;
keyType: Key;
@@ -3645,7 +3692,7 @@ export interface ZodMapDef<
export class ZodMap<
Key extends ZodTypeAny = ZodTypeAny,
- Value extends ZodTypeAny = ZodTypeAny
+ Value extends ZodTypeAny = ZodTypeAny,
> extends ZodType<
Map<Key["_output"], Value["_output"]>,
ZodMapDef<Key, Value>,
@@ -3720,7 +3767,7 @@ export class ZodMap<
}
static create = <
Key extends ZodTypeAny = ZodTypeAny,
- Value extends ZodTypeAny = ZodTypeAny
+ Value extends ZodTypeAny = ZodTypeAny,
>(
keyType: Key,
valueType: Value,
@@ -3742,8 +3789,9 @@ export class ZodMap<
////////// //////////
//////////////////////////////////////
//////////////////////////////////////
-export interface ZodSetDef<Value extends ZodTypeAny = ZodTypeAny>
- extends ZodTypeDef {
+export interface ZodSetDef<
+ Value extends ZodTypeAny = ZodTypeAny,
+> extends ZodTypeDef {
valueType: Value;
typeName: ZodFirstPartyTypeKind.ZodSet;
minSize: { value: number; message?: string } | null;
@@ -3864,7 +3912,7 @@ export class ZodSet<Value extends ZodTypeAny = ZodTypeAny> extends ZodType<
///////////////////////////////////////////
export interface ZodFunctionDef<
Args extends ZodTuple<any, any> = ZodTuple<any, any>,
- Returns extends ZodTypeAny = ZodTypeAny
+ Returns extends ZodTypeAny = ZodTypeAny,
> extends ZodTypeDef {
args: Args;
returns: Returns;
@@ -3873,21 +3921,23 @@ export interface ZodFunctionDef<
export type OuterTypeOfFunction<
Args extends ZodTuple<any, any>,
- Returns extends ZodTypeAny
-> = Args["_input"] extends Array<any>
- ? (...args: Args["_input"]) => Returns["_output"]
- : never;
+ Returns extends ZodTypeAny,
+> =
+ Args["_input"] extends Array<any>
+ ? (...args: Args["_input"]) => Returns["_output"]
+ : never;
export type InnerTypeOfFunction<
Args extends ZodTuple<any, any>,
- Returns extends ZodTypeAny
-> = Args["_output"] extends Array<any>
- ? (...args: Args["_output"]) => Returns["_input"]
- : never;
+ Returns extends ZodTypeAny,
+> =
+ Args["_output"] extends Array<any>
+ ? (...args: Args["_output"]) => Returns["_input"]
+ : never;
export class ZodFunction<
Args extends ZodTuple<any, any>,
- Returns extends ZodTypeAny
+ Returns extends ZodTypeAny,
> extends ZodType<
OuterTypeOfFunction<Args, Returns>,
ZodFunctionDef<Args, Returns>,
@@ -4039,7 +4089,7 @@ export class ZodFunction<
): ZodFunction<T, U>;
static create<
T extends AnyZodTuple = ZodTuple<[], ZodUnknown>,
- U extends ZodTypeAny = ZodUnknown
+ U extends ZodTypeAny = ZodUnknown,
>(args: T, returns: U, params?: RawCreateParams): ZodFunction<T, U>;
static create(
args?: AnyZodTuple,
@@ -4064,8 +4114,9 @@ export class ZodFunction<
////////// //////////
///////////////////////////////////////
///////////////////////////////////////
-export interface ZodLazyDef<T extends ZodTypeAny = ZodTypeAny>
- extends ZodTypeDef {
+export interface ZodLazyDef<
+ T extends ZodTypeAny = ZodTypeAny,
+> extends ZodTypeDef {
getter: () => T;
typeName: ZodFirstPartyTypeKind.ZodLazy;
}
@@ -4155,8 +4206,9 @@ export type Values<T extends EnumValues> = {
[k in T[number]]: k;
};
-export interface ZodEnumDef<T extends EnumValues = EnumValues>
- extends ZodTypeDef {
+export interface ZodEnumDef<
+ T extends EnumValues = EnumValues,
+> extends ZodTypeDef {
values: T;
typeName: ZodFirstPartyTypeKind.ZodEnum;
}
@@ -4166,10 +4218,10 @@ export type Writeable<T> = { -readonly [P in keyof T]: T[P] };
export type FilterEnum<Values, ToExclude> = Values extends []
? []
: Values extends [infer Head, ...infer Rest]
- ? Head extends ToExclude
- ? FilterEnum<Rest, ToExclude>
- : [Head, ...FilterEnum<Rest, ToExclude>]
- : never;
+ ? Head extends ToExclude
+ ? FilterEnum<Rest, ToExclude>
+ : [Head, ...FilterEnum<Rest, ToExclude>]
+ : never;
export type typecast<A, T> = A extends T ? A : never;
@@ -4295,8 +4347,9 @@ export class ZodEnum<T extends [string, ...string[]]> extends ZodType<
////////// //////////
/////////////////////////////////////////////
/////////////////////////////////////////////
-export interface ZodNativeEnumDef<T extends EnumLike = EnumLike>
- extends ZodTypeDef {
+export interface ZodNativeEnumDef<
+ T extends EnumLike = EnumLike,
+> extends ZodTypeDef {
values: T;
typeName: ZodFirstPartyTypeKind.ZodNativeEnum;
}
@@ -4366,8 +4419,9 @@ export class ZodNativeEnum<T extends EnumLike> extends ZodType<
////////// //////////
//////////////////////////////////////////
//////////////////////////////////////////
-export interface ZodPromiseDef<T extends ZodTypeAny = ZodTypeAny>
- extends ZodTypeDef {
+export interface ZodPromiseDef<
+ T extends ZodTypeAny = ZodTypeAny,
+> extends ZodTypeDef {
type: T;
typeName: ZodFirstPartyTypeKind.ZodPromise;
}
@@ -4453,8 +4507,9 @@ export type Effect<T> =
| TransformEffect<T>
| PreprocessEffect<T>;
-export interface ZodEffectsDef<T extends ZodTypeAny = ZodTypeAny>
- extends ZodTypeDef {
+export interface ZodEffectsDef<
+ T extends ZodTypeAny = ZodTypeAny,
+> extends ZodTypeDef {
schema: T;
typeName: ZodFirstPartyTypeKind.ZodEffects;
effect: Effect<any>;
@@ -4463,7 +4518,7 @@ export interface ZodEffectsDef<T extends ZodTypeAny = ZodTypeAny>
export class ZodEffects<
T extends ZodTypeAny,
Output = output<T>,
- Input = input<T>
+ Input = input<T>,
> extends ZodType<Output, ZodEffectsDef<T>, Input> {
innerType() {
return this._def.schema;
@@ -4636,8 +4691,9 @@ export { ZodEffects as ZodTransformer };
////////// //////////
///////////////////////////////////////////
///////////////////////////////////////////
-export interface ZodOptionalDef<T extends ZodTypeAny = ZodTypeAny>
- extends ZodTypeDef {
+export interface ZodOptionalDef<
+ T extends ZodTypeAny = ZodTypeAny,
+> extends ZodTypeDef {
innerType: T;
typeName: ZodFirstPartyTypeKind.ZodOptional;
}
@@ -4680,8 +4736,9 @@ export class ZodOptional<T extends ZodTypeAny> extends ZodType<
////////// //////////
///////////////////////////////////////////
///////////////////////////////////////////
-export interface ZodNullableDef<T extends ZodTypeAny = ZodTypeAny>
- extends ZodTypeDef {
+export interface ZodNullableDef<
+ T extends ZodTypeAny = ZodTypeAny,
+> extends ZodTypeDef {
innerType: T;
typeName: ZodFirstPartyTypeKind.ZodNullable;
}
@@ -4724,8 +4781,9 @@ export class ZodNullable<T extends ZodTypeAny> extends ZodType<
////////// //////////
////////////////////////////////////////////
////////////////////////////////////////////
-export interface ZodDefaultDef<T extends ZodTypeAny = ZodTypeAny>
- extends ZodTypeDef {
+export interface ZodDefaultDef<
+ T extends ZodTypeAny = ZodTypeAny,
+> extends ZodTypeDef {
innerType: T;
defaultValue: () => util.noUndefined<T["_input"]>;
typeName: ZodFirstPartyTypeKind.ZodDefault;
@@ -4778,8 +4836,9 @@ export class ZodDefault<T extends ZodTypeAny> extends ZodType<
////////// //////////
//////////////////////////////////////////
//////////////////////////////////////////
-export interface ZodCatchDef<T extends ZodTypeAny = ZodTypeAny>
- extends ZodTypeDef {
+export interface ZodCatchDef<
+ T extends ZodTypeAny = ZodTypeAny,
+> extends ZodTypeDef {
innerType: T;
catchValue: (ctx: { error: ZodError; input: unknown }) => T["_input"];
typeName: ZodFirstPartyTypeKind.ZodCatch;
@@ -4917,7 +4976,7 @@ export type BRAND<T extends string | number | symbol> = {
export class ZodBranded<
T extends ZodTypeAny,
- B extends string | number | symbol
+ B extends string | number | symbol,
> extends ZodType<T["_output"] & BRAND<B>, ZodBrandedDef<T>, T["_input"]> {
_parse(input: ParseInput): ParseReturnType<any> {
const { ctx } = this._processInputParams(input);
@@ -4942,8 +5001,10 @@ export class ZodBranded<
////////////////////////////////////////////
////////////////////////////////////////////
-export interface ZodPipelineDef<A extends ZodTypeAny, B extends ZodTypeAny>
- extends ZodTypeDef {
+export interface ZodPipelineDef<
+ A extends ZodTypeAny,
+ B extends ZodTypeAny,
+> extends ZodTypeDef {
in: A;
out: B;
typeName: ZodFirstPartyTypeKind.ZodPipeline;
@@ -4951,7 +5012,7 @@ export interface ZodPipelineDef<A extends ZodTypeAny, B extends ZodTypeAny>
export class ZodPipeline<
A extends ZodTypeAny,
- B extends ZodTypeAny
+ B extends ZodTypeAny,
> extends ZodType<B["_output"], ZodPipelineDef<A, B>, A["_input"]> {
_parse(input: ParseInput): ParseReturnType<any> {
const { status, ctx } = this._processInputParams(input);
@@ -5026,20 +5087,22 @@ type BuiltIn =
| Promise<unknown>
| RegExp;
-type MakeReadonly<T> = T extends Map<infer K, infer V>
- ? ReadonlyMap<K, V>
- : T extends Set<infer V>
- ? ReadonlySet<V>
- : T extends [infer Head, ...infer Tail]
- ? readonly [Head, ...Tail]
- : T extends Array<infer V>
- ? ReadonlyArray<V>
- : T extends BuiltIn
- ? T
- : Readonly<T>;
-
-export interface ZodReadonlyDef<T extends ZodTypeAny = ZodTypeAny>
- extends ZodTypeDef {
+type MakeReadonly<T> =
+ T extends Map<infer K, infer V>
+ ? ReadonlyMap<K, V>
+ : T extends Set<infer V>
+ ? ReadonlySet<V>
+ : T extends [infer Head, ...infer Tail]
+ ? readonly [Head, ...Tail]
+ : T extends Array<infer V>
+ ? ReadonlyArray<V>
+ : T extends BuiltIn
+ ? T
+ : Readonly<T>;
+
+export interface ZodReadonlyDef<
+ T extends ZodTypeAny = ZodTypeAny,
+> extends ZodTypeDef {
innerType: T;
typeName: ZodFirstPartyTypeKind.ZodReadonly;
}
@@ -5108,8 +5171,8 @@ export function custom<T>(
typeof params === "function"
? params(data)
: typeof params === "string"
- ? { message: params }
- : params;
+ ? { message: params }
+ : params;
const _fatal = p.fatal ?? fatal ?? true;
const p2 = typeof p === "string" ? { message: p } : p;
ctx.addIssue({ code: "custom", ...p2, fatal: _fatal });