xref: /freebsd/contrib/libucl/tests/schema/not.json (revision e8d8bef961a50d4dc22501cde4fb9fb0be1b2532)
1[
2    {
3        "description": "not",
4        "schema": {
5            "not": {"type": "integer"}
6        },
7        "tests": [
8            {
9                "description": "allowed",
10                "data": "foo",
11                "valid": true
12            },
13            {
14                "description": "disallowed",
15                "data": 1,
16                "valid": false
17            }
18        ]
19    },
20    {
21        "description": "not multiple types",
22        "schema": {
23            "not": {"type": ["integer", "boolean"]}
24        },
25        "tests": [
26            {
27                "description": "valid",
28                "data": "foo",
29                "valid": true
30            },
31            {
32                "description": "mismatch",
33                "data": 1,
34                "valid": false
35            },
36            {
37                "description": "other mismatch",
38                "data": true,
39                "valid": false
40            }
41        ]
42    },
43    {
44        "description": "not more complex schema",
45        "schema": {
46            "not": {
47                "type": "object",
48                "properties": {
49                    "foo": {
50                        "type": "string"
51                    }
52                }
53             }
54        },
55        "tests": [
56            {
57                "description": "match",
58                "data": 1,
59                "valid": true
60            },
61            {
62                "description": "other match",
63                "data": {"foo": 1},
64                "valid": true
65            },
66            {
67                "description": "mismatch",
68                "data": {"foo": "bar"},
69                "valid": false
70            }
71        ]
72    },
73    {
74        "description": "forbidden property",
75        "schema": {
76            "properties": {
77                "foo": {
78                    "not": {}
79                }
80            }
81        },
82        "tests": [
83            {
84                "description": "property present",
85                "data": {"foo": 1, "bar": 2},
86                "valid": false
87            },
88            {
89                "description": "property absent",
90                "data": {"bar": 1, "baz": 2},
91                "valid": true
92            }
93        ]
94    }
95
96]
97