700 lines
14 KiB
JSON
700 lines
14 KiB
JSON
[
|
|
{
|
|
"description": "a schema given for items",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "items_0_0",
|
|
"schemas": {
|
|
"items_0_0": {
|
|
"items": {
|
|
"type": "integer"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "valid items",
|
|
"data": [
|
|
1,
|
|
2,
|
|
3
|
|
],
|
|
"schema_id": "items_0_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "wrong type of items",
|
|
"data": [
|
|
1,
|
|
"x"
|
|
],
|
|
"schema_id": "items_0_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "INVALID_TYPE",
|
|
"values": {
|
|
"expected": "integer"
|
|
},
|
|
"details": {
|
|
"path": "1",
|
|
"schema": "items_0_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "non-arrays are invalid",
|
|
"data": {
|
|
"foo": "bar"
|
|
},
|
|
"schema_id": "items_0_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "STRICT_PROPERTY_VIOLATION",
|
|
"values": {
|
|
"property_name": "foo"
|
|
},
|
|
"details": {
|
|
"path": "foo",
|
|
"schema": "items_0_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "JavaScript pseudo-arrays are invalid",
|
|
"data": {
|
|
"0": "invalid",
|
|
"length": 1
|
|
},
|
|
"schema_id": "items_0_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "STRICT_PROPERTY_VIOLATION",
|
|
"values": {
|
|
"property_name": "0"
|
|
},
|
|
"details": {
|
|
"path": "0",
|
|
"schema": "items_0_0"
|
|
}
|
|
},
|
|
{
|
|
"code": "STRICT_PROPERTY_VIOLATION",
|
|
"values": {
|
|
"property_name": "length"
|
|
},
|
|
"details": {
|
|
"path": "length",
|
|
"schema": "items_0_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "items with boolean schema (true)",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "items_1_0",
|
|
"schemas": {
|
|
"items_1_0": {
|
|
"items": true
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "any array is valid",
|
|
"data": [
|
|
1,
|
|
"foo",
|
|
true
|
|
],
|
|
"schema_id": "items_1_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "empty array is valid",
|
|
"data": [],
|
|
"schema_id": "items_1_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "items with boolean schema (false)",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "items_2_0",
|
|
"schemas": {
|
|
"items_2_0": {
|
|
"items": false
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "any non-empty array is invalid",
|
|
"data": [
|
|
1,
|
|
"foo",
|
|
true
|
|
],
|
|
"schema_id": "items_2_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "FALSE_SCHEMA",
|
|
"details": {
|
|
"path": "0",
|
|
"schema": "items_2_0"
|
|
}
|
|
},
|
|
{
|
|
"code": "FALSE_SCHEMA",
|
|
"details": {
|
|
"path": "1",
|
|
"schema": "items_2_0"
|
|
}
|
|
},
|
|
{
|
|
"code": "FALSE_SCHEMA",
|
|
"details": {
|
|
"path": "2",
|
|
"schema": "items_2_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "empty array is valid",
|
|
"data": [],
|
|
"schema_id": "items_2_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "nested items",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "items_4_0",
|
|
"schemas": {
|
|
"items_4_0": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "number"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "valid nested array",
|
|
"data": [
|
|
[
|
|
[
|
|
[
|
|
1
|
|
]
|
|
],
|
|
[
|
|
[
|
|
2
|
|
],
|
|
[
|
|
3
|
|
]
|
|
]
|
|
],
|
|
[
|
|
[
|
|
[
|
|
4
|
|
],
|
|
[
|
|
5
|
|
],
|
|
[
|
|
6
|
|
]
|
|
]
|
|
]
|
|
],
|
|
"schema_id": "items_4_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "nested array with invalid type",
|
|
"data": [
|
|
[
|
|
[
|
|
[
|
|
"1"
|
|
]
|
|
],
|
|
[
|
|
[
|
|
2
|
|
],
|
|
[
|
|
3
|
|
]
|
|
]
|
|
],
|
|
[
|
|
[
|
|
[
|
|
4
|
|
],
|
|
[
|
|
5
|
|
],
|
|
[
|
|
6
|
|
]
|
|
]
|
|
]
|
|
],
|
|
"schema_id": "items_4_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "INVALID_TYPE",
|
|
"values": {
|
|
"expected": "number"
|
|
},
|
|
"details": {
|
|
"path": "0/0/0/0",
|
|
"schema": "items_4_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "not deep enough",
|
|
"data": [
|
|
[
|
|
[
|
|
1
|
|
],
|
|
[
|
|
2
|
|
],
|
|
[
|
|
3
|
|
]
|
|
],
|
|
[
|
|
[
|
|
4
|
|
],
|
|
[
|
|
5
|
|
],
|
|
[
|
|
6
|
|
]
|
|
]
|
|
],
|
|
"schema_id": "items_4_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "INVALID_TYPE",
|
|
"values": {
|
|
"expected": "array"
|
|
},
|
|
"details": {
|
|
"path": "0/0/0",
|
|
"schema": "items_4_0"
|
|
}
|
|
},
|
|
{
|
|
"code": "INVALID_TYPE",
|
|
"values": {
|
|
"expected": "array"
|
|
},
|
|
"details": {
|
|
"path": "0/1/0",
|
|
"schema": "items_4_0"
|
|
}
|
|
},
|
|
{
|
|
"code": "INVALID_TYPE",
|
|
"values": {
|
|
"expected": "array"
|
|
},
|
|
"details": {
|
|
"path": "0/2/0",
|
|
"schema": "items_4_0"
|
|
}
|
|
},
|
|
{
|
|
"code": "INVALID_TYPE",
|
|
"values": {
|
|
"expected": "array"
|
|
},
|
|
"details": {
|
|
"path": "1/0/0",
|
|
"schema": "items_4_0"
|
|
}
|
|
},
|
|
{
|
|
"code": "INVALID_TYPE",
|
|
"values": {
|
|
"expected": "array"
|
|
},
|
|
"details": {
|
|
"path": "1/1/0",
|
|
"schema": "items_4_0"
|
|
}
|
|
},
|
|
{
|
|
"code": "INVALID_TYPE",
|
|
"values": {
|
|
"expected": "array"
|
|
},
|
|
"details": {
|
|
"path": "1/2/0",
|
|
"schema": "items_4_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "items with null instance elements",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "items_9_0",
|
|
"schemas": {
|
|
"items_9_0": {
|
|
"items": {
|
|
"type": "null"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "allows null elements",
|
|
"data": [
|
|
null
|
|
],
|
|
"schema_id": "items_9_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "extensible: true allows extra items (when items is false)",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "items_10_0",
|
|
"schemas": {
|
|
"items_10_0": {
|
|
"items": false,
|
|
"extensible": true
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "extra item is valid",
|
|
"data": [
|
|
1
|
|
],
|
|
"schema_id": "items_10_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "FALSE_SCHEMA",
|
|
"details": {
|
|
"path": "0",
|
|
"schema": "items_10_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "extensible: true allows extra properties for items",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "items_11_0",
|
|
"schemas": {
|
|
"items_11_0": {
|
|
"items": {
|
|
"minimum": 5
|
|
},
|
|
"extensible": true
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "valid item is valid",
|
|
"data": [
|
|
5,
|
|
6
|
|
],
|
|
"schema_id": "items_11_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "invalid item (less than min) is invalid even with extensible: true",
|
|
"data": [
|
|
4
|
|
],
|
|
"schema_id": "items_11_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "MINIMUM_VIOLATED",
|
|
"values": {
|
|
"limit": "5",
|
|
"value": "4"
|
|
},
|
|
"details": {
|
|
"path": "0",
|
|
"schema": "items_11_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "array: simple extensible array",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "items_12_0",
|
|
"schemas": {
|
|
"items_12_0": {
|
|
"type": "array",
|
|
"extensible": true
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "empty array is valid",
|
|
"data": [],
|
|
"schema_id": "items_12_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "array with items is valid (extensible)",
|
|
"data": [
|
|
1,
|
|
"foo"
|
|
],
|
|
"schema_id": "items_12_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "array: items extensible",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "items_14_0",
|
|
"schemas": {
|
|
"items_14_0": {
|
|
"type": "array",
|
|
"items": {
|
|
"extensible": true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "empty array is valid",
|
|
"data": [],
|
|
"schema_id": "items_14_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "array with items is valid (items explicitly allowed to be anything extensible)",
|
|
"data": [
|
|
1,
|
|
"foo",
|
|
{}
|
|
],
|
|
"schema_id": "items_14_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "array: items strict",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "items_15_0",
|
|
"schemas": {
|
|
"items_15_0": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "object",
|
|
"extensible": false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "empty array is valid (empty objects)",
|
|
"data": [
|
|
{}
|
|
],
|
|
"schema_id": "items_15_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "array with strict object items is valid",
|
|
"data": [
|
|
{}
|
|
],
|
|
"schema_id": "items_15_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "array with invalid strict object items (extra property)",
|
|
"data": [
|
|
{
|
|
"extra": 1
|
|
}
|
|
],
|
|
"schema_id": "items_15_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "STRICT_PROPERTY_VIOLATION",
|
|
"values": {
|
|
"property_name": "extra"
|
|
},
|
|
"details": {
|
|
"path": "0/extra",
|
|
"schema": "items_15_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
}
|
|
] |