6 Commits

Author SHA1 Message Date
philkunz d53fe44766 3.0.1 2024-05-30 18:57:11 +02:00
philkunz 993c4e07bc fix(core): update 2024-05-30 18:57:10 +02:00
philkunz 8329bb902f 3.0.0 2024-05-30 18:53:53 +02:00
philkunz 7acda53d57 BREAKING CHANGE(api): changed API to be more concise 2024-05-30 18:53:52 +02:00
philkunz 50789d4416 2.0.4 2024-05-30 17:53:34 +02:00
philkunz d79d93ad30 fix(core): update 2024-05-30 17:53:33 +02:00
7 changed files with 12 additions and 9 deletions
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "@push.rocks/smartguard",
"version": "2.0.3",
"version": "3.0.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@push.rocks/smartguard",
"version": "2.0.3",
"version": "3.0.1",
"license": "MIT",
"dependencies": {
"@push.rocks/smartpromise": "^3.0.2",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@push.rocks/smartguard",
"version": "2.0.3",
"version": "3.0.1",
"private": false,
"description": "A TypeScript library for creating and managing validation guards, aiding in data validation and security checks.",
"main": "dist_ts/index.js",
+1 -1
View File
@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartguard',
version: '2.0.3',
version: '3.0.1',
description: 'A TypeScript library for creating and managing validation guards, aiding in data validation and security checks.'
}
+1
View File
@@ -2,6 +2,7 @@ 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);
+1 -1
View File
@@ -12,7 +12,7 @@ export class Guard<T> {
* executes the guard against a data argument;
* @param dataArg
*/
public async executeGuardWithData(dataArg: T) {
public async exec(dataArg: T) {
const result = await this.guardFunction(dataArg);
return result;
}
+4 -4
View File
@@ -19,11 +19,11 @@ export class GuardSet<T> extends Guard<T> {
* executes all guards in all guardSets against a data argument
* @param dataArg
*/
public async executeAllGuardsWithData(dataArg: T) {
public async execAllWithData(dataArg: T) {
const resultPromises: Array<Promise<boolean>> = [];
for (const guard of this.guards) {
const guardResultPromise = guard.executeGuardWithData(dataArg);
const guardResultPromise = guard.exec(dataArg);
resultPromises.push(guardResultPromise);
}
@@ -36,7 +36,7 @@ export class GuardSet<T> extends Guard<T> {
* @param dataArg
*/
public async allGuardsPass(dataArg: T): Promise<boolean> {
const results = await this.executeAllGuardsWithData(dataArg);
const results = await this.execAllWithData(dataArg);
return results.every(result => result);
}
@@ -45,7 +45,7 @@ export class GuardSet<T> extends Guard<T> {
* @param dataArg
*/
public async anyGuardsPass(dataArg: T): Promise<boolean> {
const results = await this.executeAllGuardsWithData(dataArg);
const results = await this.execAllWithData(dataArg);
return results.some(result => result);
}
}
+2
View File
@@ -1,4 +1,6 @@
// @push.rocks scope
import * as smartpromise from '@push.rocks/smartpromise';
// pushrocks scope
export { smartpromise };