CacheControl / CacheControl/json-rules-engine
allowUndefinedFacts not working when the facts type are string
- Linguagem predominante
- JavaScript
- Estrelas
- 3.1k
- Forks
- 507
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
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
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Direção de pesquisa
Comece executando a reprodução fornecida com Engine.run, um objeto facts vazio e allowUndefinedFacts habilitado; em seguida, acompanhe como o operador notEqual trata o fact undefined Astring em comparação com o fact numérico Bnumber. Está concluído quando a opção se comportar de forma consistente para ambos os tipos de fact e a reprodução produzir o resultado esperado documentado.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- javascript
- Domínio
- backend
- Tipo de issue
- Bug
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 35/100