736 lines
14 KiB
JSON
736 lines
14 KiB
JSON
[
|
|
{
|
|
"description": "simple enum validation",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"enum": [
|
|
1,
|
|
2,
|
|
3
|
|
],
|
|
"$id": "enum_0_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "one of the enum is valid",
|
|
"data": 1,
|
|
"schema_id": "enum_0_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "something else is invalid",
|
|
"data": 4,
|
|
"schema_id": "enum_0_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "heterogeneous enum validation",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"enum": [
|
|
6,
|
|
"foo",
|
|
[],
|
|
true,
|
|
{
|
|
"foo": 12
|
|
}
|
|
],
|
|
"properties": {
|
|
"foo": {}
|
|
},
|
|
"$id": "enum_1_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "one of the enum is valid",
|
|
"data": [],
|
|
"schema_id": "enum_1_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "something else is invalid",
|
|
"data": null,
|
|
"schema_id": "enum_1_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false
|
|
}
|
|
},
|
|
{
|
|
"description": "objects are deep compared",
|
|
"data": {
|
|
"foo": false
|
|
},
|
|
"schema_id": "enum_1_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false
|
|
}
|
|
},
|
|
{
|
|
"description": "valid object matches",
|
|
"data": {
|
|
"foo": 12
|
|
},
|
|
"schema_id": "enum_1_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "extra properties in object is invalid",
|
|
"data": {
|
|
"foo": 12,
|
|
"boo": 42
|
|
},
|
|
"schema_id": "enum_1_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "heterogeneous enum-with-null validation",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"enum": [
|
|
6,
|
|
null
|
|
],
|
|
"$id": "enum_2_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "null is valid",
|
|
"data": null,
|
|
"schema_id": "enum_2_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "number is valid",
|
|
"data": 6,
|
|
"schema_id": "enum_2_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "something else is invalid",
|
|
"data": "test",
|
|
"schema_id": "enum_2_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "enums in properties",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"type": "object",
|
|
"properties": {
|
|
"foo": {
|
|
"enum": [
|
|
"foo"
|
|
]
|
|
},
|
|
"bar": {
|
|
"enum": [
|
|
"bar"
|
|
]
|
|
}
|
|
},
|
|
"required": [
|
|
"bar"
|
|
],
|
|
"$id": "enum_3_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "both properties are valid",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar"
|
|
},
|
|
"schema_id": "enum_3_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "wrong foo value",
|
|
"data": {
|
|
"foo": "foot",
|
|
"bar": "bar"
|
|
},
|
|
"schema_id": "enum_3_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false
|
|
}
|
|
},
|
|
{
|
|
"description": "wrong bar value",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bart"
|
|
},
|
|
"schema_id": "enum_3_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false
|
|
}
|
|
},
|
|
{
|
|
"description": "missing optional property is valid",
|
|
"data": {
|
|
"bar": "bar"
|
|
},
|
|
"schema_id": "enum_3_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "missing required property is invalid",
|
|
"data": {
|
|
"foo": "foo"
|
|
},
|
|
"schema_id": "enum_3_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false
|
|
}
|
|
},
|
|
{
|
|
"description": "missing all properties is invalid",
|
|
"data": {},
|
|
"schema_id": "enum_3_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "enum with escaped characters",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"enum": [
|
|
"foo\nbar",
|
|
"foo\rbar"
|
|
],
|
|
"$id": "enum_4_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "member 1 is valid",
|
|
"data": "foo\nbar",
|
|
"schema_id": "enum_4_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "member 2 is valid",
|
|
"data": "foo\rbar",
|
|
"schema_id": "enum_4_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "another string is invalid",
|
|
"data": "abc",
|
|
"schema_id": "enum_4_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "enum with false does not match 0",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"enum": [
|
|
false
|
|
],
|
|
"$id": "enum_5_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "false is valid",
|
|
"data": false,
|
|
"schema_id": "enum_5_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "integer zero is invalid",
|
|
"data": 0,
|
|
"schema_id": "enum_5_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false
|
|
}
|
|
},
|
|
{
|
|
"description": "float zero is invalid",
|
|
"data": 0,
|
|
"schema_id": "enum_5_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "enum with [false] does not match [0]",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"enum": [
|
|
[
|
|
false
|
|
]
|
|
],
|
|
"$id": "enum_6_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "[false] is valid",
|
|
"data": [
|
|
false
|
|
],
|
|
"schema_id": "enum_6_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "[0] is invalid",
|
|
"data": [
|
|
0
|
|
],
|
|
"schema_id": "enum_6_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false
|
|
}
|
|
},
|
|
{
|
|
"description": "[0.0] is invalid",
|
|
"data": [
|
|
0
|
|
],
|
|
"schema_id": "enum_6_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "enum with true does not match 1",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"enum": [
|
|
true
|
|
],
|
|
"$id": "enum_7_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "true is valid",
|
|
"data": true,
|
|
"schema_id": "enum_7_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "integer one is invalid",
|
|
"data": 1,
|
|
"schema_id": "enum_7_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false
|
|
}
|
|
},
|
|
{
|
|
"description": "float one is invalid",
|
|
"data": 1,
|
|
"schema_id": "enum_7_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "enum with [true] does not match [1]",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"enum": [
|
|
[
|
|
true
|
|
]
|
|
],
|
|
"$id": "enum_8_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "[true] is valid",
|
|
"data": [
|
|
true
|
|
],
|
|
"schema_id": "enum_8_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "[1] is invalid",
|
|
"data": [
|
|
1
|
|
],
|
|
"schema_id": "enum_8_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false
|
|
}
|
|
},
|
|
{
|
|
"description": "[1.0] is invalid",
|
|
"data": [
|
|
1
|
|
],
|
|
"schema_id": "enum_8_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "enum with 0 does not match false",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"enum": [
|
|
0
|
|
],
|
|
"$id": "enum_9_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "false is invalid",
|
|
"data": false,
|
|
"schema_id": "enum_9_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false
|
|
}
|
|
},
|
|
{
|
|
"description": "integer zero is valid",
|
|
"data": 0,
|
|
"schema_id": "enum_9_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "float zero is valid",
|
|
"data": 0,
|
|
"schema_id": "enum_9_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "enum with [0] does not match [false]",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"enum": [
|
|
[
|
|
0
|
|
]
|
|
],
|
|
"$id": "enum_10_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "[false] is invalid",
|
|
"data": [
|
|
false
|
|
],
|
|
"schema_id": "enum_10_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false
|
|
}
|
|
},
|
|
{
|
|
"description": "[0] is valid",
|
|
"data": [
|
|
0
|
|
],
|
|
"schema_id": "enum_10_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "[0.0] is valid",
|
|
"data": [
|
|
0
|
|
],
|
|
"schema_id": "enum_10_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "enum with 1 does not match true",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"enum": [
|
|
1
|
|
],
|
|
"$id": "enum_11_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "true is invalid",
|
|
"data": true,
|
|
"schema_id": "enum_11_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false
|
|
}
|
|
},
|
|
{
|
|
"description": "integer one is valid",
|
|
"data": 1,
|
|
"schema_id": "enum_11_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "float one is valid",
|
|
"data": 1,
|
|
"schema_id": "enum_11_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "enum with [1] does not match [true]",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"enum": [
|
|
[
|
|
1
|
|
]
|
|
],
|
|
"$id": "enum_12_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "[true] is invalid",
|
|
"data": [
|
|
true
|
|
],
|
|
"schema_id": "enum_12_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false
|
|
}
|
|
},
|
|
{
|
|
"description": "[1] is valid",
|
|
"data": [
|
|
1
|
|
],
|
|
"schema_id": "enum_12_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "[1.0] is valid",
|
|
"data": [
|
|
1
|
|
],
|
|
"schema_id": "enum_12_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "nul characters in strings",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"enum": [
|
|
"hello\u0000there"
|
|
],
|
|
"$id": "enum_13_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "match string with nul",
|
|
"data": "hello\u0000there",
|
|
"schema_id": "enum_13_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "do not match string lacking nul",
|
|
"data": "hellothere",
|
|
"schema_id": "enum_13_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "extensible: true allows extra properties in enum object match",
|
|
"database": {
|
|
"schemas": [
|
|
{
|
|
"enum": [
|
|
{
|
|
"foo": 1
|
|
}
|
|
],
|
|
"extensible": true,
|
|
"$id": "enum_14_0"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "extra property ignored during strict check, but enum check still applies (mismatch here)",
|
|
"data": {
|
|
"foo": 1,
|
|
"bar": 2
|
|
},
|
|
"schema_id": "enum_14_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false
|
|
}
|
|
},
|
|
{
|
|
"description": "extra property ignored during strict check, enum match succeeds",
|
|
"data": {
|
|
"foo": 1
|
|
},
|
|
"schema_id": "enum_14_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
}
|
|
]
|
|
}
|
|
] |