-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not possible to use 0 in if/or/and? #94
Comments
@dextervanroo, in case this issue is still something that you are struggling with, could you please provide an example of a data object that you are using in your tests that causes this issue. I've performed a few quick tests and it looks like that everything works as expected. I suspect this is due to the data object that I'm using for my tests. |
@shupoval If I use |
@dextervanroo, thank you for the clarification. It is clear now. The long story short, in case @jwadhams, shouldn't we come up with something similar to the Truthy and Falsy in case of comparison operators in order to make JsonLogic's rules return the same results when executed by different languages? @dextervanroo, I'd like to suggest you to switch from the |
@shupoval But why is it that the code works just by removing the {
"if": [{
"or": [{
"===": [{
"var": "data.km"
}, false]
}, {
"===": [{
"var": "km"
}, false]
}]
}, "erro1", {
"or": [{
"and": [{
"**>=**": [{
"var": "data.km"
}, 0]
}, {
"<=": [{
"var": "data.km"
}, 2.352]
}]
}, {
"and": [{
"**>=**": [{
"var": "km"
}, 0]
}, {
"<=": [{
"var": "km"
}, 2.352]
}]
}]
}, "aqui", {
"or": [{
"and": [{
">=": [{
"var": "data.km"
}, 4.916]
}, {
"<=": [{
"var": "data.km"
}, 16.846]
}]
}, {
"and": [{
">=": [{
"var": "km"
}, 4.916]
}, {
"<=": [{
"var": "km"
}, 16.846]
}]
}]
}, "embaixo", "errei"]
} Same test parameter ( |
@dextervanroo, the reason is due to how javascript evaluates
In your case when data is if((null >= 0 && null <= 2.352) || (10 >= 0 && 10 <= 2.352))
console.log("aqui"); |
Hello. I'm trying to write a code for a data interval check and I was having trouble at first with the nested-if logic. After reading #69 I think got it right. What I'm trying to do is the following:
data.km
orkm
isfalse
, returnerro1
data.km
orkm
<= 2.352, returnaqui
data.km
orkm
<= 16.846, returnembaixo
errei
The problem is that this logic only works if I remove the
=
part of the highlighted>=
. Am I doing something wrong or is this intended behavior?The text was updated successfully, but these errors were encountered: