xref: /aosp_15_r20/external/json-schema-validator/src/test/suite/tests/draft2020-12/maxProperties.json (revision 78c4dd6aa35290980cdcd1623a7e337e8d021c7c)
1[
2    {
3        "description": "maxProperties validation",
4        "schema": {
5            "$schema": "https://json-schema.org/draft/2020-12/schema",
6            "maxProperties": 2
7        },
8        "tests": [
9            {
10                "description": "shorter is valid",
11                "data": {"foo": 1},
12                "valid": true
13            },
14            {
15                "description": "exact length is valid",
16                "data": {"foo": 1, "bar": 2},
17                "valid": true
18            },
19            {
20                "description": "too long is invalid",
21                "data": {"foo": 1, "bar": 2, "baz": 3},
22                "valid": false
23            },
24            {
25                "description": "ignores arrays",
26                "data": [1, 2, 3],
27                "valid": true
28            },
29            {
30                "description": "ignores strings",
31                "data": "foobar",
32                "valid": true
33            },
34            {
35                "description": "ignores other non-objects",
36                "data": 12,
37                "valid": true
38            }
39        ]
40    },
41    {
42        "description": "maxProperties validation with a decimal",
43        "schema": {
44            "$schema": "https://json-schema.org/draft/2020-12/schema",
45            "maxProperties": 2.0
46        },
47        "tests": [
48            {
49                "description": "shorter is valid",
50                "data": {"foo": 1},
51                "valid": true
52            },
53            {
54                "description": "too long is invalid",
55                "data": {"foo": 1, "bar": 2, "baz": 3},
56                "valid": false
57            }
58        ]
59    },
60    {
61        "description": "maxProperties = 0 means the object is empty",
62        "schema": {
63            "$schema": "https://json-schema.org/draft/2020-12/schema",
64            "maxProperties": 0
65        },
66        "tests": [
67            {
68                "description": "no properties is valid",
69                "data": {},
70                "valid": true
71            },
72            {
73                "description": "one property is invalid",
74                "data": { "foo": 1 },
75                "valid": false
76            }
77        ]
78    }
79]
80