ajv/spec/tests/rules/oneOf.json

93 lines
2.3 KiB
JSON

[
{
"description": "oneOf with one of schemas empty",
"schema": {
"oneOf": [
{ "type": "number" },
{}
]
},
"tests": [
{
"description": "string is valid",
"data": "foo",
"valid": true
},
{
"description": "number is invalid",
"data": 123,
"valid": false
}
]
},
{
"description": "oneOf with required",
"schema": {
"type": "object",
"oneOf": [
{ "required": ["foo", "bar"] },
{ "required": ["foo", "baz"] }
]
},
"tests": [
{
"description": "object with foo and bar is valid",
"data": {"foo": 1, "bar": 2},
"valid": true
},
{
"description": "object with foo and baz is valid",
"data": {"foo": 1, "baz": 3},
"valid": true
},
{
"description": "object with foo, bar and baz is invalid",
"data": {"foo": 1, "bar": 2, "baz" : 3},
"valid": false
}
]
},
{
"description": "oneOf with required with 20+ properties",
"schema": {
"type": "object",
"oneOf": [
{ "required": ["foo", "bar"] },
{
"required": [
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
"k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
"u", "v", "w", "x", "y", "z"
]
}
]
},
"tests": [
{
"description": "object with foo and bar is valid",
"data": {"foo": 1, "bar": 2},
"valid": true
},
{
"description": "object with a, b, c, ... properties is valid",
"data": {
"a": 0, "b": 0, "c": 0, "d": 0, "e": 0, "f": 0, "g": 0, "h": 0, "i": 0, "j": 0,
"k": 0, "l": 0, "m": 0, "n": 0, "o": 0, "p": 0, "q": 0, "r": 0, "s": 0, "t": 0,
"u": 0, "v": 0, "w": 0, "x": 0, "y": 0, "z": 0
},
"valid": true
},
{
"description": "object with foo, bar and a, b, c ... is invalid",
"data": {
"a": 0, "b": 0, "c": 0, "d": 0, "e": 0, "f": 0, "g": 0, "h": 0, "i": 0, "j": 0,
"k": 0, "l": 0, "m": 0, "n": 0, "o": 0, "p": 0, "q": 0, "r": 0, "s": 0, "t": 0,
"u": 0, "v": 0, "w": 0, "x": 0, "y": 0, "z": 0,
"foo": 1, "bar": 2
},
"valid": false
}
]
}
]