Skip to content

Commit 99864ff

Browse files
committed
added tests for propertyNames with additionalProperties/unevaluatedProperties, also with specification property
1 parent 51fc69c commit 99864ff

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

tests/draft2020-12/propertyNames.json

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[
22
{
33
"description": "propertyNames validation",
4+
"specification": [ { "core": "10.3.2.4" } ],
45
"schema": {
56
"$schema": "https://json-schema.org/draft/2020-12/schema",
67
"propertyNames": {"maxLength": 3}
@@ -46,6 +47,7 @@
4647
},
4748
{
4849
"description": "propertyNames with boolean schema true",
50+
"specification": [ { "core": "10.3.2.4", "quote": "The value of \"propertyNames\" MUST be a valid JSON Schema." } ],
4951
"schema": {
5052
"$schema": "https://json-schema.org/draft/2020-12/schema",
5153
"propertyNames": true
@@ -65,6 +67,7 @@
6567
},
6668
{
6769
"description": "propertyNames with boolean schema false",
70+
"specification": [ { "core": "10.3.2.4", "quote": "The value of \"propertyNames\" MUST be a valid JSON Schema." } ],
6871
"schema": {
6972
"$schema": "https://json-schema.org/draft/2020-12/schema",
7073
"propertyNames": false
@@ -81,5 +84,60 @@
8184
"valid": true
8285
}
8386
]
87+
},
88+
{
89+
"description": "propertyNames with additionalProperties",
90+
"specification": [ { "core": "10.3.2.4" }, { "core": "10.3.2.3", "quote": "The validation of propertyNames remains unaffected by the presence or absence of additionalProperties. \"propertyNames\" are validated independently, regardless of other sibling keywords" } ],
91+
"schema": {
92+
"$schema": "https://json-schema.org/draft/2020-12/schema",
93+
"additionalProperties":{
94+
"type": "number"
95+
},
96+
"propertyNames": {
97+
"maxLength": 5
98+
}
99+
},
100+
"tests": [
101+
{
102+
"description": "property names with the given pattern are valid",
103+
"data": {"apple": 4},
104+
"valid": true
105+
},
106+
{
107+
"description": "property name is invalid",
108+
"data": { "watermelon": 6 },
109+
"valid": false
110+
}
111+
]
112+
},
113+
{
114+
"description": "propertyNames with unevaluatedProperties",
115+
"specification": [ { "core": "10.3.2.4" }, { "core":"11.3", "quote": "The validation of propertyNames remains unaffected by the presence or absence of unevaluatedProperties. \"propertyNames\" are validated independently, regardless of other sibling keywords" } ],
116+
"schema": {
117+
"$schema": "https://json-schema.org/draft/2020-12/schema",
118+
"properties":{
119+
"banana":{
120+
"const": "available"
121+
}
122+
},
123+
"unevaluatedProperties":{
124+
"type": "number"
125+
},
126+
"propertyNames": {
127+
"pattern": "^[a-b]"
128+
}
129+
},
130+
"tests": [
131+
{
132+
"description": "property names with the given pattern are valid",
133+
"data": { "banana": "available", "apple": 4 },
134+
"valid": true
135+
},
136+
{
137+
"description": "property name chickoo is invalid",
138+
"data": { "banana": "available", "chickoo": 10 },
139+
"valid": false
140+
}
141+
]
84142
}
85143
]

0 commit comments

Comments
 (0)