agent_patch
runs/2026-02-27__21-30-28__gpt-5-3-codex/flux-pr-3820/flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-3-codex/agent-logs/agent.patch
61818 bytes
diff --git a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-3-codex/app/ERROR_HANDLING.md b/app/ERROR_HANDLING.md
index 78dbb29..532609c 100644
--- a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-3-codex/app/ERROR_HANDLING.md
+++ b/app/ERROR_HANDLING.md
@@ -49,7 +49,7 @@ _Every_ ZodIssue has these fields:
| ZodIssueCode.invalid_arguments | `argumentsError: ZodError` <br> This is a special error code only thrown by a wrapped function returned by `ZodFunction.implement()`. The `argumentsError` property is another ZodError containing the validation error details. |
| ZodIssueCode.invalid_return_type | `returnTypeError: ZodError` <br> This is a special error code only thrown by a wrapped function returned by `ZodFunction.implement()`. The `returnTypeError` property is another ZodError containing the validation error details. |
| ZodIssueCode.invalid_date | _no additional properties_ |
-| ZodIssueCode.invalid_string | `validation: "url" \| "email" \| "uuid"`<br> Which built-in string validator failed |
+| ZodIssueCode.invalid_string | `validation: StringValidation` (for example `"url"`, `"email"`, `"ip"`, `"cidr"`, etc.)<br> Which built-in string validator failed |
| ZodIssueCode.too_small | `type: "string" \| "number" \| "array" \| "set" \| "date"` <br>The type of the data failing validation<br><br> `minimum: number` <br>The expected length/value.<br><br>`inclusive: boolean`<br>Whether the minimum is included in the range of acceptable values.<br><br>`exact: boolean`<br>Whether the size/length is constrained to be an exact value (used to produce more readable error messages).<br> |
| ZodIssueCode.too_big | `type: "string" \| "number" \| "array" \| "set" \| "date"` <br>The type of the data failing validation<br><br> `maximum: number` <br>The expected length/value.<br><br>`inclusive: boolean`<br>Whether the maximum is included in the range of acceptable values.<br><br>`exact: boolean`<br>Whether the size/length is constrained to be an exact value (used to produce more readable error messages).<br> |
| ZodIssueCode.not_multiple_of | `multipleOf: number` <br>The value the number should be a multiple of.<br> |
@@ -92,10 +92,12 @@ Here's a sample Person schema.
```ts
const person = z.object({
names: z.array(z.string()).nonempty(), // at least 1 name
- address: z.object({
- line1: z.string(),
- zipCode: z.number().min(10000), // American 5-digit code
- }).strict() // do not allow unrecognized keys
+ address: z
+ .object({
+ line1: z.string(),
+ zipCode: z.number().min(10000), // American 5-digit code
+ })
+ .strict(), // do not allow unrecognized keys
});
```
@@ -177,7 +179,6 @@ z.setErrorMap(customErrorMap);
As mentioned above, ZodIssue is a discriminated union.
- `ctx: { defaultError: string; data: any }`
-
- `ctx.defaultError` is the error message generated by the default error map. If you only want to override the message for a single type of error, you can do that. Just return `{ message: ctx.defaultError }` for everything else.
- `ctx.data` contains the data that was passed into `.parse`. You can use this to customize the error message.
diff --git a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-3-codex/app/README.md b/app/README.md
index 3cf25ab..4d9c964 100644
--- a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-3-codex/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,32 @@ const ipv6 = z.string().ip({ version: "v6" });
ipv6.parse("192.168.1.1"); // fail
```
+### CIDR blocks
+
+The `z.string().cidr()` method validates IPv4 and IPv6 CIDR notation (address + prefix length).
+
+```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("2001:db8::/129"); // fail
+```
+
+You can additionally set the CIDR `version`.
+
+```ts
+const ipv4Cidr = z.string().cidr({ version: "v4" });
+ipv4Cidr.parse("10.0.0.0/8"); // pass
+ipv4Cidr.parse("2001:db8::/32"); // fail
+
+const ipv6Cidr = z.string().cidr({ version: "v6" });
+ipv6Cidr.parse("2001:db8::/64"); // pass
+ipv6Cidr.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-3-codex/app/deno/lib/README.md b/app/deno/lib/README.md
index a3c8886..ac1d457 100644
--- a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-3-codex/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,32 @@ const ipv6 = z.string().ip({ version: "v6" });
ipv6.parse("192.168.1.1"); // fail
```
+### CIDR blocks
+
+The `z.string().cidr()` method validates IPv4 and IPv6 CIDR notation (address + prefix length).
+
+```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("2001:db8::/129"); // fail
+```
+
+You can additionally set the CIDR `version`.
+
+```ts
+const ipv4Cidr = z.string().cidr({ version: "v4" });
+ipv4Cidr.parse("10.0.0.0/8"); // pass
+ipv4Cidr.parse("2001:db8::/32"); // fail
+
+const ipv6Cidr = z.string().cidr({ version: "v6" });
+ipv6Cidr.parse("2001:db8::/64"); // pass
+ipv6Cidr.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-3-codex/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-3-codex/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-3-codex/app/deno/lib/__tests__/string.test.ts b/app/deno/lib/__tests__/string.test.ts
index 6443871..1a474ec 100644
--- a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-3-codex/app/deno/lib/__tests__/string.test.ts
+++ b/app/deno/lib/__tests__/string.test.ts
@@ -437,6 +437,9 @@ test("checks getters", () => {
expect(z.string().ulid().isNANOID).toEqual(false);
expect(z.string().ulid().isIP).toEqual(false);
expect(z.string().ulid().isULID).toEqual(true);
+
+ expect(z.string().cidr().isCIDR).toEqual(true);
+ expect(z.string().ip().isCIDR).toEqual(false);
});
test("min max getters", () => {
@@ -769,3 +772,30 @@ 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);
+ expect(cidr.safeParse("192.168.0.1").success).toBe(false);
+ expect(cidr.safeParse("192.168.0.1/33").success).toBe(false);
+ expect(cidr.safeParse("2001:db8::/129").success).toBe(false);
+
+ const ipv4Cidr = z.string().cidr({ version: "v4" });
+ expect(ipv4Cidr.safeParse("10.0.0.0/8").success).toBe(true);
+ expect(ipv4Cidr.safeParse("2001:db8::/32").success).toBe(false);
+
+ const ipv6Cidr = z.string().cidr({ version: "v6" });
+ expect(ipv6Cidr.safeParse("2001:db8::/64").success).toBe(true);
+ expect(ipv6Cidr.safeParse("10.0.0.0/8").success).toBe(false);
+
+ const result = cidr.safeParse("10.0.0.1");
+ expect(result.success).toBe(false);
+ if (!result.success) {
+ expect(result.error.issues[0].code).toEqual("invalid_string");
+ if (result.error.issues[0].code === "invalid_string") {
+ expect(result.error.issues[0].validation).toEqual("cidr");
+ expect(result.error.issues[0].message).toEqual("Invalid cidr");
+ }
+ }
+});
diff --git a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-3-codex/app/deno/lib/__tests__/validations.test.ts b/app/deno/lib/__tests__/validations.test.ts
index 7ebbaa3..39d1c12 100644
--- a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-3-codex/app/deno/lib/__tests__/validations.test.ts
+++ b/app/deno/lib/__tests__/validations.test.ts
@@ -147,12 +147,14 @@ test("instantiation", () => {
z.string().email();
z.string().url();
z.string().uuid();
+ z.string().cidr();
z.string().min(5, { message: "Must be 5 or more characters long" });
z.string().max(5, { message: "Must be 5 or fewer characters long" });
z.string().length(5, { message: "Must be exactly 5 characters long" });
z.string().email({ message: "Invalid email address." });
z.string().url({ message: "Invalid url" });
z.string().uuid({ message: "Invalid UUID" });
+ z.string().cidr({ message: "Invalid CIDR" });
});
test("int", async () => {
diff --git a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-3-codex/app/deno/lib/types.ts b/app/deno/lib/types.ts
index 9cee39a..b1e3e27 100644
--- a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-3-codex/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,25 @@ function isValidIP(ip: string, version?: IpVersion) {
return false;
}
+function isValidCidr(cidr: string, version?: IpVersion) {
+ const [ip, prefix, ...rest] = cidr.split("/");
+ if (!ip || !prefix || rest.length > 0 || !/^\d+$/.test(prefix)) {
+ return false;
+ }
+
+ const prefixNum = Number(prefix);
+
+ if ((version === "v4" || !version) && isValidIP(ip, "v4")) {
+ return prefixNum >= 0 && prefixNum <= 32;
+ }
+
+ if ((version === "v6" || !version) && isValidIP(ip, "v6")) {
+ return prefixNum >= 0 && prefixNum <= 128;
+ }
+
+ return false;
+}
+
export class ZodString extends ZodType<string, ZodStringDef, string> {
_parse(input: ParseInput): ParseReturnType<string> {
if (this._def.coerce) {
@@ -933,6 +958,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 +1041,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 +1238,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 +2196,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 +2209,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 +2363,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 +2375,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 +2396,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 +2416,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 +2468,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 +2973,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 +3090,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 +3153,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 +3164,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 +3236,8 @@ export class ZodDiscriminatedUnion<
Discriminator extends string,
Types extends [
ZodDiscriminatedUnionOption<Discriminator>,
- ...ZodDiscriminatedUnionOption<Discriminator>[]
- ]
+ ...ZodDiscriminatedUnionOption<Discriminator>[],
+ ],
>(
discriminator: Discriminator,
options: Types,
@@ -3245,7 +3290,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 +3354,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 +3443,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 +3453,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 +3473,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 +3570,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 +3579,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 +3681,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 +3690,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 +3765,7 @@ export class ZodMap<
}
static create = <
Key extends ZodTypeAny = ZodTypeAny,
- Value extends ZodTypeAny = ZodTypeAny
+ Value extends ZodTypeAny = ZodTypeAny,
>(
keyType: Key,
valueType: Value,
@@ -3742,8 +3787,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 +3910,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 +3919,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 +4087,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 +4112,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 +4204,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 +4216,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 +4345,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 +4417,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 +4505,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 +4516,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 +4689,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 +4734,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 +4779,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 +4834,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 +4974,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 +4999,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 +5010,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 +5085,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 +5169,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-3-codex/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-3-codex/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-3-codex/app/src/__tests__/string.test.ts b/app/src/__tests__/string.test.ts
index f7037fc..936b45d 100644
--- a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-3-codex/app/src/__tests__/string.test.ts
+++ b/app/src/__tests__/string.test.ts
@@ -436,6 +436,9 @@ test("checks getters", () => {
expect(z.string().ulid().isNANOID).toEqual(false);
expect(z.string().ulid().isIP).toEqual(false);
expect(z.string().ulid().isULID).toEqual(true);
+
+ expect(z.string().cidr().isCIDR).toEqual(true);
+ expect(z.string().ip().isCIDR).toEqual(false);
});
test("min max getters", () => {
@@ -768,3 +771,30 @@ 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);
+ expect(cidr.safeParse("192.168.0.1").success).toBe(false);
+ expect(cidr.safeParse("192.168.0.1/33").success).toBe(false);
+ expect(cidr.safeParse("2001:db8::/129").success).toBe(false);
+
+ const ipv4Cidr = z.string().cidr({ version: "v4" });
+ expect(ipv4Cidr.safeParse("10.0.0.0/8").success).toBe(true);
+ expect(ipv4Cidr.safeParse("2001:db8::/32").success).toBe(false);
+
+ const ipv6Cidr = z.string().cidr({ version: "v6" });
+ expect(ipv6Cidr.safeParse("2001:db8::/64").success).toBe(true);
+ expect(ipv6Cidr.safeParse("10.0.0.0/8").success).toBe(false);
+
+ const result = cidr.safeParse("10.0.0.1");
+ expect(result.success).toBe(false);
+ if (!result.success) {
+ expect(result.error.issues[0].code).toEqual("invalid_string");
+ if (result.error.issues[0].code === "invalid_string") {
+ expect(result.error.issues[0].validation).toEqual("cidr");
+ expect(result.error.issues[0].message).toEqual("Invalid cidr");
+ }
+ }
+});
diff --git a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-3-codex/app/src/__tests__/validations.test.ts b/app/src/__tests__/validations.test.ts
index 6ab351b..888151e 100644
--- a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-3-codex/app/src/__tests__/validations.test.ts
+++ b/app/src/__tests__/validations.test.ts
@@ -146,12 +146,14 @@ test("instantiation", () => {
z.string().email();
z.string().url();
z.string().uuid();
+ z.string().cidr();
z.string().min(5, { message: "Must be 5 or more characters long" });
z.string().max(5, { message: "Must be 5 or fewer characters long" });
z.string().length(5, { message: "Must be exactly 5 characters long" });
z.string().email({ message: "Invalid email address." });
z.string().url({ message: "Invalid url" });
z.string().uuid({ message: "Invalid UUID" });
+ z.string().cidr({ message: "Invalid CIDR" });
});
test("int", async () => {
diff --git a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-3-codex/app/src/types.ts b/app/src/types.ts
index be49c70..9013063 100644
--- a/tmp/agent-patch-flux-pr-3820.1-of-1.2026-02-27__21-30-28__gpt-5-3-codex/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,25 @@ function isValidIP(ip: string, version?: IpVersion) {
return false;
}
+function isValidCidr(cidr: string, version?: IpVersion) {
+ const [ip, prefix, ...rest] = cidr.split("/");
+ if (!ip || !prefix || rest.length > 0 || !/^\d+$/.test(prefix)) {
+ return false;
+ }
+
+ const prefixNum = Number(prefix);
+
+ if ((version === "v4" || !version) && isValidIP(ip, "v4")) {
+ return prefixNum >= 0 && prefixNum <= 32;
+ }
+
+ if ((version === "v6" || !version) && isValidIP(ip, "v6")) {
+ return prefixNum >= 0 && prefixNum <= 128;
+ }
+
+ return false;
+}
+
export class ZodString extends ZodType<string, ZodStringDef, string> {
_parse(input: ParseInput): ParseReturnType<string> {
if (this._def.coerce) {
@@ -933,6 +953,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 +1036,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 +1233,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 +2191,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 +2204,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 +2358,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 +2370,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 +2391,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 +2411,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 +2463,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 +2968,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 +3085,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 +3148,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 +3159,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 +3231,8 @@ export class ZodDiscriminatedUnion<
Discriminator extends string,
Types extends [
ZodDiscriminatedUnionOption<Discriminator>,
- ...ZodDiscriminatedUnionOption<Discriminator>[]
- ]
+ ...ZodDiscriminatedUnionOption<Discriminator>[],
+ ],
>(
discriminator: Discriminator,
options: Types,
@@ -3245,7 +3285,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 +3349,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 +3438,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 +3448,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 +3468,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 +3565,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 +3574,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 +3676,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 +3685,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 +3760,7 @@ export class ZodMap<
}
static create = <
Key extends ZodTypeAny = ZodTypeAny,
- Value extends ZodTypeAny = ZodTypeAny
+ Value extends ZodTypeAny = ZodTypeAny,
>(
keyType: Key,
valueType: Value,
@@ -3742,8 +3782,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 +3905,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 +3914,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 +4082,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 +4107,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 +4199,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 +4211,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 +4340,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 +4412,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 +4500,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 +4511,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 +4684,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 +4729,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 +4774,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 +4829,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 +4969,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 +4994,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 +5005,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 +5080,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 +5164,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 });