Skip to content

Commit 0f341dc

Browse files
authored
Merge pull request #429 from notEthan/decimal_minItems
test validation of keywords which expect integers when their value has a decimal
2 parents 547330d + 32ec630 commit 0f341dc

36 files changed

+594
-0
lines changed

tests/draft-next/maxContains.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,25 @@
8686
}
8787
]
8888
},
89+
{
90+
"description": "maxContains with contains, value with a decimal",
91+
"schema": {
92+
"contains": {"const": 1},
93+
"maxContains": 1.0
94+
},
95+
"tests": [
96+
{
97+
"description": "one element matches, valid maxContains",
98+
"data": [ 1 ],
99+
"valid": true
100+
},
101+
{
102+
"description": "too many elements match, invalid maxContains",
103+
"data": [ 1, 1 ],
104+
"valid": false
105+
}
106+
]
107+
},
89108
{
90109
"description": "minContains < maxContains",
91110
"schema": {

tests/draft-next/maxItems.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,21 @@
2424
"valid": true
2525
}
2626
]
27+
},
28+
{
29+
"description": "maxItems validation with a decimal",
30+
"schema": {"maxItems": 2.0},
31+
"tests": [
32+
{
33+
"description": "shorter is valid",
34+
"data": [1],
35+
"valid": true
36+
},
37+
{
38+
"description": "too long is invalid",
39+
"data": [1, 2, 3],
40+
"valid": false
41+
}
42+
]
2743
}
2844
]

tests/draft-next/maxLength.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,21 @@
2929
"valid": true
3030
}
3131
]
32+
},
33+
{
34+
"description": "maxLength validation with a decimal",
35+
"schema": {"maxLength": 2.0},
36+
"tests": [
37+
{
38+
"description": "shorter is valid",
39+
"data": "f",
40+
"valid": true
41+
},
42+
{
43+
"description": "too long is invalid",
44+
"data": "foo",
45+
"valid": false
46+
}
47+
]
3248
}
3349
]

tests/draft-next/maxProperties.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,22 @@
3535
}
3636
]
3737
},
38+
{
39+
"description": "maxProperties validation with a decimal",
40+
"schema": {"maxProperties": 2.0},
41+
"tests": [
42+
{
43+
"description": "shorter is valid",
44+
"data": {"foo": 1},
45+
"valid": true
46+
},
47+
{
48+
"description": "too long is invalid",
49+
"data": {"foo": 1, "bar": 2, "baz": 3},
50+
"valid": false
51+
}
52+
]
53+
},
3854
{
3955
"description": "maxProperties = 0 means the object is empty",
4056
"schema": { "maxProperties": 0 },

tests/draft-next/minContains.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,25 @@
9090
}
9191
]
9292
},
93+
{
94+
"description": "minContains=2 with contains with a decimal value",
95+
"schema": {
96+
"contains": {"const": 1},
97+
"minContains": 2.0
98+
},
99+
"tests": [
100+
{
101+
"description": "one element matches, invalid minContains",
102+
"data": [ 1 ],
103+
"valid": false
104+
},
105+
{
106+
"description": "both elements match, valid minContains",
107+
"data": [ 1, 1 ],
108+
"valid": true
109+
}
110+
]
111+
},
93112
{
94113
"description": "maxContains = minContains",
95114
"schema": {

tests/draft-next/minItems.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,21 @@
2424
"valid": true
2525
}
2626
]
27+
},
28+
{
29+
"description": "minItems validation with a decimal",
30+
"schema": {"minItems": 1.0},
31+
"tests": [
32+
{
33+
"description": "longer is valid",
34+
"data": [1, 2],
35+
"valid": true
36+
},
37+
{
38+
"description": "too short is invalid",
39+
"data": [],
40+
"valid": false
41+
}
42+
]
2743
}
2844
]

tests/draft-next/minLength.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,21 @@
2929
"valid": false
3030
}
3131
]
32+
},
33+
{
34+
"description": "minLength validation with a decimal",
35+
"schema": {"minLength": 2.0},
36+
"tests": [
37+
{
38+
"description": "longer is valid",
39+
"data": "foo",
40+
"valid": true
41+
},
42+
{
43+
"description": "too short is invalid",
44+
"data": "f",
45+
"valid": false
46+
}
47+
]
3248
}
3349
]

tests/draft-next/minProperties.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,21 @@
3434
"valid": true
3535
}
3636
]
37+
},
38+
{
39+
"description": "minProperties validation with a decimal",
40+
"schema": {"minProperties": 1.0},
41+
"tests": [
42+
{
43+
"description": "longer is valid",
44+
"data": {"foo": 1, "bar": 2},
45+
"valid": true
46+
},
47+
{
48+
"description": "too short is invalid",
49+
"data": {},
50+
"valid": false
51+
}
52+
]
3753
}
3854
]

tests/draft2019-09/maxContains.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,25 @@
5151
}
5252
]
5353
},
54+
{
55+
"description": "maxContains with contains, value with a decimal",
56+
"schema": {
57+
"contains": {"const": 1},
58+
"maxContains": 1.0
59+
},
60+
"tests": [
61+
{
62+
"description": "one element matches, valid maxContains",
63+
"data": [ 1 ],
64+
"valid": true
65+
},
66+
{
67+
"description": "too many elements match, invalid maxContains",
68+
"data": [ 1, 1 ],
69+
"valid": false
70+
}
71+
]
72+
},
5473
{
5574
"description": "minContains < maxContains",
5675
"schema": {

tests/draft2019-09/maxItems.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,21 @@
2424
"valid": true
2525
}
2626
]
27+
},
28+
{
29+
"description": "maxItems validation with a decimal",
30+
"schema": {"maxItems": 2.0},
31+
"tests": [
32+
{
33+
"description": "shorter is valid",
34+
"data": [1],
35+
"valid": true
36+
},
37+
{
38+
"description": "too long is invalid",
39+
"data": [1, 2, 3],
40+
"valid": false
41+
}
42+
]
2743
}
2844
]

tests/draft2019-09/maxLength.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,21 @@
2929
"valid": true
3030
}
3131
]
32+
},
33+
{
34+
"description": "maxLength validation with a decimal",
35+
"schema": {"maxLength": 2.0},
36+
"tests": [
37+
{
38+
"description": "shorter is valid",
39+
"data": "f",
40+
"valid": true
41+
},
42+
{
43+
"description": "too long is invalid",
44+
"data": "foo",
45+
"valid": false
46+
}
47+
]
3248
}
3349
]

tests/draft2019-09/maxProperties.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,22 @@
3535
}
3636
]
3737
},
38+
{
39+
"description": "maxProperties validation with a decimal",
40+
"schema": {"maxProperties": 2.0},
41+
"tests": [
42+
{
43+
"description": "shorter is valid",
44+
"data": {"foo": 1},
45+
"valid": true
46+
},
47+
{
48+
"description": "too long is invalid",
49+
"data": {"foo": 1, "bar": 2, "baz": 3},
50+
"valid": false
51+
}
52+
]
53+
},
3854
{
3955
"description": "maxProperties = 0 means the object is empty",
4056
"schema": { "maxProperties": 0 },

tests/draft2019-09/minContains.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,25 @@
9090
}
9191
]
9292
},
93+
{
94+
"description": "minContains=2 with contains with a decimal value",
95+
"schema": {
96+
"contains": {"const": 1},
97+
"minContains": 2.0
98+
},
99+
"tests": [
100+
{
101+
"description": "one element matches, invalid minContains",
102+
"data": [ 1 ],
103+
"valid": false
104+
},
105+
{
106+
"description": "both elements match, valid minContains",
107+
"data": [ 1, 1 ],
108+
"valid": true
109+
}
110+
]
111+
},
93112
{
94113
"description": "maxContains = minContains",
95114
"schema": {

tests/draft2019-09/minItems.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,21 @@
2424
"valid": true
2525
}
2626
]
27+
},
28+
{
29+
"description": "minItems validation with a decimal",
30+
"schema": {"minItems": 1.0},
31+
"tests": [
32+
{
33+
"description": "longer is valid",
34+
"data": [1, 2],
35+
"valid": true
36+
},
37+
{
38+
"description": "too short is invalid",
39+
"data": [],
40+
"valid": false
41+
}
42+
]
2743
}
2844
]

tests/draft2019-09/minLength.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,21 @@
2929
"valid": false
3030
}
3131
]
32+
},
33+
{
34+
"description": "minLength validation with a decimal",
35+
"schema": {"minLength": 2.0},
36+
"tests": [
37+
{
38+
"description": "longer is valid",
39+
"data": "foo",
40+
"valid": true
41+
},
42+
{
43+
"description": "too short is invalid",
44+
"data": "f",
45+
"valid": false
46+
}
47+
]
3248
}
3349
]

tests/draft2019-09/minProperties.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,21 @@
3434
"valid": true
3535
}
3636
]
37+
},
38+
{
39+
"description": "minProperties validation with a decimal",
40+
"schema": {"minProperties": 1.0},
41+
"tests": [
42+
{
43+
"description": "longer is valid",
44+
"data": {"foo": 1, "bar": 2},
45+
"valid": true
46+
},
47+
{
48+
"description": "too short is invalid",
49+
"data": {},
50+
"valid": false
51+
}
52+
]
3753
}
3854
]

tests/draft2020-12/maxContains.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,25 @@
5151
}
5252
]
5353
},
54+
{
55+
"description": "maxContains with contains, value with a decimal",
56+
"schema": {
57+
"contains": {"const": 1},
58+
"maxContains": 1.0
59+
},
60+
"tests": [
61+
{
62+
"description": "one element matches, valid maxContains",
63+
"data": [ 1 ],
64+
"valid": true
65+
},
66+
{
67+
"description": "too many elements match, invalid maxContains",
68+
"data": [ 1, 1 ],
69+
"valid": false
70+
}
71+
]
72+
},
5473
{
5574
"description": "minContains < maxContains",
5675
"schema": {

0 commit comments

Comments
 (0)