495 lines
14 KiB
JSON
495 lines
14 KiB
JSON
[
|
|
{
|
|
"description": "ignore if without then or else",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"if": {
|
|
"const": 0
|
|
},
|
|
"$id": "if-then-else_0_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "valid when valid against lone if",
|
|
"data": 0,
|
|
"valid": true,
|
|
"schema_id": "if-then-else_0_0"
|
|
},
|
|
{
|
|
"description": "valid when invalid against lone if",
|
|
"data": "hello",
|
|
"valid": true,
|
|
"schema_id": "if-then-else_0_0"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "ignore then without if",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"then": {
|
|
"const": 0
|
|
},
|
|
"$id": "if-then-else_1_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "valid when valid against lone then",
|
|
"data": 0,
|
|
"valid": true,
|
|
"schema_id": "if-then-else_1_0"
|
|
},
|
|
{
|
|
"description": "valid when invalid against lone then",
|
|
"data": "hello",
|
|
"valid": true,
|
|
"schema_id": "if-then-else_1_0"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "ignore else without if",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"else": {
|
|
"const": 0
|
|
},
|
|
"$id": "if-then-else_2_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "valid when valid against lone else",
|
|
"data": 0,
|
|
"valid": true,
|
|
"schema_id": "if-then-else_2_0"
|
|
},
|
|
{
|
|
"description": "valid when invalid against lone else",
|
|
"data": "hello",
|
|
"valid": true,
|
|
"schema_id": "if-then-else_2_0"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "if and then without else",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"if": {
|
|
"exclusiveMaximum": 0
|
|
},
|
|
"then": {
|
|
"minimum": -10
|
|
},
|
|
"$id": "if-then-else_3_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "valid through then",
|
|
"data": -1,
|
|
"valid": true,
|
|
"schema_id": "if-then-else_3_0"
|
|
},
|
|
{
|
|
"description": "invalid through then",
|
|
"data": -100,
|
|
"valid": false,
|
|
"schema_id": "if-then-else_3_0"
|
|
},
|
|
{
|
|
"description": "valid when if test fails",
|
|
"data": 3,
|
|
"valid": true,
|
|
"schema_id": "if-then-else_3_0"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "if and else without then",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"if": {
|
|
"exclusiveMaximum": 0
|
|
},
|
|
"else": {
|
|
"multipleOf": 2
|
|
},
|
|
"$id": "if-then-else_4_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "valid when if test passes",
|
|
"data": -1,
|
|
"valid": true,
|
|
"schema_id": "if-then-else_4_0"
|
|
},
|
|
{
|
|
"description": "valid through else",
|
|
"data": 4,
|
|
"valid": true,
|
|
"schema_id": "if-then-else_4_0"
|
|
},
|
|
{
|
|
"description": "invalid through else",
|
|
"data": 3,
|
|
"valid": false,
|
|
"schema_id": "if-then-else_4_0"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "validate against correct branch, then vs else",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"if": {
|
|
"exclusiveMaximum": 0
|
|
},
|
|
"then": {
|
|
"minimum": -10
|
|
},
|
|
"else": {
|
|
"multipleOf": 2
|
|
},
|
|
"$id": "if-then-else_5_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "valid through then",
|
|
"data": -1,
|
|
"valid": true,
|
|
"schema_id": "if-then-else_5_0"
|
|
},
|
|
{
|
|
"description": "invalid through then",
|
|
"data": -100,
|
|
"valid": false,
|
|
"schema_id": "if-then-else_5_0"
|
|
},
|
|
{
|
|
"description": "valid through else",
|
|
"data": 4,
|
|
"valid": true,
|
|
"schema_id": "if-then-else_5_0"
|
|
},
|
|
{
|
|
"description": "invalid through else",
|
|
"data": 3,
|
|
"valid": false,
|
|
"schema_id": "if-then-else_5_0"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "non-interference across combined schemas",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"allOf": [
|
|
{
|
|
"if": {
|
|
"exclusiveMaximum": 0
|
|
}
|
|
},
|
|
{
|
|
"then": {
|
|
"minimum": -10
|
|
}
|
|
},
|
|
{
|
|
"else": {
|
|
"multipleOf": 2
|
|
}
|
|
}
|
|
],
|
|
"$id": "if-then-else_6_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "valid, but would have been invalid through then",
|
|
"data": -100,
|
|
"valid": true,
|
|
"schema_id": "if-then-else_6_0"
|
|
},
|
|
{
|
|
"description": "valid, but would have been invalid through else",
|
|
"data": 3,
|
|
"valid": true,
|
|
"schema_id": "if-then-else_6_0"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "if with boolean schema true",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"if": true,
|
|
"then": {
|
|
"const": "then"
|
|
},
|
|
"else": {
|
|
"const": "else"
|
|
},
|
|
"$id": "if-then-else_7_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "boolean schema true in if always chooses the then path (valid)",
|
|
"data": "then",
|
|
"valid": true,
|
|
"schema_id": "if-then-else_7_0"
|
|
},
|
|
{
|
|
"description": "boolean schema true in if always chooses the then path (invalid)",
|
|
"data": "else",
|
|
"valid": false,
|
|
"schema_id": "if-then-else_7_0"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "if with boolean schema false",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"if": false,
|
|
"then": {
|
|
"const": "then"
|
|
},
|
|
"else": {
|
|
"const": "else"
|
|
},
|
|
"$id": "if-then-else_8_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "boolean schema false in if always chooses the else path (invalid)",
|
|
"data": "then",
|
|
"valid": false,
|
|
"schema_id": "if-then-else_8_0"
|
|
},
|
|
{
|
|
"description": "boolean schema false in if always chooses the else path (valid)",
|
|
"data": "else",
|
|
"valid": true,
|
|
"schema_id": "if-then-else_8_0"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "if appears at the end when serialized (keyword processing sequence)",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"then": {
|
|
"const": "yes"
|
|
},
|
|
"else": {
|
|
"const": "other"
|
|
},
|
|
"if": {
|
|
"maxLength": 4
|
|
},
|
|
"$id": "if-then-else_9_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "yes redirects to then and passes",
|
|
"data": "yes",
|
|
"valid": true,
|
|
"schema_id": "if-then-else_9_0"
|
|
},
|
|
{
|
|
"description": "other redirects to else and passes",
|
|
"data": "other",
|
|
"valid": true,
|
|
"schema_id": "if-then-else_9_0"
|
|
},
|
|
{
|
|
"description": "no redirects to then and fails",
|
|
"data": "no",
|
|
"valid": false,
|
|
"schema_id": "if-then-else_9_0"
|
|
},
|
|
{
|
|
"description": "invalid redirects to else and fails",
|
|
"data": "invalid",
|
|
"valid": false,
|
|
"schema_id": "if-then-else_9_0"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "then: false fails when condition matches",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"if": {
|
|
"const": 1
|
|
},
|
|
"then": false,
|
|
"$id": "if-then-else_10_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "matches if → then=false → invalid",
|
|
"data": 1,
|
|
"valid": false,
|
|
"schema_id": "if-then-else_10_0"
|
|
},
|
|
{
|
|
"description": "does not match if → then ignored → valid",
|
|
"data": 2,
|
|
"valid": true,
|
|
"schema_id": "if-then-else_10_0"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "else: false fails when condition does not match",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"if": {
|
|
"const": 1
|
|
},
|
|
"else": false,
|
|
"$id": "if-then-else_11_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "matches if → else ignored → valid",
|
|
"data": 1,
|
|
"valid": true,
|
|
"schema_id": "if-then-else_11_0"
|
|
},
|
|
{
|
|
"description": "does not match if → else executes → invalid",
|
|
"data": 2,
|
|
"valid": false,
|
|
"schema_id": "if-then-else_11_0"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "extensible: true allows extra properties in if-then-else",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"if": {
|
|
"properties": {
|
|
"foo": {
|
|
"const": 1
|
|
}
|
|
},
|
|
"required": [
|
|
"foo"
|
|
]
|
|
},
|
|
"then": {
|
|
"properties": {
|
|
"bar": {
|
|
"const": 2
|
|
}
|
|
},
|
|
"required": [
|
|
"bar"
|
|
]
|
|
},
|
|
"extensible": true,
|
|
"$id": "if-then-else_12_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "extra property is valid (matches if and then)",
|
|
"data": {
|
|
"foo": 1,
|
|
"bar": 2,
|
|
"extra": "prop"
|
|
},
|
|
"valid": true,
|
|
"schema_id": "if-then-else_12_0"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "strict by default with if-then properties",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"if": {
|
|
"properties": {
|
|
"foo": {
|
|
"const": 1
|
|
}
|
|
},
|
|
"required": [
|
|
"foo"
|
|
]
|
|
},
|
|
"then": {
|
|
"properties": {
|
|
"bar": {
|
|
"const": 2
|
|
}
|
|
}
|
|
},
|
|
"$id": "if-then-else_13_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "valid match (foo + bar)",
|
|
"data": {
|
|
"foo": 1,
|
|
"bar": 2
|
|
},
|
|
"valid": true,
|
|
"schema_id": "if-then-else_13_0"
|
|
},
|
|
{
|
|
"description": "fails on extra property z explicitly",
|
|
"data": {
|
|
"foo": 1,
|
|
"bar": 2,
|
|
"z": 3
|
|
},
|
|
"valid": false,
|
|
"schema_id": "if-then-else_13_0"
|
|
}
|
|
]
|
|
}
|
|
] |