UNPKG

@push.rocks/smartguard

Version:

A TypeScript library for creating and managing validation guards, aiding in data validation and security checks.

17 lines (16 loc) 500 B
export type TGuardFunction<T> = (dataArg: T) => Promise<boolean>; export interface IGuardOptions { name?: string; failedHint?: string; } export declare class Guard<T> { private guardFunction; options: IGuardOptions; constructor(guardFunctionArg: TGuardFunction<T>, optionsArg?: IGuardOptions); /** * executes the guard against a data argument; * @param dataArg */ exec(dataArg: T): Promise<boolean>; getFailedHint(dataArg: T): Promise<string | null>; }