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
154 lines
3.9 KiB
JSON
154 lines
3.9 KiB
JSON
[
|
|
{
|
|
"description": "oneOf",
|
|
"schema": {
|
|
"oneOf": [
|
|
{
|
|
"type": "integer"
|
|
},
|
|
{
|
|
"minimum": 2
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "first oneOf valid",
|
|
"data": 1,
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "second oneOf valid",
|
|
"data": 2.5,
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "both oneOf valid",
|
|
"data": 3,
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "neither oneOf valid",
|
|
"data": 1.5,
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "oneOf with base schema",
|
|
"schema": {
|
|
"type": "string",
|
|
"oneOf" : [
|
|
{
|
|
"minLength": 2
|
|
},
|
|
{
|
|
"maxLength": 4
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "mismatch base schema",
|
|
"data": 3,
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "one oneOf valid",
|
|
"data": "foobar",
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "both oneOf valid",
|
|
"data": "foo",
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "oneOf with boolean schemas, all true",
|
|
"schema": {"oneOf": [true, true, true]},
|
|
"tests": [
|
|
{
|
|
"description": "any value is invalid",
|
|
"data": "foo",
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "oneOf with boolean schemas, one true",
|
|
"schema": {"oneOf": [true, false, false]},
|
|
"tests": [
|
|
{
|
|
"description": "any value is valid",
|
|
"data": "foo",
|
|
"valid": true
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "oneOf with boolean schemas, more than one true",
|
|
"schema": {"oneOf": [true, true, false]},
|
|
"tests": [
|
|
{
|
|
"description": "any value is invalid",
|
|
"data": "foo",
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "oneOf with boolean schemas, all false",
|
|
"schema": {"oneOf": [false, false, false]},
|
|
"tests": [
|
|
{
|
|
"description": "any value is invalid",
|
|
"data": "foo",
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "oneOf complex types",
|
|
"schema": {
|
|
"oneOf": [
|
|
{
|
|
"properties": {
|
|
"bar": {"type": "integer"}
|
|
},
|
|
"required": ["bar"]
|
|
},
|
|
{
|
|
"properties": {
|
|
"foo": {"type": "string"}
|
|
},
|
|
"required": ["foo"]
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "first oneOf valid (complex)",
|
|
"data": {"bar": 2},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "second oneOf valid (complex)",
|
|
"data": {"foo": "baz"},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "both oneOf valid (complex)",
|
|
"data": {"foo": "baz", "bar": 2},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "neither oneOf valid (complex)",
|
|
"data": {"foo": 2, "bar": "quux"},
|
|
"valid": false
|
|
}
|
|
]
|
|
}
|
|
]
|