// Explicitly not using "zod" types here to avoid mismatching types due to // version differences. export interface Checkable { parse: (obj: unknown) => T safeParse: ( obj: unknown, ) => { success: true; data: T } | { success: false; error: Error } } export interface Def { name: string schema: Checkable } export const is = (obj: unknown, def: Checkable): obj is T => { return def.safeParse(obj).success } export const create = (def: Checkable) => (v: unknown): v is T => def.safeParse(v).success export const assure = (def: Checkable, obj: unknown): T => { return def.parse(obj) } export const isObject = (obj: unknown): obj is Record => { return typeof obj === 'object' && obj !== null }