json-schema-validator/test/JSON-Schema-Test-Suite/tests/draft7/anyOf.json
Patrick Boettcher 7beb40bc61 Complete rewrite of the validator - aiming a 2.0-release
Schema a now "parsed" into C++-validator-objects in a first
step and then validation takes place with these objects.

Errors are now handled via a user-provided error-handler
allowing the user to collect all errors at once or bail out
when a certain threshold is reached. Fixes #36 and #8.

One (sub-)schema can now be referenced with different URIs. Fixes #9

JSON schema draft 7 is now supported. Fixes #35
2018-12-27 16:59:19 +01:00

143 lines
3.6 KiB
JSON

[
{
"description": "anyOf",
"schema": {
"anyOf": [
{
"type": "integer"
},
{
"minimum": 2
}
]
},
"tests": [
{
"description": "first anyOf valid",
"data": 1,
"valid": true
},
{
"description": "second anyOf valid",
"data": 2.5,
"valid": true
},
{
"description": "both anyOf valid",
"data": 3,
"valid": true
},
{
"description": "neither anyOf valid",
"data": 1.5,
"valid": false
}
]
},
{
"description": "anyOf with base schema",
"schema": {
"type": "string",
"anyOf" : [
{
"maxLength": 2
},
{
"minLength": 4
}
]
},
"tests": [
{
"description": "mismatch base schema",
"data": 3,
"valid": false
},
{
"description": "one anyOf valid",
"data": "foobar",
"valid": true
},
{
"description": "both anyOf invalid",
"data": "foo",
"valid": false
}
]
},
{
"description": "anyOf with boolean schemas, all true",
"schema": {"anyOf": [true, true]},
"tests": [
{
"description": "any value is valid",
"data": "foo",
"valid": true
}
]
},
{
"description": "anyOf with boolean schemas, some true",
"schema": {"anyOf": [true, false]},
"tests": [
{
"description": "any value is valid",
"data": "foo",
"valid": true
}
]
},
{
"description": "anyOf with boolean schemas, all false",
"schema": {"anyOf": [false, false]},
"tests": [
{
"description": "any value is invalid",
"data": "foo",
"valid": false
}
]
},
{
"description": "anyOf complex types",
"schema": {
"anyOf": [
{
"properties": {
"bar": {"type": "integer"}
},
"required": ["bar"]
},
{
"properties": {
"foo": {"type": "string"}
},
"required": ["foo"]
}
]
},
"tests": [
{
"description": "first anyOf valid (complex)",
"data": {"bar": 2},
"valid": true
},
{
"description": "second anyOf valid (complex)",
"data": {"foo": "baz"},
"valid": true
},
{
"description": "both anyOf valid (complex)",
"data": {"foo": "baz", "bar": 2},
"valid": true
},
{
"description": "neither anyOf valid (complex)",
"data": {"foo": 2, "bar": "quux"},
"valid": false
}
]
}
]