The home of JSON Schema validation right in your browser 🚧 Alpha 🚧 draft-7 only
Valid JSON:
xxxxxxxxxx{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "TestOptionalObject", "type": "object", "additionalProperties": false, "required": [ "test" ], "properties": { "test": { "$ref": "#/definitions/test" } }, "definitions": { "test": { "type": "object", "required": [ "key" ], "properties": { "key": { "type": "string", "enum": [ "comment", "offset", "standby", "status_unsure", "status_ok" ] } }, "allOf": [ { "if": { "properties": { "key": { "enum": [ "standby", "status_unsure", "status_ok" ] } } }, "then": { "properties": { "value": { "type": [ "object" ], "additionalProperties": false } } } }, { "if": { "properties": { "key": { "const": "comment" } } }, "then": { "properties": { "value": { "$ref": "#/definitions/commentValue" } } } }, { "if": { "properties": { "key": { "const": "offset" } } }, "then": { "properties": { "value": { "$ref": "#/definitions/offsetValue" } } } } ] }, "commentValue": { "type": "object", "additionalProperties": false, "required": [ "text" ], "properties": { "text": { "type": "string" } } }, "offsetValue": { "type": "object", "additionalProperties": false, "required": [ "seconds" ], "properties": { "seconds": { "type": "integer" } } } }}Valid JSON:
xxxxxxxxxx{ "test": { "key": "standby", "value": {} }}jsonschema.dev@relequestual Thanks to Sponsors: ![]()