
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
rulesengineedited
Advanced tools
Since it was trowing some weired issue I have recreated this repositories in my system
A small functional Rule Engine - simple maybe an understatement...
Simplicity is elegance. This rule engine is NOT forward chaining, backward chaining, nor is this an inference engine. What it is, is a pragmatic reactive engine. Simply stated, when there is a condition, execute an action -- most assuredly in a stateless manner.
Prime directives, and ables ...
#####Martin Fowler on Rule Engines
// Rule Abilities
{ables: [persistable, versionable, shareable, adaptable, testable, chainable, reusable, extensible]}
// Input - Example Greetings (rules.js - not functional but a conceptual demo)
facts = {
input: { hour: 10 },
output: {greeting:''}
}
// Process - Example Decision Table
rule = {
"id": "GREETING",
"description": "Show correct greeting based on time",
"condition": function (facts) {
// We will calculate the results regardless
return true;
},
"action": function (facts) {
var decisionTable
= [
{from: 0, to: 11, greeting: 'Good Morning'},
{from: 12, to: 17, greeting: 'Good Afternoon'},
{from: 18, to: 22, greetings: 'Good Evening'},
{from: 23, to: 24, greetings: 'Good Night'}
];
var resultArray;
// MAP
resultArray = _.map(decisionTable, function (row) {
var result = "";
if (facts.input.hour >= row.from && facts.input.hour <= row.to) {
result = row.greeting;
}
return result;
});
// Reduce
var result = _.reduce(resultArray, function (memory, element) {
if (element !== "") {
memory = element;
}
return memory;
});
facts.output.greeting = result;
}
}
// Output - Example result
facts = {
input: { hour: 10 },
output: {greeting:'Good Morning'}
}
Setup Example
// Set Up Validate Functions to be used by the validation engine
const _validate = new validate();
const _isDecimal3 = _validate.isDecimal(3);
const _isDecimal4 = _validate.isDecimal(4);
const _isDecimal5 = _validate.isDecimal(5);
const _range5_10 = _validate.range(5, 10);
const _phoneType = _validate.inGroup(['home', 'business']);
const _membership = _validate.inGroup(['Gold', 'Silver', 'Bronze']);
// Setup Phone validation rules
const validationRulesPersonPhones = [
{key: 'type', validate: _.isString, error: 'phone.type is not a valid string type'},
{key: 'type', validate: _phoneType, error: 'phone.type is not in phone type group'},
{key: 'number', validate: _.isString, error: 'phone.number invalid'}
];
// Setup Person validation rules
const validationRulesPerson = [
{key: 'person.firstName', validate: _.isString, error: 'person.firstName not a string'},
{key: 'person.lastName', validate: _.isString , error: 'person.lastName not a string'},
{key: 'person.DOB', validate: _.isDate, error: 'person.DOB invalid'},
{key: 'person.secret.id', validate: _.isString, error: 'person.secret.id not a string'},
{key: 'person.secret.pwd',validate: _.isString, error: 'person.secret.pwd not a string'},
{key: 'person.email', validate: _validate.isEmail, error: 'person.email is invalid'},
{key: 'id', validate: _.isNumber, error: 'id is not a number'},
{key: 'dec3', validate: _isDecimal3, error: 'dec3 is not three decimals'},
{key: 'dec4', validate: _isDecimal4, error: 'dec4 is not three decimals'},
{key: 'dec5', validate: _isDecimal5, error: 'dec5 is not three decimals'},
{key: 'num_1', validate: _range5_10, error: 'Number is not within range of 5-10'},
{key: 'membership', validate: _membership, error: 'Invalid membership'}
];
function getFacts() {
let obj = {};
obj.person = {};
obj.person.firstName = 'Bill';
obj.person.lastName = 'Joy';
obj.person.DOB = new Date();
obj.person.secret = {};
obj.person.secret.id = 'myId_isSecret';
obj.person.secret.pwd = 'secret';
obj.person.phones = [{type: 'home', number: '8675309'}, {type: 'business', number: '8675309'}];
obj.person.email = 'Bill@joy.com';
obj.id = 12345;
obj.dec3 = '1.233';
obj.dec4 = '1.2333';
obj.dec5 = '1.23333';
obj.num_1 = 5;
obj.membership = 'Gold';
return obj;
}
// Run Example from testValidate.js
let errorResults = [];
// Run validation rules on Person
errorResults.push(_validate.run(validationRulesPerson, getFacts()));
// Run validation rules on Persons Phone numbers
getFacts().person.phones.forEach(function(elem) {
errorResults.push(_validate.run(validationRulesPersonPhones, elem));
});
// Will contain all errors found
errorResults = _.flatten(errorResults);
The source is available for download from GitHub.
Alternatively, you can install using Node Package Manager npm:
mocha lib/test
mocha lib/test/testValidate.js
FAQs
Business Rules Engine
We found that rulesengineedited demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.