xref: /freebsd/contrib/libucl/tests/schema/dependencies.json (revision 3c4ba5f55438f7afd4f4b0b56f88f2bb505fd6a6)
1[
2    {
3        "description": "dependencies",
4        "schema": {
5            "dependencies": {"bar": ["foo"]}
6        },
7        "tests": [
8            {
9                "description": "neither",
10                "data": {},
11                "valid": true
12            },
13            {
14                "description": "nondependant",
15                "data": {"foo": 1},
16                "valid": true
17            },
18            {
19                "description": "with dependency",
20                "data": {"foo": 1, "bar": 2},
21                "valid": true
22            },
23            {
24                "description": "missing dependency",
25                "data": {"bar": 2},
26                "valid": false
27            },
28            {
29                "description": "ignores non-objects",
30                "data": "foo",
31                "valid": true
32            }
33        ]
34    },
35    {
36        "description": "multiple dependencies",
37        "schema": {
38            "dependencies": {"quux": ["foo", "bar"]}
39        },
40        "tests": [
41            {
42                "description": "neither",
43                "data": {},
44                "valid": true
45            },
46            {
47                "description": "nondependants",
48                "data": {"foo": 1, "bar": 2},
49                "valid": true
50            },
51            {
52                "description": "with dependencies",
53                "data": {"foo": 1, "bar": 2, "quux": 3},
54                "valid": true
55            },
56            {
57                "description": "missing dependency",
58                "data": {"foo": 1, "quux": 2},
59                "valid": false
60            },
61            {
62                "description": "missing other dependency",
63                "data": {"bar": 1, "quux": 2},
64                "valid": false
65            },
66            {
67                "description": "missing both dependencies",
68                "data": {"quux": 1},
69                "valid": false
70            }
71        ]
72    },
73    {
74        "description": "multiple dependencies subschema",
75        "schema": {
76            "dependencies": {
77                "bar": {
78                    "properties": {
79                        "foo": {"type": "integer"},
80                        "bar": {"type": "integer"}
81                    }
82                }
83            }
84        },
85        "tests": [
86            {
87                "description": "valid",
88                "data": {"foo": 1, "bar": 2},
89                "valid": true
90            },
91            {
92                "description": "no dependency",
93                "data": {"foo": "quux"},
94                "valid": true
95            },
96            {
97                "description": "wrong type",
98                "data": {"foo": "quux", "bar": 2},
99                "valid": false
100            },
101            {
102                "description": "wrong type other",
103                "data": {"foo": 2, "bar": "quux"},
104                "valid": false
105            },
106            {
107                "description": "wrong type both",
108                "data": {"foo": "quux", "bar": "quux"},
109                "valid": false
110            }
111        ]
112    }
113]
114