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