xref: /aosp_15_r20/external/json-schema-validator/src/test/suite/tests/draft4/not.json (revision 78c4dd6aa35290980cdcd1623a7e337e8d021c7c)
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        "description": "forbid everything with empty schema",
97        "schema": { "not": {} },
98        "tests": [
99            {
100                "description": "number is invalid",
101                "data": 1,
102                "valid": false
103            },
104            {
105                "description": "string is invalid",
106                "data": "foo",
107                "valid": false
108            },
109            {
110                "description": "boolean true is invalid",
111                "data": true,
112                "valid": false
113            },
114            {
115                "description": "boolean false is invalid",
116                "data": false,
117                "valid": false
118            },
119            {
120                "description": "null is invalid",
121                "data": null,
122                "valid": false
123            },
124            {
125                "description": "object is invalid",
126                "data": {"foo": "bar"},
127                "valid": false
128            },
129            {
130                "description": "empty object is invalid",
131                "data": {},
132                "valid": false
133            },
134            {
135                "description": "array is invalid",
136                "data": ["foo"],
137                "valid": false
138            },
139            {
140                "description": "empty array is invalid",
141                "data": [],
142                "valid": false
143            }
144        ]
145    },
146    {
147        "description": "double negation",
148        "schema": { "not": { "not": {} } },
149        "tests": [
150            {
151                "description": "any value is valid",
152                "data": "foo",
153                "valid": true
154            }
155        ]
156    }
157]
158