-
Notifications
You must be signed in to change notification settings - Fork 6
Conversation
f100fde
to
49347e8
Compare
@@ -0,0 +1,55 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope this schema implements all features documented here:
http://jsonlogic.com/operations.html#var
schemas/operators/logic/equal.json
Outdated
"title": "Any" | ||
}, | ||
{ | ||
"$ref": "http://jsonlogic.com/schemas/operators/operators/variable.json" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any other possible items for logical operators?
http://jsonlogic.com/operations.html#logic-and-boolean-operations
@@ -0,0 +1,28 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should be consistent :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed this one, all others within a separate PR
5b02725
to
d70bf54
Compare
|
||
"title": "All", | ||
"description": "Any valid JSON data type.", | ||
"type": ["array", "boolean", "null", "number", "object", "string"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ "$ref": "http://jsonlogic.com/schemas/operators/string/cat.json" }, | ||
{ "$ref": "http://jsonlogic.com/schemas/operators/string/substr.json" }, | ||
|
||
{ "$ref": "http://jsonlogic.com/schemas/common/all-types.json" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This schema is very loose, mainly because the API itself is very forgiving
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in this case a forgiving APi is nice
8381e38
to
0753e40
Compare
schemas/operators/misc/method.json
Outdated
"$id": "http://jsonlogic.com/schemas/operators/misc/method.json", | ||
|
||
"title": "method", | ||
"description": "If your rule needs to call a method on an object, you can use the built-in method operation.\n You can also pass an array of arguments into the methot.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lina-salih
@mjenny
The only operator documented on a other page:
http://jsonlogic.com/add_operation.html#calling-methods-on-objects
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NICE!
{ "$ref": "http://jsonlogic.com/schemas/operators/string/cat.json" }, | ||
{ "$ref": "http://jsonlogic.com/schemas/operators/string/substr.json" }, | ||
|
||
{ "$ref": "http://jsonlogic.com/schemas/common/all-types.json" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in this case a forgiving APi is nice
{ | ||
"type": "number", | ||
"title": "Index", | ||
"description": "You can also use the var operator to access an array by numeric index." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
"description": "An array with one or three elements.", | ||
"type": "array", | ||
"minItems": 1, | ||
"maxItems": 3, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it enough when we provide one-or-more args?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought so too at the beginning, then I saw that for example +
and *
take any number of arguments from 1 to infinity.
But -
and /
take only up to 2 - no more.
And then there are other special ops which take up to 3 like <
and <=
(in contrast to >
and >=
).
if
is the most complex number of args, it 2n + 1
, so 1, 3, 5, 7, 9, etc.
To make all of this even more complex, all operators support a single argument without an array.
It even doesn't matter if the provided number of arguments make sense, jsonLogic.apply
will try it's best to never fail and output nonsense in the worst case 😅
"oneOf": [ | ||
{ | ||
"title": "Single Array", | ||
"description": "An array with just one element.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think unary and one-or-more args cover all constellations 🤔
@@ -0,0 +1,28 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should be consistent :)
fixes #2
fixes jwadhams#55
Added