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