smartguard/ts/index.ts
2024-05-30 17:53:33 +02:00

15 lines
524 B
TypeScript

import * as plugins from './smartguard.plugins.js';
import { Guard } from './smartguard.classes.guard.js';
import { GuardSet } from './smartguard.classes.guardset.js';
export * from './smartguard.classes.guard.js';
export * from './smartguard.classes.guardset.js';
export const passGuardsOrReject = async <T>(dataArg: T, guards: Array<Guard<T>>) => {
const guardSet = new GuardSet<T>(guards);
const result = await guardSet.allGuardsPass(dataArg);
if (!result) {
throw new Error('Guard failed');
}
return ;
};