smpl-rule-engine
v1.0.0
Published
A basic conditions based rules engine to check whether an schema passes the rule
Downloads
2
Readme
Rule Engine (rule-engine.ob)
A basic conditions based rules engine to check whether an schema passes the rule
#Example
#Rule schema The rules are composed by 3 basic components
- all
- any
- condition
- An
all
block is an array of rules in which every rule should evaluate as true - An
any
block is an array of rules in which at least one rule should evaluate as true - A
condition
is an object with the fields:- field - The name of field of the schema to check
- operator - The operator used to compare the values
- value - The value against the rule compare the schema field
Example
const rule = {
all: [
{
any: [
{
field: 'name',
operator: '=',
value: 'John'
},
{
field: 'name',
operator: '<>',
value: 'Daenerys'
}
],
{
field: 'age',
operator: '>',
value: 25
}
}
]
};