[ { "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": "items and subitems", "database": { "types": [ { "name": "items_3_0", "schemas": { "items_3_0": { "type": "array", "items": false, "prefixItems": [ { "type": "item" }, { "type": "item" }, { "type": "item" } ] } } }, { "name": "item", "schemas": { "item": { "type": "array", "items": false, "prefixItems": [ { "type": "sub-item" }, { "type": "sub-item" } ] } } }, { "name": "sub-item", "schemas": { "sub-item": { "type": "object", "required": [ "foo" ] } } } ] }, "tests": [ { "description": "valid items", "data": [ [ { "foo": null }, { "foo": null } ], [ { "foo": null }, { "foo": null } ], [ { "foo": null }, { "foo": null } ] ], "schema_id": "items_3_0", "action": "validate", "expect": { "success": false, "errors": [ { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "0/0/foo", "schema": "items_3_0" } }, { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "0/1/foo", "schema": "items_3_0" } }, { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "1/0/foo", "schema": "items_3_0" } }, { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "1/1/foo", "schema": "items_3_0" } }, { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "2/0/foo", "schema": "items_3_0" } }, { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "2/1/foo", "schema": "items_3_0" } } ] } }, { "description": "too many items", "data": [ [ { "foo": null }, { "foo": null } ], [ { "foo": null }, { "foo": null } ], [ { "foo": null }, { "foo": null } ], [ { "foo": null }, { "foo": null } ] ], "schema_id": "items_3_0", "action": "validate", "expect": { "success": false, "errors": [ { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "0/0/foo", "schema": "items_3_0" } }, { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "0/1/foo", "schema": "items_3_0" } }, { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "1/0/foo", "schema": "items_3_0" } }, { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "1/1/foo", "schema": "items_3_0" } }, { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "2/0/foo", "schema": "items_3_0" } }, { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "2/1/foo", "schema": "items_3_0" } }, { "code": "FALSE_SCHEMA", "details": { "path": "3", "schema": "items_3_0" } } ] } }, { "description": "too many sub-items", "data": [ [ { "foo": null }, { "foo": null }, { "foo": null } ], [ { "foo": null }, { "foo": null } ], [ { "foo": null }, { "foo": null } ] ], "schema_id": "items_3_0", "action": "validate", "expect": { "success": false, "errors": [ { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "0/0/foo", "schema": "items_3_0" } }, { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "0/1/foo", "schema": "items_3_0" } }, { "code": "FALSE_SCHEMA", "details": { "path": "0/2", "schema": "items_3_0" } }, { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "1/0/foo", "schema": "items_3_0" } }, { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "1/1/foo", "schema": "items_3_0" } }, { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "2/0/foo", "schema": "items_3_0" } }, { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "2/1/foo", "schema": "items_3_0" } } ] } }, { "description": "wrong item", "data": [ { "foo": null }, [ { "foo": null }, { "foo": null } ], [ { "foo": null }, { "foo": null } ] ], "schema_id": "items_3_0", "action": "validate", "expect": { "success": false, "errors": [ { "code": "INVALID_TYPE", "values": { "expected": "array" }, "details": { "path": "0", "schema": "items_3_0" } }, { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "0/foo", "schema": "items_3_0" } }, { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "1/0/foo", "schema": "items_3_0" } }, { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "1/1/foo", "schema": "items_3_0" } }, { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "2/0/foo", "schema": "items_3_0" } }, { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "2/1/foo", "schema": "items_3_0" } } ] } }, { "description": "wrong sub-item", "data": [ [ {}, { "foo": null } ], [ { "foo": null }, { "foo": null } ], [ { "foo": null }, { "foo": null } ] ], "schema_id": "items_3_0", "action": "validate", "expect": { "success": false, "errors": [ { "code": "REQUIRED_FIELD_MISSING", "values": { "field_name": "foo" }, "details": { "path": "0/0/foo", "schema": "items_3_0" } }, { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "0/1/foo", "schema": "items_3_0" } }, { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "1/0/foo", "schema": "items_3_0" } }, { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "1/1/foo", "schema": "items_3_0" } }, { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "2/0/foo", "schema": "items_3_0" } }, { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "2/1/foo", "schema": "items_3_0" } } ] } }, { "description": "fewer items is invalid", "data": [ [ { "foo": null } ], [ { "foo": null } ] ], "schema_id": "items_3_0", "action": "validate", "expect": { "success": false, "errors": [ { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "0/0/foo", "schema": "items_3_0" } }, { "code": "STRICT_PROPERTY_VIOLATION", "values": { "property_name": "foo" }, "details": { "path": "1/0/foo", "schema": "items_3_0" } } ] } } ] }, { "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": "prefixItems with no additional items allowed", "database": { "types": [ { "name": "items_5_0", "schemas": { "items_5_0": { "prefixItems": [ {}, {}, {} ], "items": false } } } ] }, "tests": [ { "description": "empty array", "data": [], "schema_id": "items_5_0", "action": "validate", "expect": { "success": true } }, { "description": "fewer number of items present (1)", "data": [ 1 ], "schema_id": "items_5_0", "action": "validate", "expect": { "success": true } }, { "description": "fewer number of items present (2)", "data": [ 1, 2 ], "schema_id": "items_5_0", "action": "validate", "expect": { "success": true } }, { "description": "equal number of items present", "data": [ 1, 2, 3 ], "schema_id": "items_5_0", "action": "validate", "expect": { "success": true } }, { "description": "additional items are not permitted", "data": [ 1, 2, 3, 4 ], "schema_id": "items_5_0", "action": "validate", "expect": { "success": false, "errors": [ { "code": "FALSE_SCHEMA", "details": { "path": "3", "schema": "items_5_0" } } ] } } ] }, { "description": "items does not look in applicators, valid case", "database": { "types": [ { "name": "items_6_0", "schemas": { "items_6_0": { "allOf": [ { "prefixItems": [ { "minimum": 3 } ] } ], "items": { "minimum": 5 } } } } ] }, "tests": [ { "description": "prefixItems in allOf does not constrain items, invalid case", "data": [ 3, 5 ], "schema_id": "items_6_0", "action": "validate", "expect": { "success": false, "errors": [ { "code": "MINIMUM_VIOLATED", "values": { "limit": "5", "value": "3" }, "details": { "path": "0", "schema": "items_6_0" } } ] } }, { "description": "prefixItems in allOf does not constrain items, valid case", "data": [ 5, 5 ], "schema_id": "items_6_0", "action": "validate", "expect": { "success": true } } ] }, { "description": "prefixItems validation adjusts the starting index for items", "database": { "types": [ { "name": "items_7_0", "schemas": { "items_7_0": { "prefixItems": [ { "type": "string" } ], "items": { "type": "integer" } } } } ] }, "tests": [ { "description": "valid items", "data": [ "x", 2, 3 ], "schema_id": "items_7_0", "action": "validate", "expect": { "success": true } }, { "description": "wrong type of second item", "data": [ "x", "y" ], "schema_id": "items_7_0", "action": "validate", "expect": { "success": false, "errors": [ { "code": "INVALID_TYPE", "values": { "expected": "integer" }, "details": { "path": "1", "schema": "items_7_0" } } ] } } ] }, { "description": "items with heterogeneous array", "database": { "types": [ { "name": "items_8_0", "schemas": { "items_8_0": { "prefixItems": [ {} ], "items": false } } } ] }, "tests": [ { "description": "heterogeneous invalid instance", "data": [ "foo", "bar", 37 ], "schema_id": "items_8_0", "action": "validate", "expect": { "success": false, "errors": [ { "code": "FALSE_SCHEMA", "details": { "path": "1", "schema": "items_8_0" } }, { "code": "FALSE_SCHEMA", "details": { "path": "2", "schema": "items_8_0" } } ] } }, { "description": "valid instance", "data": [ null ], "schema_id": "items_8_0", "action": "validate", "expect": { "success": true } } ] }, { "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: strict array", "database": { "types": [ { "name": "items_13_0", "schemas": { "items_13_0": { "type": "array", "extensible": false } } } ] }, "tests": [ { "description": "empty array is valid", "data": [], "schema_id": "items_13_0", "action": "validate", "expect": { "success": true } }, { "description": "array with items is invalid (strict)", "data": [ 1 ], "schema_id": "items_13_0", "action": "validate", "expect": { "success": false, "errors": [ { "code": "STRICT_ITEM_VIOLATION", "values": { "index": "0" }, "details": { "path": "0", "schema": "items_13_0" } } ] } } ] }, { "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" } } ] } } ] } ]