diff --git a/json/targeting.json b/json/targeting.json index 9d392f7..0799285 100644 --- a/json/targeting.json +++ b/json/targeting.json @@ -133,22 +133,6 @@ } } }, - "ifRule": { - "type": "object", - "additionalProperties": false, - "properties": { - "if": { - "title": "If Operator", - "description": "The if statement takes 1-3 arguments: a condition (\"if\"), what to do if its true (\"then\", optional, defaults to returning true), and what to do if its false (\"else\", optional, defaults to returning false). Note that the form accepting more than 3 arguments (else-if) is not supported in flagd; use nesting instead.", - "type": "array", - "minItems": 1, - "maxItems": 3, - "items": { - "$ref": "#/$defs/args" - } - } - } - }, "binaryOrTernaryOp": { "type": "array", "minItems": 2, @@ -190,6 +174,11 @@ "type": "object", "additionalProperties": false, "properties": { + "if": { + "title": "If Operator", + "description": "The if statement takes 1 or more arguments: a condition (\"if\"), what to do if its true (\"then\", optional, defaults to returning true), and what to do if its false (\"else\", optional, defaults to returning false). Note that the else condition can be used as an else-if statement by adding additional arguments.", + "$ref": "#/$defs/variadicOp" + }, "==": { "title": "Lose Equality Operation", "description": "Tests equality, with type coercion. Requires two arguments.", @@ -560,9 +549,6 @@ { "$ref": "#/$defs/missingSomeRule" }, - { - "$ref": "#/$defs/ifRule" - }, { "$ref": "#/$defs/binaryRule" }, diff --git a/json/targeting.yaml b/json/targeting.yaml index 571dd13..3b6f3a0 100644 --- a/json/targeting.yaml +++ b/json/targeting.yaml @@ -97,22 +97,6 @@ type: object - type: array items: type: string - ifRule: - type: object - additionalProperties: false - properties: - if: - title: If Operator - description: 'The if statement takes 1-3 arguments: a condition ("if"), what to - do if its true ("then", optional, defaults to returning true), - and what to do if its false ("else", optional, defaults to returning false). - Note that the form accepting more than 3 arguments (else-if) is not supported in flagd; - use nesting instead.' - type: array - minItems: 1 - maxItems: 3 - items: - $ref: "#/$defs/args" binaryOrTernaryOp: type: array minItems: 2 @@ -149,6 +133,10 @@ type: object type: object additionalProperties: false properties: + "if": + title: "If Operator" + description: "The if statement takes 1 or more arguments: a condition (\"if\"), what to do if its true (\"then\", optional, defaults to returning true), and what to do if its false (\"else\", optional, defaults to returning false). Note that the else condition can be used as an else-if statement by adding additional arguments." + $ref: "#/$defs/variadicOp" "==": title: Lose Equality Operation description: Tests equality, with type coercion. Requires two arguments. @@ -428,7 +416,6 @@ type: object - $ref: "#/$defs/varRule" - $ref: "#/$defs/missingRule" - $ref: "#/$defs/missingSomeRule" - - $ref: "#/$defs/ifRule" - $ref: "#/$defs/binaryRule" - $ref: "#/$defs/binaryOrTernaryRule" - $ref: "#/$defs/associativeRule" diff --git a/json/test/positive/basic-json-ops.json b/json/test/positive/basic-json-ops.json index c81465c..d6f9882 100644 --- a/json/test/positive/basic-json-ops.json +++ b/json/test/positive/basic-json-ops.json @@ -10,6 +10,7 @@ "defaultVariant": "on", "targeting": { "*" : [ + {"if" : [false, "false", false, "false", true, "true"] }, {"if" : [ true, "yes", "no" ]}, {"if" : [ true, "yes" ]}, {"if" : [ true ]},