[ { "description": "simple enum validation", "schema": {"enum": [1, 2, 3]}, "tests": [ { "description": "one of the enum is valid", "data": 1, "valid": true }, { "description": "something else is invalid", "data": 4, "valid": false } ] }, { "description": "heterogeneous enum validation", "schema": {"enum": [6, "foo", [], true, {"foo": 12}]}, "tests": [ { "description": "one of the enum is valid", "data": [], "valid": true }, { "description": "something else is invalid", "data": null, "valid": false }, { "description": "objects are deep compared", "data": {"foo": false}, "valid": false } ] }, { "description": "enums in properties", "schema": { "type":"object", "properties": { "foo": {"enum":["foo"]}, "bar": {"enum":["bar"]} }, "required": ["bar"] }, "tests": [ { "description": "both properties are valid", "data": {"foo":"foo", "bar":"bar"}, "valid": true }, { "description": "wrong foo value", "data": {"foo":"foot", "bar":"bar"}, "valid": false }, { "description": "wrong bar value", "data": {"foo":"foo", "bar":"bart"}, "valid": false }, { "description": "missing optional property is valid", "data": {"bar":"bar"}, "valid": true }, { "description": "missing required property is invalid", "data": {"foo":"foo"}, "valid": false }, { "description": "missing all properties is invalid", "data": {}, "valid": false } ] }, { "description": "enum with escaped characters", "schema": { "enum": ["foo\nbar", "foo\rbar"] }, "tests": [ { "description": "member 1 is valid", "data": "foo\nbar", "valid": true }, { "description": "member 2 is valid", "data": "foo\rbar", "valid": true }, { "description": "another string is invalid", "data": "abc", "valid": false } ] }, { "description": "enum with false does not match 0", "schema": {"enum": [false]}, "tests": [ { "description": "false is valid", "data": false, "valid": true }, { "description": "integer zero is invalid", "data": 0, "valid": false }, { "description": "float zero is invalid", "data": 0.0, "valid": false } ] }, { "description": "enum with true does not match 1", "schema": {"enum": [true]}, "tests": [ { "description": "true is valid", "data": true, "valid": true }, { "description": "integer one is invalid", "data": 1, "valid": false }, { "description": "float one is invalid", "data": 1.0, "valid": false } ] }, { "description": "enum with 0 does not match false", "schema": {"enum": [0]}, "tests": [ { "description": "false is invalid", "data": false, "valid": false }, { "description": "integer zero is valid", "data": 0, "valid": true }, { "description": "float zero is valid", "data": 0.0, "valid": true } ] }, { "description": "enum with 1 does not match true", "schema": {"enum": [1]}, "tests": [ { "description": "true is invalid", "data": true, "valid": false }, { "description": "integer one is valid", "data": 1, "valid": true }, { "description": "float one is valid", "data": 1.0, "valid": true } ] } ]