Skip to content

Commit f08b884

Browse files
committed
Cases go under additional and unevaluated Properties
1 parent 99864ff commit f08b884

File tree

3 files changed

+55
-59
lines changed

3 files changed

+55
-59
lines changed

tests/draft2020-12/additionalProperties.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,5 +158,29 @@
158158
"valid": true
159159
}
160160
]
161+
},
162+
{
163+
"description": "additionalProperties with propertyNames",
164+
"schema": {
165+
"$schema": "https://json-schema.org/draft/2020-12/schema",
166+
"propertyNames": {
167+
"maxLength": 5
168+
},
169+
"additionalProperties":{
170+
"type": "number"
171+
}
172+
},
173+
"tests": [
174+
{
175+
"description": "Valid against both keywords",
176+
"data": {"apple": 4},
177+
"valid": true
178+
},
179+
{
180+
"description": "Valid against propertyNames, but not unevaluatedProperties",
181+
"data": { "fig": 2, "pear": "available" },
182+
"valid": false
183+
}
184+
]
161185
}
162186
]

tests/draft2020-12/propertyNames.json

Lines changed: 1 addition & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[
22
{
33
"description": "propertyNames validation",
4-
"specification": [ { "core": "10.3.2.4" } ],
54
"schema": {
65
"$schema": "https://json-schema.org/draft/2020-12/schema",
76
"propertyNames": {"maxLength": 3}
@@ -47,7 +46,6 @@
4746
},
4847
{
4948
"description": "propertyNames with boolean schema true",
50-
"specification": [ { "core": "10.3.2.4", "quote": "The value of \"propertyNames\" MUST be a valid JSON Schema." } ],
5149
"schema": {
5250
"$schema": "https://json-schema.org/draft/2020-12/schema",
5351
"propertyNames": true
@@ -67,7 +65,6 @@
6765
},
6866
{
6967
"description": "propertyNames with boolean schema false",
70-
"specification": [ { "core": "10.3.2.4", "quote": "The value of \"propertyNames\" MUST be a valid JSON Schema." } ],
7168
"schema": {
7269
"$schema": "https://json-schema.org/draft/2020-12/schema",
7370
"propertyNames": false
@@ -84,60 +81,5 @@
8481
"valid": true
8582
}
8683
]
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-
]
14284
}
143-
]
85+
]

tests/draft2020-12/unevaluatedProperties.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,5 +1564,35 @@
15641564
"valid": false
15651565
}
15661566
]
1567+
},
1568+
{
1569+
"description": "unevaluatedProperties with propertyNames",
1570+
"schema": {
1571+
"$schema": "https://json-schema.org/draft/2020-12/schema",
1572+
"properties":{
1573+
"banana":{
1574+
"const": "available"
1575+
}
1576+
},
1577+
"propertyNames": {
1578+
"pattern": "^[a-b]"
1579+
},
1580+
"unevaluatedProperties":{
1581+
"type": "number"
1582+
}
1583+
1584+
},
1585+
"tests": [
1586+
{
1587+
"description": "Valid against all constraints",
1588+
"data": { "banana": "available", "apple": 4 },
1589+
"valid": true
1590+
},
1591+
{
1592+
"description": "valid against propertyNames, but not unevaluatedProperties",
1593+
"data": { "banana": "available", "apple": true },
1594+
"valid": false
1595+
}
1596+
]
15671597
}
15681598
]

0 commit comments

Comments
 (0)