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';
|
2019-06-18 12:51:13 +00:00
|
|
|
|
2019-08-07 14:31:53 +00:00
|
|
|
export const passGuards = async <T>(dataArg: T, guards: Array<Guard<T>>) => {
|
|
|
|
const done = plugins.smartpromise.defer();
|
|
|
|
const guardSet = new GuardSet<T>(guards);
|
|
|
|
const results = await guardSet.executeGuardsWithData(dataArg);
|
|
|
|
for (const result of results) {
|
2019-08-07 14:34:34 +00:00
|
|
|
if (!result) {
|
2019-08-07 14:31:53 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
done.resolve();
|
|
|
|
await done.promise;
|
|
|
|
return;
|
2019-08-07 14:34:34 +00:00
|
|
|
};
|