-
Notifications
You must be signed in to change notification settings - Fork 9
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
Can't get json-logic-engine to work with this logic #20
Comments
I'm not entirely sure that this should be considered valid logic; I'm tempted to put some work in to make the error message better (and not crash it at runtime), but the logic is essentially asking:
Multiplying with one argument, where that argument is a string. Is the expectation here that if engine.addMethod('*', (data) => Array.isArray(data) ? data.reduce((a, b) => +a * +b) : data, { deterministic: true }) This can be used to override the behavior. I can be convinced though! |
Ahh thanks @TotalTechGeek ! I am new to JsonLogic ... that was definitely a mistake in my logic. I was just trying to return some strings as part of my learning process. Here's the corrected json: {
"map": [
{
"var": ""
},
{
"cat": [
{
"var": "a"
},
" ",
{
"var": "b"
}
]
}
]
} which returns the expected output: I agree that a better error message would be helpful, but on the other hand json-logic-js executes it with no error at all which seems worse to me! Thanks for your help |
If you have any other questions, please don't hesitate to drop a comment! I'm going to leave this issue open to look into improving the error messages / validation. |
Hi there! I am evaluating json-logic-engine and I am finding that the following logic compiles but crashes at runtime. Same rule/data works in json-logic-js.
Logic:
Data:
Error:
The text was updated successfully, but these errors were encountered: