[ { "description": "oneOf", "database": { "schemas": [ { "oneOf": [ { "type": "integer" }, { "minimum": 2 } ], "$id": "oneOf_0_0" } ] }, "tests": [ { "description": "first oneOf valid", "data": 1, "schema_id": "oneOf_0_0", "action": "validate", "expect": { "success": true } }, { "description": "second oneOf valid", "data": 2.5, "schema_id": "oneOf_0_0", "action": "validate", "expect": { "success": true } }, { "description": "both oneOf valid", "data": 3, "schema_id": "oneOf_0_0", "action": "validate", "expect": { "success": false } }, { "description": "neither oneOf valid", "data": 1.5, "schema_id": "oneOf_0_0", "action": "validate", "expect": { "success": false } } ] }, { "description": "oneOf with base schema", "database": { "schemas": [ { "type": "string", "oneOf": [ { "minLength": 2 }, { "maxLength": 4 } ], "$id": "oneOf_1_0" } ] }, "tests": [ { "description": "mismatch base schema", "data": 3, "schema_id": "oneOf_1_0", "action": "validate", "expect": { "success": false } }, { "description": "one oneOf valid", "data": "foobar", "schema_id": "oneOf_1_0", "action": "validate", "expect": { "success": true } }, { "description": "both oneOf valid", "data": "foo", "schema_id": "oneOf_1_0", "action": "validate", "expect": { "success": false } } ] }, { "description": "oneOf with boolean schemas, all true", "database": { "schemas": [ { "oneOf": [ true, true, true ], "$id": "oneOf_2_0" } ] }, "tests": [ { "description": "any value is invalid", "data": "foo", "schema_id": "oneOf_2_0", "action": "validate", "expect": { "success": false } } ] }, { "description": "oneOf with boolean schemas, one true", "database": { "schemas": [ { "oneOf": [ true, false, false ], "$id": "oneOf_3_0" } ] }, "tests": [ { "description": "any value is valid", "data": "foo", "schema_id": "oneOf_3_0", "action": "validate", "expect": { "success": true } } ] }, { "description": "oneOf with boolean schemas, more than one true", "database": { "schemas": [ { "oneOf": [ true, true, false ], "$id": "oneOf_4_0" } ] }, "tests": [ { "description": "any value is invalid", "data": "foo", "schema_id": "oneOf_4_0", "action": "validate", "expect": { "success": false } } ] }, { "description": "oneOf with boolean schemas, all false", "database": { "schemas": [ { "oneOf": [ false, false, false ], "$id": "oneOf_5_0" } ] }, "tests": [ { "description": "any value is invalid", "data": "foo", "schema_id": "oneOf_5_0", "action": "validate", "expect": { "success": false } } ] }, { "description": "oneOf complex types", "database": { "schemas": [ { "oneOf": [ { "properties": { "bar": { "type": "integer" } }, "required": [ "bar" ] }, { "properties": { "foo": { "type": "string" } }, "required": [ "foo" ] } ], "$id": "oneOf_6_0" } ] }, "tests": [ { "description": "first oneOf valid (complex)", "data": { "bar": 2 }, "schema_id": "oneOf_6_0", "action": "validate", "expect": { "success": true } }, { "description": "second oneOf valid (complex)", "data": { "foo": "baz" }, "schema_id": "oneOf_6_0", "action": "validate", "expect": { "success": true } }, { "description": "both oneOf valid (complex)", "data": { "foo": "baz", "bar": 2 }, "schema_id": "oneOf_6_0", "action": "validate", "expect": { "success": false } }, { "description": "neither oneOf valid (complex)", "data": { "foo": 2, "bar": "quux" }, "schema_id": "oneOf_6_0", "action": "validate", "expect": { "success": false } } ] }, { "description": "oneOf with empty schema", "database": { "schemas": [ { "oneOf": [ { "type": "number" }, {} ], "$id": "oneOf_7_0" } ] }, "tests": [ { "description": "one valid - valid", "data": "foo", "schema_id": "oneOf_7_0", "action": "validate", "expect": { "success": true } }, { "description": "both valid - invalid", "data": 123, "schema_id": "oneOf_7_0", "action": "validate", "expect": { "success": false } } ] }, { "description": "oneOf with required", "database": { "schemas": [ { "type": "object", "properties": { "foo": true, "bar": true, "baz": true }, "oneOf": [ { "required": [ "foo", "bar" ] }, { "required": [ "foo", "baz" ] } ], "$id": "oneOf_8_0" } ] }, "tests": [ { "description": "both invalid - invalid", "data": { "bar": 2 }, "schema_id": "oneOf_8_0", "action": "validate", "expect": { "success": false } }, { "description": "first valid - valid", "data": { "foo": 1, "bar": 2 }, "schema_id": "oneOf_8_0", "action": "validate", "expect": { "success": true } }, { "description": "second valid - valid", "data": { "foo": 1, "baz": 3 }, "schema_id": "oneOf_8_0", "action": "validate", "expect": { "success": true } }, { "description": "both valid - invalid", "data": { "foo": 1, "bar": 2, "baz": 3 }, "schema_id": "oneOf_8_0", "action": "validate", "expect": { "success": false } }, { "description": "extra property invalid (strict)", "data": { "foo": 1, "bar": 2, "extra": 3 }, "schema_id": "oneOf_8_0", "action": "validate", "expect": { "success": false } } ] }, { "description": "oneOf with required (extensible)", "database": { "schemas": [ { "type": "object", "extensible": true, "oneOf": [ { "required": [ "foo", "bar" ] }, { "required": [ "foo", "baz" ] } ], "$id": "oneOf_9_0" } ] }, "tests": [ { "description": "both invalid - invalid", "data": { "bar": 2 }, "schema_id": "oneOf_9_0", "action": "validate", "expect": { "success": false } }, { "description": "first valid - valid", "data": { "foo": 1, "bar": 2 }, "schema_id": "oneOf_9_0", "action": "validate", "expect": { "success": true } }, { "description": "second valid - valid", "data": { "foo": 1, "baz": 3 }, "schema_id": "oneOf_9_0", "action": "validate", "expect": { "success": true } }, { "description": "both valid - invalid", "data": { "foo": 1, "bar": 2, "baz": 3 }, "schema_id": "oneOf_9_0", "action": "validate", "expect": { "success": false } }, { "description": "extra properties are valid (extensible)", "data": { "foo": 1, "bar": 2, "extra": "value" }, "schema_id": "oneOf_9_0", "action": "validate", "expect": { "success": true } } ] }, { "description": "oneOf with missing optional property", "database": { "schemas": [ { "oneOf": [ { "properties": { "bar": true, "baz": true }, "required": [ "bar" ] }, { "properties": { "foo": true }, "required": [ "foo" ] } ], "$id": "oneOf_10_0" } ] }, "tests": [ { "description": "first oneOf valid", "data": { "bar": 8 }, "schema_id": "oneOf_10_0", "action": "validate", "expect": { "success": true } }, { "description": "second oneOf valid", "data": { "foo": "foo" }, "schema_id": "oneOf_10_0", "action": "validate", "expect": { "success": true } }, { "description": "both oneOf valid", "data": { "foo": "foo", "bar": 8 }, "schema_id": "oneOf_10_0", "action": "validate", "expect": { "success": false } }, { "description": "neither oneOf valid", "data": { "baz": "quux" }, "schema_id": "oneOf_10_0", "action": "validate", "expect": { "success": false } } ] }, { "description": "nested oneOf, to check validation semantics", "database": { "schemas": [ { "oneOf": [ { "oneOf": [ { "type": "null" } ] } ], "$id": "oneOf_11_0" } ] }, "tests": [ { "description": "null is valid", "data": null, "schema_id": "oneOf_11_0", "action": "validate", "expect": { "success": true } }, { "description": "anything non-null is invalid", "data": 123, "schema_id": "oneOf_11_0", "action": "validate", "expect": { "success": false } } ] }, { "description": "extensible: true allows extra properties in oneOf", "database": { "schemas": [ { "oneOf": [ { "properties": { "bar": { "type": "integer" } }, "required": [ "bar" ] }, { "properties": { "foo": { "type": "string" } }, "required": [ "foo" ] } ], "extensible": true, "$id": "oneOf_12_0" } ] }, "tests": [ { "description": "extra property is valid (matches first option)", "data": { "bar": 2, "extra": "prop" }, "schema_id": "oneOf_12_0", "action": "validate", "expect": { "success": true } } ] } ]