CoolFace
Apppublic

AK-21/Graphite-Industrial-Intelligence

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
ZodError.d.ts165 linesDownload Raw Back to v3
1import type { Primitive } from "./helpers/typeAliases.js";2import { util, type ZodParsedType } from "./helpers/util.js";3import type { TypeOf, ZodType } from "./index.js";4type allKeys<T> = T extends any ? keyof T : never;5export type inferFlattenedErrors<T extends ZodType<any, any, any>, U = string> = typeToFlattenedError<TypeOf<T>, U>;6export type typeToFlattenedError<T, U = string> = {7    formErrors: U[];8    fieldErrors: {9        [P in allKeys<T>]?: U[];10    };11};12export declare const ZodIssueCode: {13    custom: "custom";14    invalid_type: "invalid_type";15    too_big: "too_big";16    too_small: "too_small";17    not_multiple_of: "not_multiple_of";18    unrecognized_keys: "unrecognized_keys";19    invalid_union: "invalid_union";20    invalid_literal: "invalid_literal";21    invalid_union_discriminator: "invalid_union_discriminator";22    invalid_enum_value: "invalid_enum_value";23    invalid_arguments: "invalid_arguments";24    invalid_return_type: "invalid_return_type";25    invalid_date: "invalid_date";26    invalid_string: "invalid_string";27    invalid_intersection_types: "invalid_intersection_types";28    not_finite: "not_finite";29};30export type ZodIssueCode = keyof typeof ZodIssueCode;31export type ZodIssueBase = {32    path: (string | number)[];33    message?: string | undefined;34};35export interface ZodInvalidTypeIssue extends ZodIssueBase {36    code: typeof ZodIssueCode.invalid_type;37    expected: ZodParsedType;38    received: ZodParsedType;39}40export interface ZodInvalidLiteralIssue extends ZodIssueBase {41    code: typeof ZodIssueCode.invalid_literal;42    expected: unknown;43    received: unknown;44}45export interface ZodUnrecognizedKeysIssue extends ZodIssueBase {46    code: typeof ZodIssueCode.unrecognized_keys;47    keys: string[];48}49export interface ZodInvalidUnionIssue extends ZodIssueBase {50    code: typeof ZodIssueCode.invalid_union;51    unionErrors: ZodError[];52}53export interface ZodInvalidUnionDiscriminatorIssue extends ZodIssueBase {54    code: typeof ZodIssueCode.invalid_union_discriminator;55    options: Primitive[];56}57export interface ZodInvalidEnumValueIssue extends ZodIssueBase {58    received: string | number;59    code: typeof ZodIssueCode.invalid_enum_value;60    options: (string | number)[];61}62export interface ZodInvalidArgumentsIssue extends ZodIssueBase {63    code: typeof ZodIssueCode.invalid_arguments;64    argumentsError: ZodError;65}66export interface ZodInvalidReturnTypeIssue extends ZodIssueBase {67    code: typeof ZodIssueCode.invalid_return_type;68    returnTypeError: ZodError;69}70export interface ZodInvalidDateIssue extends ZodIssueBase {71    code: typeof ZodIssueCode.invalid_date;72}73export type StringValidation = "email" | "url" | "emoji" | "uuid" | "nanoid" | "regex" | "cuid" | "cuid2" | "ulid" | "datetime" | "date" | "time" | "duration" | "ip" | "cidr" | "base64" | "jwt" | "base64url" | {74    includes: string;75    position?: number | undefined;76} | {77    startsWith: string;78} | {79    endsWith: string;80};81export interface ZodInvalidStringIssue extends ZodIssueBase {82    code: typeof ZodIssueCode.invalid_string;83    validation: StringValidation;84}85export interface ZodTooSmallIssue extends ZodIssueBase {86    code: typeof ZodIssueCode.too_small;87    minimum: number | bigint;88    inclusive: boolean;89    exact?: boolean;90    type: "array" | "string" | "number" | "set" | "date" | "bigint";91}92export interface ZodTooBigIssue extends ZodIssueBase {93    code: typeof ZodIssueCode.too_big;94    maximum: number | bigint;95    inclusive: boolean;96    exact?: boolean;97    type: "array" | "string" | "number" | "set" | "date" | "bigint";98}99export interface ZodInvalidIntersectionTypesIssue extends ZodIssueBase {100    code: typeof ZodIssueCode.invalid_intersection_types;101}102export interface ZodNotMultipleOfIssue extends ZodIssueBase {103    code: typeof ZodIssueCode.not_multiple_of;104    multipleOf: number | bigint;105}106export interface ZodNotFiniteIssue extends ZodIssueBase {107    code: typeof ZodIssueCode.not_finite;108}109export interface ZodCustomIssue extends ZodIssueBase {110    code: typeof ZodIssueCode.custom;111    params?: {112        [k: string]: any;113    };114}115export type DenormalizedError = {116    [k: string]: DenormalizedError | string[];117};118export type ZodIssueOptionalMessage = ZodInvalidTypeIssue | ZodInvalidLiteralIssue | ZodUnrecognizedKeysIssue | ZodInvalidUnionIssue | ZodInvalidUnionDiscriminatorIssue | ZodInvalidEnumValueIssue | ZodInvalidArgumentsIssue | ZodInvalidReturnTypeIssue | ZodInvalidDateIssue | ZodInvalidStringIssue | ZodTooSmallIssue | ZodTooBigIssue | ZodInvalidIntersectionTypesIssue | ZodNotMultipleOfIssue | ZodNotFiniteIssue | ZodCustomIssue;119export type ZodIssue = ZodIssueOptionalMessage & {120    fatal?: boolean | undefined;121    message: string;122};123export declare const quotelessJson: (obj: any) => string;124type recursiveZodFormattedError<T> = T extends [any, ...any[]] ? {125    [K in keyof T]?: ZodFormattedError<T[K]>;126} : T extends any[] ? {127    [k: number]: ZodFormattedError<T[number]>;128} : T extends object ? {129    [K in keyof T]?: ZodFormattedError<T[K]>;130} : unknown;131export type ZodFormattedError<T, U = string> = {132    _errors: U[];133} & recursiveZodFormattedError<NonNullable<T>>;134export type inferFormattedError<T extends ZodType<any, any, any>, U = string> = ZodFormattedError<TypeOf<T>, U>;135export declare class ZodError<T = any> extends Error {136    issues: ZodIssue[];137    get errors(): ZodIssue[];138    constructor(issues: ZodIssue[]);139    format(): ZodFormattedError<T>;140    format<U>(mapper: (issue: ZodIssue) => U): ZodFormattedError<T, U>;141    static create: (issues: ZodIssue[]) => ZodError<any>;142    static assert(value: unknown): asserts value is ZodError;143    toString(): string;144    get message(): string;145    get isEmpty(): boolean;146    addIssue: (sub: ZodIssue) => void;147    addIssues: (subs?: ZodIssue[]) => void;148    flatten(): typeToFlattenedError<T>;149    flatten<U>(mapper?: (issue: ZodIssue) => U): typeToFlattenedError<T, U>;150    get formErrors(): typeToFlattenedError<T, string>;151}152type stripPath<T extends object> = T extends any ? util.OmitKeys<T, "path"> : never;153export type IssueData = stripPath<ZodIssueOptionalMessage> & {154    path?: (string | number)[];155    fatal?: boolean | undefined;156};157export type ErrorMapCtx = {158    defaultError: string;159    data: any;160};161export type ZodErrorMap = (issue: ZodIssueOptionalMessage, _ctx: ErrorMapCtx) => {162    message: string;163};164export {};165