diff --git a/tests/draft2019-09/if-then-else.json b/tests/draft2019-09/if-then-else.json index 510a0e0a..8b965f17 100644 --- a/tests/draft2019-09/if-then-else.json +++ b/tests/draft2019-09/if-then-else.json @@ -264,5 +264,64 @@ "valid": false } ] - } + }, + { + "description": "then: false fails when condition matches", + "schema": { + "if": { "const": 1 }, + "then": false + }, + "tests": [ + { + "description": "matches if → then=false → invalid", + "data": 1, + "valid": false + }, + { + "description": "does not match if → then ignored → valid", + "data": 2, + "valid": true + } + ] + }, + { + "description": "else: false fails when condition does not match", + "schema": { + "if": { "const": 1 }, + "else": false + }, + "tests": [ + { + "description": "matches if → else ignored → valid", + "data": 1, + "valid": true + }, + { + "description": "does not match if → else executes → invalid", + "data": 2, + "valid": false + } + ] + }, + { + "description": "then and else both are false", + "schema":{ + "if":{"type":"number"}, + "then":false, + "else":false + }, + "tests":[ + { + "description": "matches if → then executes and else does not execute → invalid", + "data": 4, + "valid": false + }, + { + "description": "does not match if → else executes → invalid", + "data": "foo", + "valid": false + } + ] + } ] + diff --git a/tests/draft2020-12/if-then-else.json b/tests/draft2020-12/if-then-else.json index 1c35d7e6..acdfc3d0 100644 --- a/tests/draft2020-12/if-then-else.json +++ b/tests/draft2020-12/if-then-else.json @@ -264,5 +264,63 @@ "valid": false } ] - } + }, + { + "description": "then: false fails when condition matches", + "schema": { + "if": { "const": 1 }, + "then": false + }, + "tests": [ + { + "description": "matches if → then=false → invalid", + "data": 1, + "valid": false + }, + { + "description": "does not match if → then ignored → valid", + "data": 2, + "valid": true + } + ] + }, + { + "description": "else: false fails when condition does not match", + "schema": { + "if": { "const": 1 }, + "else": false + }, + "tests": [ + { + "description": "matches if → else ignored → valid", + "data": 1, + "valid": true + }, + { + "description": "does not match if → else executes → invalid", + "data": 2, + "valid": false + } + ] + }, + { + "description": "then and else both are false", + "schema":{ + "if":{"type":"number"}, + "then":false, + "else":false + }, + "tests":[ + { + "description": "matches if → then executes and else does not execute → invalid", + "data": 4, + "valid": false + }, + { + "description": "does not match if → else executes → invalid", + "data": "foo", + "valid": false + } + ] + } ] diff --git a/tests/draft7/if-then-else.json b/tests/draft7/if-then-else.json index 284e9191..7a4a92ca 100644 --- a/tests/draft7/if-then-else.json +++ b/tests/draft7/if-then-else.json @@ -254,5 +254,63 @@ "valid": false } ] - } + }, + { + "description": "then: false fails when condition matches", + "schema": { + "if": { "const": 1 }, + "then": false + }, + "tests": [ + { + "description": "matches if → then=false → invalid", + "data": 1, + "valid": false + }, + { + "description": "does not match if → then ignored → valid", + "data": 2, + "valid": true + } + ] + }, + { + "description": "else: false fails when condition does not match", + "schema": { + "if": { "const": 1 }, + "else": false + }, + "tests": [ + { + "description": "matches if → else ignored → valid", + "data": 1, + "valid": true + }, + { + "description": "does not match if → else executes → invalid", + "data": 2, + "valid": false + } + ] + }, + { + "description": "then and else both are false", + "schema":{ + "if":{"type":"number"}, + "then":false, + "else":false + }, + "tests":[ + { + "description": "matches if → then executes and else does not execute → invalid", + "data": 4, + "valid": false + }, + { + "description": "does not match if → else executes → invalid", + "data": "foo", + "valid": false + } + ] + } ]