CacheControl / CacheControl/json-rules-engine

allowUndefinedFacts not working when the facts type are string

Offen
#270 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
JavaScript
Sterne
3.1k
Forks
507
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Here's my example, you can reproduce the issue with the code:
`const customAttributeRule = {
"name": "allowUndefinedFacts-test",
"attributes": [
{
"name": "Astring",
"type": "string"
},
{
"name": "Bnumber",
"type": "number"
}
],
"decisions": [
{
"conditions": {
"all": [
{
"fact": "Astring",
"operator": "notEqual",
"value": "string"
}
]
},
"event": {
"type": "Astring",
"params": {
"value": "1",
"description": "Astring test"
}
}
},
{
"conditions": {
"all": [
{
"fact": "Bnumber",
"operator": "lessThan",
"value": 5
}
]
},
"event": {
"type": "Bnumber",
"params": {
"value": "1",
"description": "Bnumber test"
}
}
}
]
}`
`let facts = {}`
`const engine = new Engine(customAttributeRule.decisions, {allowUndefinedFacts: true});
engine.on('success', event => {
console.log(event)
});`
`let result = engine .run(facts)`
The engine output is
`{
type: 'Astring',
params: { value: '1', description: 'Astring test' }
}`
However, the allowUndefinedFacts works when then fact type is number

Since the engine treat undefined facts as undefined, so I added another condition that `{
"fact": "Astring",
"operator": "notEqual",
"value": "undefined"
}`, but it still does not work as expected

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.