Socket
Book a DemoInstallSign in
Socket

aries-js

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aries-js

basic rules engine

0.1.1
latest
Source
npmnpm
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

Aries

CI Job

Rules suck unless when designing system because you remember that bug that was causing clients to get denied and cost you a week of sleep? Pepperidge Farm remembers.

Don't be hip be a square and make some rules now.

Documentation

Note - You need use the defined ruleName as the key of your rule object inside the config

Possible comparisons method avaliable

CompareTwo(dataItemPath, dataItemTwoPath, operand) - Compare two values aganist eachother.

{
    ruleName: "Bounds Example",
    ...,
    dataItemPath: 'a',
    dataItemTwoPath: 'b',
    operand: '===',
    ...
}

//When using >, <, <=, >= you should use number types, strings will use the length of the string as the comparison number
{
    ruleName: "Bounds Example",
    ...,
    dataItemPath: 'a',
    dataItemTwoPath: 'b.c',
    operand: '>',
    ...
}

CompareBounds(dataItemPath, lowerBound, upperBound, operand?) - Check if a number is within a given range

//Examples
{
    ruleName: "Bounds Example",
    ...,
    lowerBound: 10,
    upperBound: 30,
    dataItemPath: 'a',
    operand: '>=', //for this type any of >=, <=, >, < these but it only checks for the = sign 
    ...           //it will always evaluate as lowerBound </= dataItem </= upperBound
}

CompareBaseline(dataItemPath, baseline, operand) - Compare a number or a list of numbers aganist of constant (baseline)

Can be used on a collection (Array<nummber>)

Will evaluate in this order dataItem operand baseline keep this in mind when defining your rule configs

{
    ruleName: "Bounds Example",
    ...,
    dataItemPath: 'a.b', //Equal 60 here
    baseline: 100,
    operand: '<=' // dataItem <= baseline or 60 <= 100 === true
}

CompareBaselineTolerance(dataItem, baseline, tolerance, operand?) - Checks if a given value is within a given tolerance,

Example

100 is greater than or equal 60 +/-10% or in number form 54 < 100 || 66 < 100

{
    ruleName: "Bounds Example",
    ...,
    dataItemPath: 'a.b', //Equal 200 here
    baseline: 100,
    tolerance: 10, // will be 10%
    operand: '<=' // baseline - 10% <= dataItem <= baseline + 10% or 90 <= 200 || 110 <= 200
}

Dependent Rules

If you need to compare some more complex information or just a larger number of data items you can chain existing rules together using dependent rules.

Accepted operators- && and ||

Example

{
ruleName: "Test Dependent Rule",
operand: "&&", // || is the only other accepted operator,
ruleNames: ["RuleOne","RuleTwo"]
}

Background

This repo is named after my dog who recently passed away. A dog who didn't listen to shit or follow the rules and I name a rule validation, seems fitting to me.

RIP buddy 2008-2020

Keywords

rules-engine

FAQs

Package last updated on 23 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.