Skip to content

Commit 35041a3

Browse files
jgraettingerJulian
authored andcommitted
Tests for unevaluatedItems.
1 parent 8feb429 commit 35041a3

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
[
2+
{
3+
"description": "anyOf with false unevaluatedItems",
4+
"schema": {
5+
"$schema": "https://json-schema.org/draft/2019-09/schema",
6+
"unevaluatedItems": false,
7+
"anyOf": [
8+
{"items": {"type": "string"}},
9+
{"items": [true, true]}
10+
]
11+
},
12+
"tests": [
13+
{
14+
"description": "all strings is valid",
15+
"data": ["foo", "bar", "baz"],
16+
"valid": true
17+
},
18+
{
19+
"description": "one item is valid",
20+
"data": [1],
21+
"valid": true
22+
},
23+
{
24+
"description": "two items are valid",
25+
"data": [1, "two"],
26+
"valid": true
27+
},
28+
{
29+
"description": "three items are invalid",
30+
"data": [1, "two", "three"],
31+
"valid": false
32+
},
33+
{
34+
"description": "four strings are valid",
35+
"data": ["one", "two", "three", "four"],
36+
"valid": true
37+
}
38+
]
39+
},
40+
{
41+
"description": "complex unevaluated schema",
42+
"schema": {
43+
"$schema": "https://json-schema.org/draft/2019-09/schema",
44+
"unevaluatedItems": {
45+
"allOf": [{"minLength": 3}, {"type": "string"}]
46+
},
47+
"if": {"items": [{"type": "integer"}, {"type": "array"}]}
48+
},
49+
"tests": [
50+
{
51+
"description": "empty array",
52+
"data": [],
53+
"valid": true
54+
},
55+
{
56+
"description": "if passes with one item",
57+
"data": [1],
58+
"valid": true
59+
},
60+
{
61+
"description": "if passes with two items",
62+
"data": [1, [2, 3]],
63+
"valid": true
64+
},
65+
{
66+
"description": "if passes with third valid unevaluated item",
67+
"data": [1, [2, 3], "long-string"],
68+
"valid": true
69+
},
70+
{
71+
"description": "if passes with third invalid unevaluated item",
72+
"data": [1, [2, 3], "zz"],
73+
"valid": false
74+
},
75+
{
76+
"description": "if fails with all valid unevaluated items",
77+
"data": ["all", "long", "strings"],
78+
"valid": true
79+
},
80+
{
81+
"description": "if and unevaluated items fail",
82+
"data": ["a", "b", "c"],
83+
"valid": false
84+
}
85+
]
86+
}
87+
]

0 commit comments

Comments
 (0)