Files
smartguard/ts/index.ts

15 lines
524 B
TypeScript
Raw Permalink Normal View History

2022-03-21 21:53:46 +01:00
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';
2024-05-30 17:53:33 +02:00
export * from './smartguard.classes.guardset.js';
2019-06-18 14:51:13 +02:00
2024-05-30 16:57:18 +02:00
export const passGuardsOrReject = async <T>(dataArg: T, guards: Array<Guard<T>>) => {
2019-08-07 16:31:53 +02:00
const guardSet = new GuardSet<T>(guards);
2024-05-30 16:57:18 +02:00
const result = await guardSet.allGuardsPass(dataArg);
if (!result) {
throw new Error('Guard failed');
2019-08-07 16:31:53 +02:00
}
2024-05-30 16:57:18 +02:00
return ;
2019-08-07 16:34:34 +02:00
};