197 lines
4.2 KiB
JSON
197 lines
4.2 KiB
JSON
[
|
|
{
|
|
"description": "property is equal to another property",
|
|
"schema": {
|
|
"properties": {
|
|
"sameAs": { "const": { "$data": "1/thisOne" } },
|
|
"thisOne": {}
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "same value is valid",
|
|
"data": {
|
|
"sameAs": 5,
|
|
"thisOne": 5
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "same object is valid",
|
|
"data": {
|
|
"sameAs": { "foo": 1, "bar": 2 },
|
|
"thisOne": { "bar": 2, "foo": 1 }
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "another value is invalid",
|
|
"data": {
|
|
"sameAs": { "foo": 1 },
|
|
"thisOne": { "foo": 2 }
|
|
},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "another type is invalid",
|
|
"data": {
|
|
"sameAs": 5,
|
|
"thisOne": "5"
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "property values are equal to property names",
|
|
"schema": {
|
|
"additionalProperties": {
|
|
"const": { "$data": "0#" }
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "valid object",
|
|
"data": { "foo": "foo", "bar": "bar", "baz": "baz" },
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "invalid object",
|
|
"data": { "foo": "bar" },
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "items are equal to their indeces",
|
|
"schema": {
|
|
"items": {
|
|
"const": { "$data": "0#" }
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "valid array",
|
|
"data": [ 0, 1, 2, 3 ],
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "invalid array",
|
|
"data": [ 0, 2 ],
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "items in one array are equal to items in another (limited length)",
|
|
"schema": {
|
|
"properties": {
|
|
"arr": {
|
|
"items": [{},{},{}],
|
|
"additionalItems": false
|
|
},
|
|
"sameArr": {
|
|
"items": [
|
|
{ "const": { "$data": "2/arr/0" } },
|
|
{ "const": { "$data": "2/arr/1" } },
|
|
{ "const": { "$data": "2/arr/2" } }
|
|
],
|
|
"additionalItems": false
|
|
}
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "equal arrays are valid",
|
|
"data": {
|
|
"arr": [ 1, "abc", {"foo": "bar"} ],
|
|
"sameArr": [ 1, "abc", {"foo": "bar"} ]
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "different arrays are invalid",
|
|
"data": {
|
|
"arr": [ 1, "abc", {"foo": "bar"} ],
|
|
"sameArr": [ 1, "abc", {"foo": "foo"} ]
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "any data is equal to itself",
|
|
"schema": {
|
|
"const": { "$data": "0" }
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "number is equal to itself",
|
|
"data": 1,
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "string is equal to itself",
|
|
"data": "foo",
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "object is equal to itself",
|
|
"data": { "foo": "bar" },
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "array is equal to itself",
|
|
"data": [ 1, 2, 3 ],
|
|
"valid": true
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "property value is contained in array",
|
|
"schema": {
|
|
"properties": {
|
|
"name": { "type": "string" },
|
|
"list": {
|
|
"type": "array",
|
|
"contains": { "const": { "$data": "2/name" } }
|
|
}
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "1 item array containing property is valid",
|
|
"data": {
|
|
"name": "foo",
|
|
"list": [ "foo" ]
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "2 item array containing property is valid",
|
|
"data": {
|
|
"name": "foo",
|
|
"list": [ "foo", "bar" ]
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "array not containing property is invalid",
|
|
"data": {
|
|
"name": "foo",
|
|
"list": [ "bar" ]
|
|
},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "empty array is invalid",
|
|
"data": {
|
|
"name": "foo",
|
|
"list": []
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
}
|
|
]
|