xref: /freebsd/contrib/libucl/tests/schema/properties.json (revision 7ef62cebc2f965b0f640263e179276928885e33d)
1[
2    {
3        "description": "object properties validation",
4        "schema": {
5            "properties": {
6                "foo": {"type": "integer"},
7                "bar": {"type": "string"}
8            }
9        },
10        "tests": [
11            {
12                "description": "both properties present and valid is valid",
13                "data": {"foo": 1, "bar": "baz"},
14                "valid": true
15            },
16            {
17                "description": "one property invalid is invalid",
18                "data": {"foo": 1, "bar": {}},
19                "valid": false
20            },
21            {
22                "description": "both properties invalid is invalid",
23                "data": {"foo": [], "bar": {}},
24                "valid": false
25            },
26            {
27                "description": "doesn't invalidate other properties",
28                "data": {"quux": []},
29                "valid": true
30            },
31            {
32                "description": "ignores non-objects",
33                "data": [],
34                "valid": true
35            }
36        ]
37    },
38    {
39        "description":
40            "properties, patternProperties, additionalProperties interaction",
41        "schema": {
42            "properties": {
43                "foo": {"type": "array", "maxItems": 3},
44                "bar": {"type": "array"}
45            },
46            "patternProperties": {"f.o": {"minItems": 2}},
47            "additionalProperties": {"type": "integer"}
48        },
49        "tests": [
50            {
51                "description": "property validates property",
52                "data": {"foo": [1, 2]},
53                "valid": true
54            },
55            {
56                "description": "property invalidates property",
57                "data": {"foo": [1, 2, 3, 4]},
58                "valid": false
59            },
60            {
61                "description": "patternProperty invalidates property",
62                "data": {"foo": []},
63                "valid": false
64            },
65            {
66                "description": "patternProperty validates nonproperty",
67                "data": {"fxo": [1, 2]},
68                "valid": true
69            },
70            {
71                "description": "patternProperty invalidates nonproperty",
72                "data": {"fxo": []},
73                "valid": false
74            },
75            {
76                "description": "additionalProperty ignores property",
77                "data": {"bar": []},
78                "valid": true
79            },
80            {
81                "description": "additionalProperty validates others",
82                "data": {"quux": 3},
83                "valid": true
84            },
85            {
86                "description": "additionalProperty invalidates others",
87                "data": {"quux": "foo"},
88                "valid": false
89            }
90        ]
91    }
92]
93