-
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
Matching documents in array #14
Comments
Hi @Mihailoff! I appreciate your contributions to the repo! I actually do agree that being more explicit improves readability in this case, but I'd like to remain as spec-compliant as possible with JSON-Logic. Thinking through options:
If "$this" was added, would the traversal syntax remain the same? For example, If you wanted to access data from an above section,
|
Where is the spec? :) https://jsonlogic.com doesn't mention empty
Following the "path" style, should it be then a dot This is my use case, a document with subdocuments. Will this work?
|
Hm, the website fails to mention it there: But it is implemented in the mainline repo here: https://github.com/jwadhams/json-logic-js/blob/9c805e9ac6a3787e8508e982a079888d3cc295b5/logic.js#L126 And shows up on the website under this section: https://jsonlogic.com/operations.html#all-none-and-some And is part of the test suite: https://jsonlogic.com/tests.json
Also yes, your rule there will work perfectly! import LogicEngine from './logic.js'
const engine = new LogicEngine()
const validate = engine.build({
some: [
{
var: 'items'
},
{
'<': [
{
var: 'a'
},
10
]
}
]
})
console.log(validate({
items: [
{
a: 1
},
{
a: 2
}
]
})) // true
console.log(validate({
items: [
{
a: 11
},
{
a: 12
}
]
})) // false |
There is
some
operator that iterates over an array.json-logic-engine/test.js
Line 466 in 5f1d2b5
Empty
var: ''
is confusing, a special character like$this
could make it more explicit.Regarding the nested object, I'd expect something like this:
What do you think?
The text was updated successfully, but these errors were encountered: