summaryrefslogtreecommitdiff
path: root/json/tests/draft2019-09/maxContains.json
blob: ce4507c3262bf99dc0619ca199d37a9f5566f378 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
[
    {
        "description": "maxContains without contains is ignored",
        "schema": {
            "$schema": "https://json-schema.org/draft/2019-09/schema",
            "maxContains": 1
        },
        "tests": [
            {
                "description": "one item valid against lone maxContains",
                "data": [ 1 ],
                "valid": true
            },
            {
                "description": "two items still valid against lone maxContains",
                "data": [ 1, 2 ],
                "valid": true
            }
        ]
    },
    {
        "description": "maxContains with contains",
        "schema": {
            "$schema": "https://json-schema.org/draft/2019-09/schema",
            "contains": {"const": 1},
            "maxContains": 1
        },
        "tests": [
            {
                "description": "empty data",
                "data": [ ],
                "valid": false
            },
            {
                "description": "all elements match, valid maxContains",
                "data": [ 1 ],
                "valid": true
            },
            {
                "description": "all elements match, invalid maxContains",
                "data": [ 1, 1 ],
                "valid": false
            },
            {
                "description": "some elements match, valid maxContains",
                "data": [ 1, 2 ],
                "valid": true
            },
            {
                "description": "some elements match, invalid maxContains",
                "data": [ 1, 2, 1 ],
                "valid": false
            }
        ]
    },
    {
        "description": "maxContains with contains, value with a decimal",
        "schema": {
            "$schema": "https://json-schema.org/draft/2019-09/schema",
            "contains": {"const": 1},
            "maxContains": 1.0
        },
        "tests": [
            {
                "description": "one element matches, valid maxContains",
                "data": [ 1 ],
                "valid": true
            },
            {
                "description": "too many elements match, invalid maxContains",
                "data": [ 1, 1 ],
                "valid": false
            }
        ]
    },
    {
        "description": "minContains < maxContains",
        "schema": {
            "$schema": "https://json-schema.org/draft/2019-09/schema",
            "contains": {"const": 1},
            "minContains": 1,
            "maxContains": 3
        },
        "tests": [
            {
                "description": "actual < minContains < maxContains",
                "data": [ ],
                "valid": false
            },
            {
                "description": "minContains < actual < maxContains",
                "data": [ 1, 1 ],
                "valid": true
            },
            {
                "description": "minContains < maxContains < actual",
                "data": [ 1, 1, 1, 1 ],
                "valid": false
            }
        ]
    }
]