diff --git a/behaverse/validators/test.json b/behaverse/validators/test.json index 951a254..002e924 100644 --- a/behaverse/validators/test.json +++ b/behaverse/validators/test.json @@ -1,7 +1,9 @@ -{ - "base": {}, - "types": ["c13"], - "custom": { - "c2": "hello" +[ + { + "base": {}, + "types": ["AppStarted"], + "custom": { + "id": 2 + } } -} +] \ No newline at end of file diff --git a/behaverse/validators/test.json b/behaverse/validators/test.json index 951a254..002e924 100644 --- a/behaverse/validators/test.json +++ b/behaverse/validators/test.json @@ -1,7 +1,9 @@ -{ - "base": {}, - "types": ["c13"], - "custom": { - "c2": "hello" +[ + { + "base": {}, + "types": ["AppStarted"], + "custom": { + "id": 2 + } } -} +] \ No newline at end of file diff --git a/behaverse/validators/test.schema.json b/behaverse/validators/test.schema.json index 1d2f26b..332f680 100644 --- a/behaverse/validators/test.schema.json +++ b/behaverse/validators/test.schema.json @@ -1,53 +1,44 @@ { - "definitions": { - "c1": { - "type": "object", - "additionalProperties": false, - "properties": { - "c1": {"type": "object"} - } + "type": "array", + "items": { + "type": "object", + "properties": { + "base": { + "type": "object" + }, + "types": { + "type": "array", + "minItems": 1, + "items": { + "type": "string", + "enum": ["AppStarted", "AppActivated"] + } + } }, - "c2": { + "required": [ "base", "types", "custom" ], + "allOf": [ + { + "if": { "properties": { "types": { "contains": { "const": "AppStarted" }}}}, + "then": { "properties": { "custom": { "$ref": "#/definitions/AppStarted" }}} + }, + { + "if": { "properties": { "types": { "contains": { "const": "AppActivated" }}}}, + "then": { "properties": { "custom": { "$ref": "#/definitions/AppActivated" }}} + } + ] + }, + + "definitions": { + "AppActivated": { + "type": "object", + "properties": { + "id": { "type": "number" } + }, + "required": ["id"] + }, + "AppStarted": { "type": "string" } - }, - "type": "object", - "properties": { - "base": { - "type": "object" - }, - "types": { - "type": "array", - "minItems": 1, - "items": { - "type": "string", - "enum": ["c1", "c2", "c3"] - } - }, - "custom": { - "oneOf": [ - { - "if": { - "properties": { - "types": { - "type": "array", - "contains": {"type":"string", "enum": ["c1"]}}}}, - "then": { - "$ref": "#/definitions/c1" - } - }, - { - "if": { - "properties": { - "types": { - "type": "array", - "contains": {"type":"string", "enum": ["c2"]}}}}, - "then": { - "$ref": "#/definitions/c2" - } - } - ] - } - }, - "required": [ "base", "types", "custom" ] + } + } \ No newline at end of file diff --git a/behaverse/validators/test.json b/behaverse/validators/test.json index 951a254..002e924 100644 --- a/behaverse/validators/test.json +++ b/behaverse/validators/test.json @@ -1,7 +1,9 @@ -{ - "base": {}, - "types": ["c13"], - "custom": { - "c2": "hello" +[ + { + "base": {}, + "types": ["AppStarted"], + "custom": { + "id": 2 + } } -} +] \ No newline at end of file diff --git a/behaverse/validators/test.schema.json b/behaverse/validators/test.schema.json index 1d2f26b..332f680 100644 --- a/behaverse/validators/test.schema.json +++ b/behaverse/validators/test.schema.json @@ -1,53 +1,44 @@ { - "definitions": { - "c1": { - "type": "object", - "additionalProperties": false, - "properties": { - "c1": {"type": "object"} - } + "type": "array", + "items": { + "type": "object", + "properties": { + "base": { + "type": "object" + }, + "types": { + "type": "array", + "minItems": 1, + "items": { + "type": "string", + "enum": ["AppStarted", "AppActivated"] + } + } }, - "c2": { + "required": [ "base", "types", "custom" ], + "allOf": [ + { + "if": { "properties": { "types": { "contains": { "const": "AppStarted" }}}}, + "then": { "properties": { "custom": { "$ref": "#/definitions/AppStarted" }}} + }, + { + "if": { "properties": { "types": { "contains": { "const": "AppActivated" }}}}, + "then": { "properties": { "custom": { "$ref": "#/definitions/AppActivated" }}} + } + ] + }, + + "definitions": { + "AppActivated": { + "type": "object", + "properties": { + "id": { "type": "number" } + }, + "required": ["id"] + }, + "AppStarted": { "type": "string" } - }, - "type": "object", - "properties": { - "base": { - "type": "object" - }, - "types": { - "type": "array", - "minItems": 1, - "items": { - "type": "string", - "enum": ["c1", "c2", "c3"] - } - }, - "custom": { - "oneOf": [ - { - "if": { - "properties": { - "types": { - "type": "array", - "contains": {"type":"string", "enum": ["c1"]}}}}, - "then": { - "$ref": "#/definitions/c1" - } - }, - { - "if": { - "properties": { - "types": { - "type": "array", - "contains": {"type":"string", "enum": ["c2"]}}}}, - "then": { - "$ref": "#/definitions/c2" - } - } - ] - } - }, - "required": [ "base", "types", "custom" ] + } + } \ No newline at end of file diff --git a/behaverse/validators/test2.json b/behaverse/validators/test2.json new file mode 100644 index 0000000..833efe1 --- /dev/null +++ b/behaverse/validators/test2.json @@ -0,0 +1,5 @@ +{ + "street_address": "24 Sussex Drive", + "country": "Canada", + "postal_code": "xx1M 1M4" +} \ No newline at end of file diff --git a/behaverse/validators/test.json b/behaverse/validators/test.json index 951a254..002e924 100644 --- a/behaverse/validators/test.json +++ b/behaverse/validators/test.json @@ -1,7 +1,9 @@ -{ - "base": {}, - "types": ["c13"], - "custom": { - "c2": "hello" +[ + { + "base": {}, + "types": ["AppStarted"], + "custom": { + "id": 2 + } } -} +] \ No newline at end of file diff --git a/behaverse/validators/test.schema.json b/behaverse/validators/test.schema.json index 1d2f26b..332f680 100644 --- a/behaverse/validators/test.schema.json +++ b/behaverse/validators/test.schema.json @@ -1,53 +1,44 @@ { - "definitions": { - "c1": { - "type": "object", - "additionalProperties": false, - "properties": { - "c1": {"type": "object"} - } + "type": "array", + "items": { + "type": "object", + "properties": { + "base": { + "type": "object" + }, + "types": { + "type": "array", + "minItems": 1, + "items": { + "type": "string", + "enum": ["AppStarted", "AppActivated"] + } + } }, - "c2": { + "required": [ "base", "types", "custom" ], + "allOf": [ + { + "if": { "properties": { "types": { "contains": { "const": "AppStarted" }}}}, + "then": { "properties": { "custom": { "$ref": "#/definitions/AppStarted" }}} + }, + { + "if": { "properties": { "types": { "contains": { "const": "AppActivated" }}}}, + "then": { "properties": { "custom": { "$ref": "#/definitions/AppActivated" }}} + } + ] + }, + + "definitions": { + "AppActivated": { + "type": "object", + "properties": { + "id": { "type": "number" } + }, + "required": ["id"] + }, + "AppStarted": { "type": "string" } - }, - "type": "object", - "properties": { - "base": { - "type": "object" - }, - "types": { - "type": "array", - "minItems": 1, - "items": { - "type": "string", - "enum": ["c1", "c2", "c3"] - } - }, - "custom": { - "oneOf": [ - { - "if": { - "properties": { - "types": { - "type": "array", - "contains": {"type":"string", "enum": ["c1"]}}}}, - "then": { - "$ref": "#/definitions/c1" - } - }, - { - "if": { - "properties": { - "types": { - "type": "array", - "contains": {"type":"string", "enum": ["c2"]}}}}, - "then": { - "$ref": "#/definitions/c2" - } - } - ] - } - }, - "required": [ "base", "types", "custom" ] + } + } \ No newline at end of file diff --git a/behaverse/validators/test2.json b/behaverse/validators/test2.json new file mode 100644 index 0000000..833efe1 --- /dev/null +++ b/behaverse/validators/test2.json @@ -0,0 +1,5 @@ +{ + "street_address": "24 Sussex Drive", + "country": "Canada", + "postal_code": "xx1M 1M4" +} \ No newline at end of file diff --git a/behaverse/validators/test2.schema.json b/behaverse/validators/test2.schema.json new file mode 100644 index 0000000..8ae3a50 --- /dev/null +++ b/behaverse/validators/test2.schema.json @@ -0,0 +1,38 @@ +{ + "type": "object", + "properties": { + "street_address": { + "type": "string" + }, + "country": { + "type": "string", + "enum": ["United States of America", "Canada", "Netherlands"] + } + }, + "allOf": [ + { + "if": { + "properties": { "country": { "const": "United States of America" } } + }, + "then": { + "properties": { "postal_code": { "pattern": "[0-9]{5}(-[0-9]{4})?" } } + } + }, + { + "if": { + "properties": { "country": { "const": "Canada" } } + }, + "then": { + "properties": { "postal_code": { "pattern": "[A-Z][0-9][A-Z] [0-9][A-Z][0-9]" } } + } + }, + { + "if": { + "properties": { "country": { "const": "Netherlands" } } + }, + "then": { + "properties": { "postal_code": { "pattern": "[0-9]{4} [A-Z]{2}" } } + } + } + ] +} \ No newline at end of file diff --git a/behaverse/validators/test.json b/behaverse/validators/test.json index 951a254..002e924 100644 --- a/behaverse/validators/test.json +++ b/behaverse/validators/test.json @@ -1,7 +1,9 @@ -{ - "base": {}, - "types": ["c13"], - "custom": { - "c2": "hello" +[ + { + "base": {}, + "types": ["AppStarted"], + "custom": { + "id": 2 + } } -} +] \ No newline at end of file diff --git a/behaverse/validators/test.schema.json b/behaverse/validators/test.schema.json index 1d2f26b..332f680 100644 --- a/behaverse/validators/test.schema.json +++ b/behaverse/validators/test.schema.json @@ -1,53 +1,44 @@ { - "definitions": { - "c1": { - "type": "object", - "additionalProperties": false, - "properties": { - "c1": {"type": "object"} - } + "type": "array", + "items": { + "type": "object", + "properties": { + "base": { + "type": "object" + }, + "types": { + "type": "array", + "minItems": 1, + "items": { + "type": "string", + "enum": ["AppStarted", "AppActivated"] + } + } }, - "c2": { + "required": [ "base", "types", "custom" ], + "allOf": [ + { + "if": { "properties": { "types": { "contains": { "const": "AppStarted" }}}}, + "then": { "properties": { "custom": { "$ref": "#/definitions/AppStarted" }}} + }, + { + "if": { "properties": { "types": { "contains": { "const": "AppActivated" }}}}, + "then": { "properties": { "custom": { "$ref": "#/definitions/AppActivated" }}} + } + ] + }, + + "definitions": { + "AppActivated": { + "type": "object", + "properties": { + "id": { "type": "number" } + }, + "required": ["id"] + }, + "AppStarted": { "type": "string" } - }, - "type": "object", - "properties": { - "base": { - "type": "object" - }, - "types": { - "type": "array", - "minItems": 1, - "items": { - "type": "string", - "enum": ["c1", "c2", "c3"] - } - }, - "custom": { - "oneOf": [ - { - "if": { - "properties": { - "types": { - "type": "array", - "contains": {"type":"string", "enum": ["c1"]}}}}, - "then": { - "$ref": "#/definitions/c1" - } - }, - { - "if": { - "properties": { - "types": { - "type": "array", - "contains": {"type":"string", "enum": ["c2"]}}}}, - "then": { - "$ref": "#/definitions/c2" - } - } - ] - } - }, - "required": [ "base", "types", "custom" ] + } + } \ No newline at end of file diff --git a/behaverse/validators/test2.json b/behaverse/validators/test2.json new file mode 100644 index 0000000..833efe1 --- /dev/null +++ b/behaverse/validators/test2.json @@ -0,0 +1,5 @@ +{ + "street_address": "24 Sussex Drive", + "country": "Canada", + "postal_code": "xx1M 1M4" +} \ No newline at end of file diff --git a/behaverse/validators/test2.schema.json b/behaverse/validators/test2.schema.json new file mode 100644 index 0000000..8ae3a50 --- /dev/null +++ b/behaverse/validators/test2.schema.json @@ -0,0 +1,38 @@ +{ + "type": "object", + "properties": { + "street_address": { + "type": "string" + }, + "country": { + "type": "string", + "enum": ["United States of America", "Canada", "Netherlands"] + } + }, + "allOf": [ + { + "if": { + "properties": { "country": { "const": "United States of America" } } + }, + "then": { + "properties": { "postal_code": { "pattern": "[0-9]{5}(-[0-9]{4})?" } } + } + }, + { + "if": { + "properties": { "country": { "const": "Canada" } } + }, + "then": { + "properties": { "postal_code": { "pattern": "[A-Z][0-9][A-Z] [0-9][A-Z][0-9]" } } + } + }, + { + "if": { + "properties": { "country": { "const": "Netherlands" } } + }, + "then": { + "properties": { "postal_code": { "pattern": "[0-9]{4} [A-Z]{2}" } } + } + } + ] +} \ No newline at end of file diff --git a/behaverse/validators/test_array.schema.json b/behaverse/validators/test_array.schema.json new file mode 100644 index 0000000..690d021 --- /dev/null +++ b/behaverse/validators/test_array.schema.json @@ -0,0 +1,7 @@ +{ + "type": "array", + "contains": { + "type": "string", + "enum": ["c1"] + } +}