@zod-plugins/string-validator
Version:
This library is a extend for z.ZodStringļ¼providing some custom validator for string
26 lines (25 loc) ⢠655 B
TypeScript
import { z } from 'zod';
export interface IntOptions {
allowLeadingZeroes?: boolean;
min?: number;
max?: number;
lt?: number;
gt?: number;
}
export declare type IssueArg = string | {
message?: string | undefined;
fatal?: boolean;
};
export interface CustomCheck {
(input: string, addIssue: (arg?: IssueArg) => void, ctx: z.ParseContext): void;
kind: string;
}
declare module 'zod' {
interface ZodString {
int: (options?: IntOptions, issueArg?: IssueArg) => z.ZodString;
i64: (issueArg?: IssueArg) => z.ZodString;
}
interface ZodStringDef {
customChecks?: Array<CustomCheck>;
}
}