xref: /aosp_15_r20/external/json-schema-validator/src/test/suite/tests/draft2019-09/propertyNames.json (revision 78c4dd6aa35290980cdcd1623a7e337e8d021c7c)
1[
2    {
3        "description": "propertyNames validation",
4        "schema": {
5            "$schema": "https://json-schema.org/draft/2019-09/schema",
6            "propertyNames": {"maxLength": 3}
7        },
8        "tests": [
9            {
10                "description": "all property names valid",
11                "data": {
12                    "f": {},
13                    "foo": {}
14                },
15                "valid": true
16            },
17            {
18                "description": "some property names invalid",
19                "data": {
20                    "foo": {},
21                    "foobar": {}
22                },
23                "valid": false
24            },
25            {
26                "description": "object without properties is valid",
27                "data": {},
28                "valid": true
29            },
30            {
31                "description": "ignores arrays",
32                "data": [1, 2, 3, 4],
33                "valid": true
34            },
35            {
36                "description": "ignores strings",
37                "data": "foobar",
38                "valid": true
39            },
40            {
41                "description": "ignores other non-objects",
42                "data": 12,
43                "valid": true
44            }
45        ]
46    },
47    {
48        "description": "propertyNames validation with pattern",
49        "schema": {
50            "$schema": "https://json-schema.org/draft/2019-09/schema",
51            "propertyNames": { "pattern": "^a+$" }
52        },
53        "tests": [
54            {
55                "description": "matching property names valid",
56                "data": {
57                    "a": {},
58                    "aa": {},
59                    "aaa": {}
60                },
61                "valid": true
62            },
63            {
64                "description": "non-matching property name is invalid",
65                "data": {
66                    "aaA": {}
67                },
68                "valid": false
69            },
70            {
71                "description": "object without properties is valid",
72                "data": {},
73                "valid": true
74            }
75        ]
76    },
77    {
78        "description": "propertyNames with boolean schema true",
79        "schema": {
80            "$schema": "https://json-schema.org/draft/2019-09/schema",
81            "propertyNames": true
82        },
83        "tests": [
84            {
85                "description": "object with any properties is valid",
86                "data": {"foo": 1},
87                "valid": true
88            },
89            {
90                "description": "empty object is valid",
91                "data": {},
92                "valid": true
93            }
94        ]
95    },
96    {
97        "description": "propertyNames with boolean schema false",
98        "schema": {
99            "$schema": "https://json-schema.org/draft/2019-09/schema",
100            "propertyNames": false
101        },
102        "tests": [
103            {
104                "description": "object with any properties is invalid",
105                "data": {"foo": 1},
106                "valid": false
107            },
108            {
109                "description": "empty object is valid",
110                "data": {},
111                "valid": true
112            }
113        ]
114    }
115]
116