-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5a3b5f3
commit 8bf2cc1
Showing
2 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
type ZodParsedType = string; | ||
type Primitive = string | number | boolean | bigint | symbol | undefined | null; | ||
class ZodError {} | ||
|
||
export enum ZodIssueCode { | ||
invalid_type = "invalid_type", | ||
custom = "custom", | ||
invalid_union = "invalid_union", | ||
invalid_date = "invalid_date", | ||
invalid_string = "invalid_string", | ||
invalid_array = "invalid_array", | ||
invalid_number = "invalid_number", | ||
invalid_set = "invalid_set", | ||
invalid_object = "invalid_object", | ||
invalid_bigint = "invalid_bigint", | ||
invalid_file = "invalid_file", | ||
} | ||
|
||
export type ZodIssueBase = { | ||
path: (string | number)[]; | ||
message?: string; | ||
input?: unknown; | ||
code: ZodIssueCode; | ||
level: "warn" | "error" | "abort"; | ||
}; | ||
|
||
export interface ZodInvalidTypeIssue extends ZodIssueBase { | ||
code: typeof ZodIssueCode.invalid_type; | ||
expected: ZodParsedType; | ||
received: ZodParsedType; | ||
} | ||
|
||
export interface ZodInvalidUnionIssue extends ZodIssueBase { | ||
code: typeof ZodIssueCode.invalid_union; | ||
unionErrors: ZodError[]; | ||
} | ||
|
||
export interface ZodInvalidDateIssue extends ZodIssueBase { | ||
code: ZodIssueCode.invalid_date; | ||
subcode: "too_big" | "too_small"; | ||
minimum?: number; | ||
maximum?: number; | ||
exclusive?: boolean; | ||
} | ||
|
||
type $StringFormats = | ||
| "email" | ||
| "url" | ||
| "jwt" | ||
| "json" | ||
| "emoji" | ||
| "uuid" | ||
| "nanoid" | ||
| "guid" | ||
| "regex" | ||
| "cuid" | ||
| "cuid2" | ||
| "ulid" | ||
| "xid" | ||
| "ksuid" | ||
| "datetime" | ||
| "date" | ||
| "time" | ||
| "duration" | ||
| "ip" | ||
| "base64" | ||
| "e164"; | ||
|
||
export interface ZodInvalidStringIssue extends ZodIssueBase { | ||
code: typeof ZodIssueCode.invalid_string; | ||
subcode: "too_small" | "too_big" | "invalid_format"; | ||
format?: $StringFormats; | ||
pattern?: string; | ||
startsWith?: string; | ||
endsWith?: string; | ||
includes?: string; | ||
} | ||
|
||
export interface ZodInvalidObjectIssue extends ZodIssueBase { | ||
code: typeof ZodIssueCode.invalid_object; | ||
subcode: "unrecognized_keys" | "missing_keys"; | ||
unrecognizedKeys?: string[]; | ||
missingKeys?: string[]; | ||
} | ||
|
||
export interface ZodInvalidArrayIssue extends ZodIssueBase { | ||
code: ZodIssueCode.invalid_array; | ||
subcode: "too_big" | "too_small" | "not_unique"; | ||
minimum?: number; | ||
maximum?: number; | ||
} | ||
|
||
export interface ZodInvalidNumberIssue extends ZodIssueBase { | ||
code: ZodIssueCode.invalid_number; | ||
subcode: "too_big" | "too_small" | "not_integer" | "not_multiple_of"; | ||
minimum?: number; | ||
maximum?: number; | ||
exclusive?: boolean; | ||
multipleOf?: number; | ||
} | ||
|
||
export interface ZodInvalidSetIssue extends ZodIssueBase { | ||
code: ZodIssueCode.invalid_set; | ||
subcode: "too_big" | "too_small" | "not_unique"; | ||
minimum?: number; | ||
maximum?: number; | ||
} | ||
|
||
export interface ZodInvalidBigIntIssue extends ZodIssueBase { | ||
code: ZodIssueCode.invalid_bigint; | ||
subcode: "too_big" | "too_small"; | ||
minimum?: number; | ||
maximum?: number; | ||
exclusive?: boolean; | ||
} | ||
|
||
export interface ZodInvalidFileIssue extends ZodIssueBase { | ||
code: ZodIssueCode.invalid_file; | ||
subcode: "too_big" | "too_small" | "invalid_mime" | "invalid_name"; | ||
minimum?: number; | ||
maximum?: number; | ||
acceptedTypes?: string[]; | ||
name?: string; | ||
} | ||
|
||
export interface ZodCustomIssue extends ZodIssueBase { | ||
code: typeof ZodIssueCode.custom; | ||
params?: { [k: string]: any }; | ||
} | ||
|
||
export type ZodIssue = | ||
| ZodInvalidTypeIssue | ||
| ZodInvalidUnionIssue | ||
| ZodInvalidStringIssue | ||
| ZodInvalidArrayIssue | ||
| ZodInvalidNumberIssue | ||
| ZodInvalidSetIssue | ||
| ZodInvalidObjectIssue | ||
| ZodInvalidBigIntIssue | ||
| ZodInvalidFileIssue | ||
| ZodCustomIssue; |
Empty file.