smartguard/ts/smartguard.classes.guard.ts

20 lines
499 B
TypeScript

import * as plugins from './smartguard.plugins.js';
export type TGuardFunction<T> = (dataArg: T) => Promise<boolean>;
export class Guard<T> {
private guardFunction: TGuardFunction<T>;
constructor(guardFunctionArg: TGuardFunction<T>) {
this.guardFunction = guardFunctionArg;
}
/**
* executes the guard against a data argument;
* @param dataArg
*/
public async executeGuardWithData(dataArg: T) {
const result = await this.guardFunction(dataArg);
return result;
}
}