xref: /freebsd/contrib/libucl/tests/schema/enum.json (revision b9f654b163bce26de79705e77b872427c9f2afa1)
1[
2    {
3        "description": "simple enum validation",
4        "schema": {"enum": [1, 2, 3]},
5        "tests": [
6            {
7                "description": "one of the enum is valid",
8                "data": 1,
9                "valid": true
10            },
11            {
12                "description": "something else is invalid",
13                "data": 4,
14                "valid": false
15            }
16        ]
17    },
18    {
19        "description": "heterogeneous enum validation",
20        "schema": {"enum": [6, "foo", [], true, {"foo": 12}]},
21        "tests": [
22            {
23                "description": "one of the enum is valid",
24                "data": [],
25                "valid": true
26            },
27            {
28                "description": "something else is invalid",
29                "data": null,
30                "valid": false
31            },
32            {
33                "description": "objects are deep compared",
34                "data": {"foo": false},
35                "valid": false
36            }
37        ]
38    },
39    {
40        "description": "enums in properties",
41        "schema": {
42           "type":"object",
43		     "properties": {
44		        "foo": {"enum":["foo"]},
45		        "bar": {"enum":["bar"]}
46		     },
47		     "required": ["bar"]
48		  },
49        "tests": [
50            {
51                "description": "both properties are valid",
52                "data": {"foo":"foo", "bar":"bar"},
53                "valid": true
54            },
55            {
56                "description": "missing optional property is valid",
57                "data": {"bar":"bar"},
58                "valid": true
59            },
60            {
61                "description": "missing required property is invalid",
62                "data": {"foo":"foo"},
63                "valid": false
64            },
65            {
66                "description": "missing all properties is invalid",
67                "data": {},
68                "valid": false
69            }
70        ]
71    }
72]
73