smartguard/ts/smartguard.classes.guard.ts
2024-05-30 18:57:10 +02:00

20 lines
483 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 exec(dataArg: T) {
const result = await this.guardFunction(dataArg);
return result;
}
}