Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions tests/draft2019-09/propertyNames.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,58 @@
"valid": true
}
]
},
{
"description": "propertyNames with const",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"propertyNames": {"const": "foo"}
},
"tests": [
{
"description": "object with property foo is valid",
"data": {"foo": 1},
"valid": true
},
{
"description": "object with any other property is invalid",
"data": {"bar": 1},
"valid": false
},
{
"description": "empty object is valid",
"data": {},
"valid": true
}
]
},
{
"description": "propertyNames with enum",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"propertyNames": {"enum": ["foo", "bar"]}
},
"tests": [
{
"description": "object with property foo is valid",
"data": {"foo": 1},
"valid": true
},
{
"description": "object with property foo and bar is valid",
"data": {"foo": 1, "bar": 1},
"valid": true
},
{
"description": "object with any other property is invalid",
"data": {"baz": 1},
"valid": false
},
{
"description": "empty object is valid",
"data": {},
"valid": true
}
]
}
]
83 changes: 83 additions & 0 deletions tests/draft2020-12/propertyNames.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,36 @@
}
]
},
{
"description": "propertyNames validation with pattern",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"propertyNames": { "pattern": "^a+$" }
},
"tests": [
{
"description": "matching property names valid",
"data": {
"a": {},
"aa": {},
"aaa": {}
},
"valid": true
},
{
"description": "non-matching property name is invalid",
"data": {
"aaA": {}
},
"valid": false
},
{
"description": "object without properties is valid",
"data": {},
"valid": true
}
]
},
{
"description": "propertyNames with boolean schema true",
"schema": {
Expand Down Expand Up @@ -81,5 +111,58 @@
"valid": true
}
]
},
{
"description": "propertyNames with const",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"propertyNames": {"const": "foo"}
},
"tests": [
{
"description": "object with property foo is valid",
"data": {"foo": 1},
"valid": true
},
{
"description": "object with any other property is invalid",
"data": {"bar": 1},
"valid": false
},
{
"description": "empty object is valid",
"data": {},
"valid": true
}
]
},
{
"description": "propertyNames with enum",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"propertyNames": {"enum": ["foo", "bar"]}
},
"tests": [
{
"description": "object with property foo is valid",
"data": {"foo": 1},
"valid": true
},
{
"description": "object with property foo and bar is valid",
"data": {"foo": 1, "bar": 1},
"valid": true
},
{
"description": "object with any other property is invalid",
"data": {"baz": 1},
"valid": false
},
{
"description": "empty object is valid",
"data": {},
"valid": true
}
]
}
]
47 changes: 47 additions & 0 deletions tests/draft6/propertyNames.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,52 @@
"valid": true
}
]
},
{
"description": "propertyNames with const",
"schema": {"propertyNames": {"const": "foo"}},
"tests": [
{
"description": "object with property foo is valid",
"data": {"foo": 1},
"valid": true
},
{
"description": "object with any other property is invalid",
"data": {"bar": 1},
"valid": false
},
{
"description": "empty object is valid",
"data": {},
"valid": true
}
]
},
{
"description": "propertyNames with enum",
"schema": {"propertyNames": {"enum": ["foo", "bar"]}},
"tests": [
{
"description": "object with property foo is valid",
"data": {"foo": 1},
"valid": true
},
{
"description": "object with property foo and bar is valid",
"data": {"foo": 1, "bar": 1},
"valid": true
},
{
"description": "object with any other property is invalid",
"data": {"baz": 1},
"valid": false
},
{
"description": "empty object is valid",
"data": {},
"valid": true
}
]
}
]
47 changes: 47 additions & 0 deletions tests/draft7/propertyNames.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,52 @@
"valid": true
}
]
},
{
"description": "propertyNames with const",
"schema": {"propertyNames": {"const": "foo"}},
"tests": [
{
"description": "object with property foo is valid",
"data": {"foo": 1},
"valid": true
},
{
"description": "object with any other property is invalid",
"data": {"bar": 1},
"valid": false
},
{
"description": "empty object is valid",
"data": {},
"valid": true
}
]
},
{
"description": "propertyNames with enum",
"schema": {"propertyNames": {"enum": ["foo", "bar"]}},
"tests": [
{
"description": "object with property foo is valid",
"data": {"foo": 1},
"valid": true
},
{
"description": "object with property foo and bar is valid",
"data": {"foo": 1, "bar": 1},
"valid": true
},
{
"description": "object with any other property is invalid",
"data": {"baz": 1},
"valid": false
},
{
"description": "empty object is valid",
"data": {},
"valid": true
}
]
}
]
Loading