guardz
Version:
A simple and lightweight TypeScript type guard library for runtime type validation.
17 lines (16 loc) • 1.12 kB
TypeScript
import { TypeGuardFn } from '../typeguards/isType';
export type TypeGuardWrapperKind = 'undefinedOr' | 'nullOr' | 'nilOr';
export type TypeGuardMeta = {
schema?: Record<string, TypeGuardFn<any>>;
itemGuard?: TypeGuardFn<any>;
innerGuard?: TypeGuardFn<any>;
wrapperKind?: TypeGuardWrapperKind;
};
export type TypeGuardWithMeta<T> = TypeGuardFn<T> & TypeGuardMeta;
export declare const getTypeGuardSchema: (typeGuardFn: TypeGuardFn<any>) => Record<string, TypeGuardFn<any>> | undefined;
export declare const getTypeGuardItemGuard: (typeGuardFn: TypeGuardFn<any>) => TypeGuardFn<any> | undefined;
export declare const getTypeGuardInnerGuard: (typeGuardFn: TypeGuardFn<any>) => TypeGuardFn<any> | undefined;
export declare const getTypeGuardWrapperKind: (typeGuardFn: TypeGuardFn<any>) => TypeGuardWrapperKind | undefined;
export declare const isNestedObjectTypeGuard: (typeGuardFn: TypeGuardFn<any>) => boolean;
export declare const isArrayTypeGuard: (typeGuardFn: TypeGuardFn<any>) => boolean;
export declare const attachTypeGuardMeta: <T>(typeGuardFn: TypeGuardFn<T>, meta: TypeGuardMeta) => TypeGuardFn<T>;