xref: /freebsd/contrib/libucl/tests/schema/additionalItems.json (revision 0b3105a37d7adcadcb720112fed4dc4e8040be99)
1[
2    {
3        "description": "additionalItems as schema",
4        "schema": {
5            "items": [{}],
6            "additionalItems": {"type": "integer"}
7        },
8        "tests": [
9            {
10                "description": "additional items match schema",
11                "data": [ null, 2, 3, 4 ],
12                "valid": true
13            },
14            {
15                "description": "additional items do not match schema",
16                "data": [ null, 2, 3, "foo" ],
17                "valid": false
18            }
19        ]
20    },
21    {
22        "description": "items is schema, no additionalItems",
23        "schema": {
24            "items": {},
25            "additionalItems": false
26        },
27        "tests": [
28            {
29                "description": "all items match schema",
30                "data": [ 1, 2, 3, 4, 5 ],
31                "valid": true
32            }
33        ]
34    },
35    {
36        "description": "array of items with no additionalItems",
37        "schema": {
38            "items": [{}, {}, {}],
39            "additionalItems": false
40        },
41        "tests": [
42            {
43                "description": "no additional items present",
44                "data": [ 1, 2, 3 ],
45                "valid": true
46            },
47            {
48                "description": "additional items are not permitted",
49                "data": [ 1, 2, 3, 4 ],
50                "valid": false
51            }
52        ]
53    },
54    {
55        "description": "additionalItems as false without items",
56        "schema": {"additionalItems": false},
57        "tests": [
58            {
59                "description":
60                    "items defaults to empty schema so everything is valid",
61                "data": [ 1, 2, 3, 4, 5 ],
62                "valid": true
63            },
64            {
65                "description": "ignores non-arrays",
66                "data": {"foo" : "bar"},
67                "valid": true
68            }
69        ]
70    },
71    {
72        "description": "additionalItems are allowed by default",
73        "schema": {"items": [{"type": "integer"}]},
74        "tests": [
75            {
76                "description": "only the first item is validated",
77                "data": [1, "foo", false],
78                "valid": true
79            }
80        ]
81    }
82]
83