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