Skip to content

Commit

Permalink
fix: unary op shorthand unsupported (#142)
Browse files Browse the repository at this point in the history
Unary ops should support single args (shorthand) as well as arrays with
just a single element.

Signed-off-by: Todd Baert <[email protected]>
  • Loading branch information
toddbaert authored May 23, 2024
1 parent cc2f5a1 commit 946ffc4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
19 changes: 13 additions & 6 deletions json/targeting.json
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,19 @@
}
},
"unaryOp": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"$ref": "#/definitions/args"
}
"anyOf": [
{
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"$ref": "#/definitions/args"
}
},
{
"$ref": "#/definitions/args"
}
]
},
"unaryRule": {
"title": "Unary Operation",
Expand Down
12 changes: 7 additions & 5 deletions json/targeting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,13 @@ definitions:
of arguments.
$ref: "#/definitions/associativeOp"
unaryOp:
type: array
minItems: 1
maxItems: 1
items:
$ref: "#/definitions/args"
anyOf:
- type: array
minItems: 1
maxItems: 1
items:
"$ref": "#/definitions/args"
- "$ref": "#/definitions/args"
unaryRule:
title: Unary Operation
description: Any primitive JSONLogic operation with 1 operands.
Expand Down
1 change: 1 addition & 0 deletions json/test/positive/basic-json-ops.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
{"!=" : [1, 2]},
{"!==" : [1, 2]},
{"!": [true]},
{"!": true},
{"!!": ["0"] },
{"or": [true, false]},
{"or":[false, 0, "a"]},
Expand Down

0 comments on commit 946ffc4

Please sign in to comment.