Skip to content

Boolean #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Mar 1, 2017
33 changes: 33 additions & 0 deletions tests/draft6/allOf.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,38 @@
"valid": false
}
]
},
{
"description": "allOf with boolean schemas, all true",
"schema": {"allOf": [true, true]},
"tests": [
{
"description": "any value is valid",
"data": "foo",
"valid": true
}
]
},
{
"description": "allOf with boolean schemas, some false",
"schema": {"allOf": [true, false]},
"tests": [
{
"description": "any value is invalid",
"data": "foo",
"valid": false
}
]
},
{
"description": "allOf with boolean schemas, all false",
"schema": {"allOf": [false, false]},
"tests": [
{
"description": "any value is invalid",
"data": "foo",
"valid": false
}
]
}
]
33 changes: 33 additions & 0 deletions tests/draft6/anyOf.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,38 @@
"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
}
]
}
]
104 changes: 104 additions & 0 deletions tests/draft6/boolean_schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
[
{
"description": "boolean schema 'true'",
"schema": true,
"tests": [
{
"description": "number is valid",
"data": 1,
"valid": true
},
{
"description": "string is valid",
"data": "foo",
"valid": true
},
{
"description": "boolean true is valid",
"data": true,
"valid": true
},
{
"description": "boolean false is valid",
"data": false,
"valid": true
},
{
"description": "null is valid",
"data": null,
"valid": true
},
{
"description": "object is valid",
"data": {"foo": "bar"},
"valid": true
},
{
"description": "empty object is valid",
"data": {},
"valid": true
},
{
"description": "array is valid",
"data": ["foo"],
"valid": true
},
{
"description": "empty array is valid",
"data": [],
"valid": true
}
]
},
{
"description": "boolean schema 'false'",
"schema": false,
"tests": [
{
"description": "number is invalid",
"data": 1,
"valid": false
},
{
"description": "string is invalid",
"data": "foo",
"valid": false
},
{
"description": "boolean true is invalid",
"data": true,
"valid": false
},
{
"description": "boolean false is invalid",
"data": false,
"valid": false
},
{
"description": "null is invalid",
"data": null,
"valid": false
},
{
"description": "object is invalid",
"data": {"foo": "bar"},
"valid": false
},
{
"description": "empty object is invalid",
"data": {},
"valid": false
},
{
"description": "array is invalid",
"data": ["foo"],
"valid": false
},
{
"description": "empty array is invalid",
"data": [],
"valid": false
}
]
}
]
32 changes: 32 additions & 0 deletions tests/draft6/contains.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,37 @@
"valid": false
}
]
},
{
"description": "contains keyword with boolean schema true",
"schema": {"contains": true},
"tests": [
{
"description": "any non-empty array is valid",
"data": ["foo"],
"valid": true
},
{
"description": "empty array is invalid",
"data": [],
"valid": false
}
]
},
{
"description": "contains keyword with boolean schema false",
"schema": {"contains": false},
"tests": [
{
"description": "any non-empty array is invalid",
"data": ["foo"],
"valid": false
},
{
"description": "empty array is invalid",
"data": [],
"valid": false
}
]
}
]
31 changes: 31 additions & 0 deletions tests/draft6/dependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,36 @@
"valid": false
}
]
},
{
"description": "dependencies with boolean subschemas",
"schema": {
"dependencies": {
"foo": true,
"bar": false
}
},
"tests": [
{
"description": "object with property having schema true is valid",
"data": {"foo": 1},
"valid": true
},
{
"description": "object with property having schema false is invalid",
"data": {"bar": 2},
"valid": false
},
{
"description": "object with both properties is invalid",
"data": {"foo": 1, "bar": 2},
"valid": false
},
{
"description": "empty object is valid",
"data": {},
"valid": true
}
]
}
]
55 changes: 55 additions & 0 deletions tests/draft6/items.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,60 @@
"valid": true
}
]
},
{
"description": "items with boolean schema (true)",
"schema": {"items": true},
"tests": [
{
"description": "any array is valid",
"data": [ 1, "foo", true ],
"valid": true
},
{
"description": "empty array is valid",
"data": [],
"valid": true
}
]
},
{
"description": "items with boolean schema (false)",
"schema": {"items": false},
"tests": [
{
"description": "any non-empty array is invalid",
"data": [ 1, "foo", true ],
"valid": false
},
{
"description": "empty array is valid",
"data": [],
"valid": true
}
]
},
{
"description": "items with boolean schemas",
"schema": {
"items": [true, false]
},
"tests": [
{
"description": "array with one item is valid",
"data": [ 1 ],
"valid": true
},
{
"description": "array with two items is invalid",
"data": [ 1, "foo" ],
"valid": false
},
{
"description": "empty array is valid",
"data": [],
"valid": true
}
]
}
]
23 changes: 22 additions & 1 deletion tests/draft6/not.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,27 @@
"valid": true
}
]
},
{
"description": "not with boolean schema true",
"schema": {"not": true},
"tests": [
{
"description": "any value is invalid",
"data": "foo",
"valid": false
}
]
},
{
"description": "not with boolean schema false",
"schema": {"not": false},
"tests": [
{
"description": "any value is valid",
"data": "foo",
"valid": true
}
]
}

]
44 changes: 44 additions & 0 deletions tests/draft6/oneOf.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,49 @@
"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
}
]
}
]
Loading