json-schema-rules-engine
json-schema-rules-engine copied to clipboard
It is unclear where json-schema syntax can be used
from the rules object of the example it is not clear where standard json-schema syntax can be used and library syntax is needed.
It seems that when, then, otherwise, is, actions are keywords from the library, while this oject in is is json-schema.
const rules = {
dailyTemp: {
when: [
{
weather: {
params: {
query: '{{city}}',
appId: '{{apiKey}}',
units: '{{units}}',
},
path: 'main.temp',
is: {
type: 'number',
minimum: '{{hotTemp}}',
},
},
},
],
then: {
actions: [
{
type: 'log',
params: { message: 'Quite hot out today!' },
},
],
},
otherwise: {
actions: [
{
type: 'log',
params: { message: 'Brrr, bundle up!' },
},
],
},
},
};
If this is correct, a simple rule could be written as:
const rules = {
simple: {
when: [
{
weather: {},
is: {
type: 'object',
properties {
temp: {
type: 'number'
}
}
},
},
},
],
}
Is this correct?