[ { "description": "integer type matches integers", "database": { "schemas": [ { "type": "integer", "$id": "type_0_0" } ] }, "tests": [ { "description": "an integer is an integer", "data": 1, "schema_id": "type_0_0", "action": "validate", "expect": { "success": true } }, { "description": "a float with zero fractional part is an integer", "data": 1, "schema_id": "type_0_0", "action": "validate", "expect": { "success": true } }, { "description": "a float is not an integer", "data": 1.1, "schema_id": "type_0_0", "action": "validate", "expect": { "success": false } }, { "description": "a string is not an integer", "data": "foo", "schema_id": "type_0_0", "action": "validate", "expect": { "success": false } }, { "description": "a string is still not an integer, even if it looks like one", "data": "1", "schema_id": "type_0_0", "action": "validate", "expect": { "success": false } }, { "description": "an object is not an integer", "data": {}, "schema_id": "type_0_0", "action": "validate", "expect": { "success": false } }, { "description": "an array is not an integer", "data": [], "schema_id": "type_0_0", "action": "validate", "expect": { "success": false } }, { "description": "a boolean is not an integer", "data": true, "schema_id": "type_0_0", "action": "validate", "expect": { "success": false } }, { "description": "null is not an integer", "data": null, "schema_id": "type_0_0", "action": "validate", "expect": { "success": false } } ] }, { "description": "number type matches numbers", "database": { "schemas": [ { "type": "number", "$id": "type_1_0" } ] }, "tests": [ { "description": "an integer is a number", "data": 1, "schema_id": "type_1_0", "action": "validate", "expect": { "success": true } }, { "description": "a float with zero fractional part is a number (and an integer)", "data": 1, "schema_id": "type_1_0", "action": "validate", "expect": { "success": true } }, { "description": "a float is a number", "data": 1.1, "schema_id": "type_1_0", "action": "validate", "expect": { "success": true } }, { "description": "a string is not a number", "data": "foo", "schema_id": "type_1_0", "action": "validate", "expect": { "success": false } }, { "description": "a string is still not a number, even if it looks like one", "data": "1", "schema_id": "type_1_0", "action": "validate", "expect": { "success": false } }, { "description": "an object is not a number", "data": {}, "schema_id": "type_1_0", "action": "validate", "expect": { "success": false } }, { "description": "an array is not a number", "data": [], "schema_id": "type_1_0", "action": "validate", "expect": { "success": false } }, { "description": "a boolean is not a number", "data": true, "schema_id": "type_1_0", "action": "validate", "expect": { "success": false } }, { "description": "null is not a number", "data": null, "schema_id": "type_1_0", "action": "validate", "expect": { "success": false } } ] }, { "description": "string type matches strings", "database": { "schemas": [ { "type": "string", "$id": "type_2_0" } ] }, "tests": [ { "description": "1 is not a string", "data": 1, "schema_id": "type_2_0", "action": "validate", "expect": { "success": false } }, { "description": "a float is not a string", "data": 1.1, "schema_id": "type_2_0", "action": "validate", "expect": { "success": false } }, { "description": "a string is a string", "data": "foo", "schema_id": "type_2_0", "action": "validate", "expect": { "success": true } }, { "description": "a string is still a string, even if it looks like a number", "data": "1", "schema_id": "type_2_0", "action": "validate", "expect": { "success": true } }, { "description": "an empty string is still a string", "data": "", "schema_id": "type_2_0", "action": "validate", "expect": { "success": true } }, { "description": "an object is not a string", "data": {}, "schema_id": "type_2_0", "action": "validate", "expect": { "success": false } }, { "description": "an array is not a string", "data": [], "schema_id": "type_2_0", "action": "validate", "expect": { "success": false } }, { "description": "a boolean is not a string", "data": true, "schema_id": "type_2_0", "action": "validate", "expect": { "success": false } }, { "description": "null is not a string", "data": null, "schema_id": "type_2_0", "action": "validate", "expect": { "success": false } } ] }, { "description": "object type matches objects", "database": { "schemas": [ { "type": "object", "$id": "type_3_0" } ] }, "tests": [ { "description": "an integer is not an object", "data": 1, "schema_id": "type_3_0", "action": "validate", "expect": { "success": false } }, { "description": "a float is not an object", "data": 1.1, "schema_id": "type_3_0", "action": "validate", "expect": { "success": false } }, { "description": "a string is not an object", "data": "foo", "schema_id": "type_3_0", "action": "validate", "expect": { "success": false } }, { "description": "an object is an object", "data": {}, "schema_id": "type_3_0", "action": "validate", "expect": { "success": true } }, { "description": "an array is not an object", "data": [], "schema_id": "type_3_0", "action": "validate", "expect": { "success": false } }, { "description": "a boolean is not an object", "data": true, "schema_id": "type_3_0", "action": "validate", "expect": { "success": false } }, { "description": "null is not an object", "data": null, "schema_id": "type_3_0", "action": "validate", "expect": { "success": false } } ] }, { "description": "array type matches arrays", "database": { "schemas": [ { "type": "array", "$id": "type_4_0" } ] }, "tests": [ { "description": "an integer is not an array", "data": 1, "schema_id": "type_4_0", "action": "validate", "expect": { "success": false } }, { "description": "a float is not an array", "data": 1.1, "schema_id": "type_4_0", "action": "validate", "expect": { "success": false } }, { "description": "a string is not an array", "data": "foo", "schema_id": "type_4_0", "action": "validate", "expect": { "success": false } }, { "description": "an object is not an array", "data": {}, "schema_id": "type_4_0", "action": "validate", "expect": { "success": false } }, { "description": "an array is an array", "data": [], "schema_id": "type_4_0", "action": "validate", "expect": { "success": true } }, { "description": "a boolean is not an array", "data": true, "schema_id": "type_4_0", "action": "validate", "expect": { "success": false } }, { "description": "null is not an array", "data": null, "schema_id": "type_4_0", "action": "validate", "expect": { "success": false } } ] }, { "description": "boolean type matches booleans", "database": { "schemas": [ { "type": "boolean", "$id": "type_5_0" } ] }, "tests": [ { "description": "an integer is not a boolean", "data": 1, "schema_id": "type_5_0", "action": "validate", "expect": { "success": false } }, { "description": "zero is not a boolean", "data": 0, "schema_id": "type_5_0", "action": "validate", "expect": { "success": false } }, { "description": "a float is not a boolean", "data": 1.1, "schema_id": "type_5_0", "action": "validate", "expect": { "success": false } }, { "description": "a string is not a boolean", "data": "foo", "schema_id": "type_5_0", "action": "validate", "expect": { "success": false } }, { "description": "an empty string is a null", "data": "", "schema_id": "type_5_0", "action": "validate", "expect": { "success": true } }, { "description": "an object is not a boolean", "data": {}, "schema_id": "type_5_0", "action": "validate", "expect": { "success": false } }, { "description": "an array is not a boolean", "data": [], "schema_id": "type_5_0", "action": "validate", "expect": { "success": false } }, { "description": "true is a boolean", "data": true, "schema_id": "type_5_0", "action": "validate", "expect": { "success": true } }, { "description": "false is a boolean", "data": false, "schema_id": "type_5_0", "action": "validate", "expect": { "success": true } }, { "description": "null is not a boolean", "data": null, "schema_id": "type_5_0", "action": "validate", "expect": { "success": false } } ] }, { "description": "null type matches only the null object", "database": { "schemas": [ { "type": "null", "$id": "type_6_0" } ] }, "tests": [ { "description": "an integer is not null", "data": 1, "schema_id": "type_6_0", "action": "validate", "expect": { "success": false } }, { "description": "a float is not null", "data": 1.1, "schema_id": "type_6_0", "action": "validate", "expect": { "success": false } }, { "description": "zero is not null", "data": 0, "schema_id": "type_6_0", "action": "validate", "expect": { "success": false } }, { "description": "a string is not null", "data": "foo", "schema_id": "type_6_0", "action": "validate", "expect": { "success": false } }, { "description": "an empty string is null", "data": "", "schema_id": "type_6_0", "action": "validate", "expect": { "success": true } }, { "description": "an object is not null", "data": {}, "schema_id": "type_6_0", "action": "validate", "expect": { "success": false } }, { "description": "an array is not null", "data": [], "schema_id": "type_6_0", "action": "validate", "expect": { "success": false } }, { "description": "true is not null", "data": true, "schema_id": "type_6_0", "action": "validate", "expect": { "success": false } }, { "description": "false is not null", "data": false, "schema_id": "type_6_0", "action": "validate", "expect": { "success": false } }, { "description": "null is null", "data": null, "schema_id": "type_6_0", "action": "validate", "expect": { "success": true } } ] }, { "description": "multiple types can be specified in an array", "database": { "schemas": [ { "type": [ "integer", "string" ], "$id": "type_7_0" } ] }, "tests": [ { "description": "an integer is valid", "data": 1, "schema_id": "type_7_0", "action": "validate", "expect": { "success": true } }, { "description": "a string is valid", "data": "foo", "schema_id": "type_7_0", "action": "validate", "expect": { "success": true } }, { "description": "a float is invalid", "data": 1.1, "schema_id": "type_7_0", "action": "validate", "expect": { "success": false } }, { "description": "an object is invalid", "data": {}, "schema_id": "type_7_0", "action": "validate", "expect": { "success": false } }, { "description": "an array is invalid", "data": [], "schema_id": "type_7_0", "action": "validate", "expect": { "success": false } }, { "description": "a boolean is invalid", "data": true, "schema_id": "type_7_0", "action": "validate", "expect": { "success": false } }, { "description": "null is invalid", "data": null, "schema_id": "type_7_0", "action": "validate", "expect": { "success": false } } ] }, { "description": "type as array with one item", "database": { "schemas": [ { "type": [ "string" ], "$id": "type_8_0" } ] }, "tests": [ { "description": "string is valid", "data": "foo", "schema_id": "type_8_0", "action": "validate", "expect": { "success": true } }, { "description": "number is invalid", "data": 123, "schema_id": "type_8_0", "action": "validate", "expect": { "success": false } } ] }, { "description": "type: array or object", "database": { "schemas": [ { "type": [ "array", "object" ], "items": {}, "$id": "type_9_0" } ] }, "tests": [ { "description": "array is valid", "data": [ 1, 2, 3 ], "schema_id": "type_9_0", "action": "validate", "expect": { "success": true } }, { "description": "object is valid", "data": {}, "schema_id": "type_9_0", "action": "validate", "expect": { "success": true } }, { "description": "number is invalid", "data": 123, "schema_id": "type_9_0", "action": "validate", "expect": { "success": false } }, { "description": "string is invalid", "data": "foo", "schema_id": "type_9_0", "action": "validate", "expect": { "success": false } }, { "description": "null is invalid", "data": null, "schema_id": "type_9_0", "action": "validate", "expect": { "success": false } } ] }, { "description": "type: array, object or null", "database": { "schemas": [ { "type": [ "array", "object", "null" ], "items": {}, "$id": "type_10_0" } ] }, "tests": [ { "description": "array is valid", "data": [ 1, 2, 3 ], "schema_id": "type_10_0", "action": "validate", "expect": { "success": true } }, { "description": "object is valid", "data": {}, "schema_id": "type_10_0", "action": "validate", "expect": { "success": true } }, { "description": "null is valid", "data": null, "schema_id": "type_10_0", "action": "validate", "expect": { "success": true } }, { "description": "number is invalid", "data": 123, "schema_id": "type_10_0", "action": "validate", "expect": { "success": false } }, { "description": "string is invalid", "data": "foo", "schema_id": "type_10_0", "action": "validate", "expect": { "success": false } } ] }, { "description": "extensible: true allows extra properties", "database": { "schemas": [ { "type": "object", "extensible": true, "$id": "type_11_0" } ] }, "tests": [ { "description": "extra property is valid", "data": { "foo": 1 }, "schema_id": "type_11_0", "action": "validate", "expect": { "success": true } } ] } ]