import type { CheckingError, Either, Fn, Option, Result } from '../../mod.js'; import * as z from 'zod'; /** [zod文档](https://zod.dev/README_ZH) zod是一个Schema验证库,用于弥补Ts在运行时不具有类型检查的缺陷,能实现全链路的类型安全 @category ext */ export * from 'zod'; /** ### `option` @example ```ts const option = z.option(z.string()) const res = option.safeParse(Some('jiojio')) assert(res.success) ``` @category Ext - zod */ export declare const option: (value: S) => z.ZodEffects>, Option>>; /** ### `resule` @example ```ts const result = z.result(z.string(), z.number()) const res = result.safeParse(Ok('jiojio')) assert(res.success) ``` @category Ext - zod */ export declare const result: (ok: T, err: E) => z.ZodEffects, z.infer>, any>; /** ### `either` @example ```ts const either = z.either(z.string(), z.number()) const res = either.safeParse(Left('jiojio')) assert(res.success) ``` @category Ext - zod */ export declare const either: (left: z.infer, right: z.infer) => z.ZodEffects, z.infer>, any>; /** ### `symbol_value` : 具体的symbol值 @example Usage ```ts const sym = Symbol('jiojio') const pattern = z.symbol_value(sym) const res = pattern.safeParse(sym).success assert(res) ``` @category Ext - zod */ export declare const symbol_value: (sym: symbol) => z.ZodEffects; /** ### `rule` : 自定义校验规则 @example Usage ```ts const len_ten = zod.checking( zod.rule((data) => { if (Number(data) > 10) return Ok() return CheckingError.err('数据小于等于10,无法通过校验') }), ) assert(len_ten(11).unwrap() === 11) assert(len_ten(9).unwrap_err().cause() === '数据小于等于10,无法通过校验') ``` @category Ext - zod */ export declare const rule: (check: Fn>) => z.ZodEffects; //# sourceMappingURL=extend.d.ts.map