xref: /freebsd/contrib/libucl/tests/schema/additionalProperties.json (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1[
2    {
3        "description":
4            "additionalProperties being false does not allow other properties",
5        "schema": {
6            "properties": {"foo": {}, "bar": {}},
7            "patternProperties": { "^v": {} },
8            "additionalProperties": false
9        },
10        "tests": [
11            {
12                "description": "no additional properties is valid",
13                "data": {"foo": 1},
14                "valid": true
15            },
16            {
17                "description": "an additional property is invalid",
18                "data": {"foo" : 1, "bar" : 2, "quux" : "boom"},
19                "valid": false
20            },
21            {
22                "description": "ignores non-objects",
23                "data": [1, 2, 3],
24                "valid": true
25            },
26            {
27                "description": "patternProperties are not additional properties",
28                "data": {"foo":1, "vroom": 2},
29                "valid": true
30            }
31        ]
32    },
33    {
34        "description":
35            "additionalProperties allows a schema which should validate",
36        "schema": {
37            "properties": {"foo": {}, "bar": {}},
38            "additionalProperties": {"type": "boolean"}
39        },
40        "tests": [
41            {
42                "description": "no additional properties is valid",
43                "data": {"foo": 1},
44                "valid": true
45            },
46            {
47                "description": "an additional valid property is valid",
48                "data": {"foo" : 1, "bar" : 2, "quux" : true},
49                "valid": true
50            },
51            {
52                "description": "an additional invalid property is invalid",
53                "data": {"foo" : 1, "bar" : 2, "quux" : 12},
54                "valid": false
55            }
56        ]
57    },
58    {
59        "description": "additionalProperties are allowed by default",
60        "schema": {"properties": {"foo": {}, "bar": {}}},
61        "tests": [
62            {
63                "description": "additional properties are allowed",
64                "data": {"foo": 1, "bar": 2, "quux": true},
65                "valid": true
66            }
67        ]
68    }
69]
70