xref: /aosp_15_r20/external/json-schema-validator/src/test/suite/tests/draft-next/not.json (revision 78c4dd6aa35290980cdcd1623a7e337e8d021c7c)
1[
2    {
3        "description": "not",
4        "schema": {
5            "$schema": "https://json-schema.org/draft/next/schema",
6            "not": {"type": "integer"}
7        },
8        "tests": [
9            {
10                "description": "allowed",
11                "data": "foo",
12                "valid": true
13            },
14            {
15                "description": "disallowed",
16                "data": 1,
17                "valid": false
18            }
19        ]
20    },
21    {
22        "description": "not multiple types",
23        "schema": {
24            "$schema": "https://json-schema.org/draft/next/schema",
25            "not": {"type": ["integer", "boolean"]}
26        },
27        "tests": [
28            {
29                "description": "valid",
30                "data": "foo",
31                "valid": true
32            },
33            {
34                "description": "mismatch",
35                "data": 1,
36                "valid": false
37            },
38            {
39                "description": "other mismatch",
40                "data": true,
41                "valid": false
42            }
43        ]
44    },
45    {
46        "description": "not more complex schema",
47        "schema": {
48            "$schema": "https://json-schema.org/draft/next/schema",
49            "not": {
50                "type": "object",
51                "properties": {
52                    "foo": {
53                        "type": "string"
54                    }
55                }
56             }
57        },
58        "tests": [
59            {
60                "description": "match",
61                "data": 1,
62                "valid": true
63            },
64            {
65                "description": "other match",
66                "data": {"foo": 1},
67                "valid": true
68            },
69            {
70                "description": "mismatch",
71                "data": {"foo": "bar"},
72                "valid": false
73            }
74        ]
75    },
76    {
77        "description": "forbidden property",
78        "schema": {
79            "$schema": "https://json-schema.org/draft/next/schema",
80            "properties": {
81                "foo": {
82                    "not": {}
83                }
84            }
85        },
86        "tests": [
87            {
88                "description": "property present",
89                "data": {"foo": 1, "bar": 2},
90                "valid": false
91            },
92            {
93                "description": "property absent",
94                "data": {"bar": 1, "baz": 2},
95                "valid": true
96            }
97        ]
98    },
99    {
100        "description": "not with boolean schema true",
101        "schema": {
102            "$schema": "https://json-schema.org/draft/next/schema",
103            "not": true
104        },
105        "tests": [
106            {
107                "description": "any value is invalid",
108                "data": "foo",
109                "valid": false
110            }
111        ]
112    },
113    {
114        "description": "not with boolean schema false",
115        "schema": {
116            "$schema": "https://json-schema.org/draft/next/schema",
117            "not": false
118        },
119        "tests": [
120            {
121                "description": "any value is valid",
122                "data": "foo",
123                "valid": true
124            }
125        ]
126    },
127    {
128        "description": "collect annotations inside a 'not', even if collection is disabled",
129        "schema": {
130            "$schema": "https://json-schema.org/draft/next/schema",
131            "not": {
132                "$comment": "this subschema must still produce annotations internally, even though the 'not' will ultimately discard them",
133                "anyOf": [
134                    true,
135                    { "properties": { "foo": true } }
136                ],
137                "unevaluatedProperties": false
138            }
139        },
140        "tests": [
141            {
142                "description": "unevaluated property",
143                "data": { "bar": 1 },
144                "valid": true
145            },
146            {
147                "description": "annotations are still collected inside a 'not'",
148                "data": { "foo": 1 },
149                "valid": false
150            }
151        ]
152     }
153]
154