Skip to content

Commit 544f7c3

Browse files
authored
Merge pull request #712 from otto-ifak/main
Add tests for enum validation with arrays of boolean values
2 parents 589a085 + 9dad3eb commit 544f7c3

File tree

6 files changed

+540
-0
lines changed

6 files changed

+540
-0
lines changed

tests/draft-next/enum.json

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,30 @@
168168
}
169169
]
170170
},
171+
{
172+
"description": "enum with [false] does not match [0]",
173+
"schema": {
174+
"$schema": "https://json-schema.org/draft/next/schema",
175+
"enum": [[false]]
176+
},
177+
"tests": [
178+
{
179+
"description": "[false] is valid",
180+
"data": [false],
181+
"valid": true
182+
},
183+
{
184+
"description": "[0] is invalid",
185+
"data": [0],
186+
"valid": false
187+
},
188+
{
189+
"description": "[0.0] is invalid",
190+
"data": [0.0],
191+
"valid": false
192+
}
193+
]
194+
},
171195
{
172196
"description": "enum with true does not match 1",
173197
"schema": {
@@ -192,6 +216,30 @@
192216
}
193217
]
194218
},
219+
{
220+
"description": "enum with [true] does not match [1]",
221+
"schema": {
222+
"$schema": "https://json-schema.org/draft/next/schema",
223+
"enum": [[true]]
224+
},
225+
"tests": [
226+
{
227+
"description": "[true] is valid",
228+
"data": [true],
229+
"valid": true
230+
},
231+
{
232+
"description": "[1] is invalid",
233+
"data": [1],
234+
"valid": false
235+
},
236+
{
237+
"description": "[1.0] is invalid",
238+
"data": [1.0],
239+
"valid": false
240+
}
241+
]
242+
},
195243
{
196244
"description": "enum with 0 does not match false",
197245
"schema": {
@@ -216,6 +264,30 @@
216264
}
217265
]
218266
},
267+
{
268+
"description": "enum with [0] does not match [false]",
269+
"schema": {
270+
"$schema": "https://json-schema.org/draft/next/schema",
271+
"enum": [[0]]
272+
},
273+
"tests": [
274+
{
275+
"description": "[false] is invalid",
276+
"data": [false],
277+
"valid": false
278+
},
279+
{
280+
"description": "[0] is valid",
281+
"data": [0],
282+
"valid": true
283+
},
284+
{
285+
"description": "[0.0] is valid",
286+
"data": [0.0],
287+
"valid": true
288+
}
289+
]
290+
},
219291
{
220292
"description": "enum with 1 does not match true",
221293
"schema": {
@@ -240,6 +312,30 @@
240312
}
241313
]
242314
},
315+
{
316+
"description": "enum with [1] does not match [true]",
317+
"schema": {
318+
"$schema": "https://json-schema.org/draft/next/schema",
319+
"enum": [[1]]
320+
},
321+
"tests": [
322+
{
323+
"description": "[true] is invalid",
324+
"data": [true],
325+
"valid": false
326+
},
327+
{
328+
"description": "[1] is valid",
329+
"data": [1],
330+
"valid": true
331+
},
332+
{
333+
"description": "[1.0] is valid",
334+
"data": [1.0],
335+
"valid": true
336+
}
337+
]
338+
},
243339
{
244340
"description": "nul characters in strings",
245341
"schema": {

tests/draft2019-09/enum.json

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,30 @@
168168
}
169169
]
170170
},
171+
{
172+
"description": "enum with [false] does not match [0]",
173+
"schema": {
174+
"$schema": "https://json-schema.org/draft/2019-09/schema",
175+
"enum": [[false]]
176+
},
177+
"tests": [
178+
{
179+
"description": "[false] is valid",
180+
"data": [false],
181+
"valid": true
182+
},
183+
{
184+
"description": "[0] is invalid",
185+
"data": [0],
186+
"valid": false
187+
},
188+
{
189+
"description": "[0.0] is invalid",
190+
"data": [0.0],
191+
"valid": false
192+
}
193+
]
194+
},
171195
{
172196
"description": "enum with true does not match 1",
173197
"schema": {
@@ -192,6 +216,30 @@
192216
}
193217
]
194218
},
219+
{
220+
"description": "enum with [true] does not match [1]",
221+
"schema": {
222+
"$schema": "https://json-schema.org/draft/2019-09/schema",
223+
"enum": [[true]]
224+
},
225+
"tests": [
226+
{
227+
"description": "[true] is valid",
228+
"data": [true],
229+
"valid": true
230+
},
231+
{
232+
"description": "[1] is invalid",
233+
"data": [1],
234+
"valid": false
235+
},
236+
{
237+
"description": "[1.0] is invalid",
238+
"data": [1.0],
239+
"valid": false
240+
}
241+
]
242+
},
195243
{
196244
"description": "enum with 0 does not match false",
197245
"schema": {
@@ -216,6 +264,30 @@
216264
}
217265
]
218266
},
267+
{
268+
"description": "enum with [0] does not match [false]",
269+
"schema": {
270+
"$schema": "https://json-schema.org/draft/2019-09/schema",
271+
"enum": [[0]]
272+
},
273+
"tests": [
274+
{
275+
"description": "[false] is invalid",
276+
"data": [false],
277+
"valid": false
278+
},
279+
{
280+
"description": "[0] is valid",
281+
"data": [0],
282+
"valid": true
283+
},
284+
{
285+
"description": "[0.0] is valid",
286+
"data": [0.0],
287+
"valid": true
288+
}
289+
]
290+
},
219291
{
220292
"description": "enum with 1 does not match true",
221293
"schema": {
@@ -240,6 +312,30 @@
240312
}
241313
]
242314
},
315+
{
316+
"description": "enum with [1] does not match [true]",
317+
"schema": {
318+
"$schema": "https://json-schema.org/draft/2019-09/schema",
319+
"enum": [[1]]
320+
},
321+
"tests": [
322+
{
323+
"description": "[true] is invalid",
324+
"data": [true],
325+
"valid": false
326+
},
327+
{
328+
"description": "[1] is valid",
329+
"data": [1],
330+
"valid": true
331+
},
332+
{
333+
"description": "[1.0] is valid",
334+
"data": [1.0],
335+
"valid": true
336+
}
337+
]
338+
},
243339
{
244340
"description": "nul characters in strings",
245341
"schema": {

tests/draft2020-12/enum.json

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,30 @@
168168
}
169169
]
170170
},
171+
{
172+
"description": "enum with [false] does not match [0]",
173+
"schema": {
174+
"$schema": "https://json-schema.org/draft/2020-12/schema",
175+
"enum": [[false]]
176+
},
177+
"tests": [
178+
{
179+
"description": "[false] is valid",
180+
"data": [false],
181+
"valid": true
182+
},
183+
{
184+
"description": "[0] is invalid",
185+
"data": [0],
186+
"valid": false
187+
},
188+
{
189+
"description": "[0.0] is invalid",
190+
"data": [0.0],
191+
"valid": false
192+
}
193+
]
194+
},
171195
{
172196
"description": "enum with true does not match 1",
173197
"schema": {
@@ -192,6 +216,30 @@
192216
}
193217
]
194218
},
219+
{
220+
"description": "enum with [true] does not match [1]",
221+
"schema": {
222+
"$schema": "https://json-schema.org/draft/2020-12/schema",
223+
"enum": [[true]]
224+
},
225+
"tests": [
226+
{
227+
"description": "[true] is valid",
228+
"data": [true],
229+
"valid": true
230+
},
231+
{
232+
"description": "[1] is invalid",
233+
"data": [1],
234+
"valid": false
235+
},
236+
{
237+
"description": "[1.0] is invalid",
238+
"data": [1.0],
239+
"valid": false
240+
}
241+
]
242+
},
195243
{
196244
"description": "enum with 0 does not match false",
197245
"schema": {
@@ -216,6 +264,30 @@
216264
}
217265
]
218266
},
267+
{
268+
"description": "enum with [0] does not match [false]",
269+
"schema": {
270+
"$schema": "https://json-schema.org/draft/2020-12/schema",
271+
"enum": [[0]]
272+
},
273+
"tests": [
274+
{
275+
"description": "[false] is invalid",
276+
"data": [false],
277+
"valid": false
278+
},
279+
{
280+
"description": "[0] is valid",
281+
"data": [0],
282+
"valid": true
283+
},
284+
{
285+
"description": "[0.0] is valid",
286+
"data": [0.0],
287+
"valid": true
288+
}
289+
]
290+
},
219291
{
220292
"description": "enum with 1 does not match true",
221293
"schema": {
@@ -240,6 +312,30 @@
240312
}
241313
]
242314
},
315+
{
316+
"description": "enum with [1] does not match [true]",
317+
"schema": {
318+
"$schema": "https://json-schema.org/draft/2020-12/schema",
319+
"enum": [[1]]
320+
},
321+
"tests": [
322+
{
323+
"description": "[true] is invalid",
324+
"data": [true],
325+
"valid": false
326+
},
327+
{
328+
"description": "[1] is valid",
329+
"data": [1],
330+
"valid": true
331+
},
332+
{
333+
"description": "[1.0] is valid",
334+
"data": [1.0],
335+
"valid": true
336+
}
337+
]
338+
},
243339
{
244340
"description": "nul characters in strings",
245341
"schema": {

0 commit comments

Comments
 (0)