...

Text file src/github.com/qri-io/jsonschema/testdata/draft2019-09/properties.json

Documentation: github.com/qri-io/jsonschema/testdata/draft2019-09

     1[
     2    {
     3        "description": "object properties validation",
     4        "schema": {
     5            "properties": {
     6                "foo": {"type": "integer"},
     7                "bar": {"type": "string"}
     8            }
     9        },
    10        "tests": [
    11            {
    12                "description": "both properties present and valid is valid",
    13                "data": {"foo": 1, "bar": "baz"},
    14                "valid": true
    15            },
    16            {
    17                "description": "one property invalid is invalid",
    18                "data": {"foo": 1, "bar": {}},
    19                "valid": false
    20            },
    21            {
    22                "description": "both properties invalid is invalid",
    23                "data": {"foo": [], "bar": {}},
    24                "valid": false
    25            },
    26            {
    27                "description": "doesn't invalidate other properties",
    28                "data": {"quux": []},
    29                "valid": true
    30            },
    31            {
    32                "description": "ignores arrays",
    33                "data": [],
    34                "valid": true
    35            },
    36            {
    37                "description": "ignores other non-objects",
    38                "data": 12,
    39                "valid": true
    40            }
    41        ]
    42    },
    43    {
    44        "description":
    45            "properties, patternProperties, additionalProperties interaction",
    46        "schema": {
    47            "properties": {
    48                "foo": {"type": "array", "maxItems": 3},
    49                "bar": {"type": "array"}
    50            },
    51            "patternProperties": {"f.o": {"minItems": 2}},
    52            "additionalProperties": {"type": "integer"}
    53        },
    54        "tests": [
    55            {
    56                "description": "property validates property",
    57                "data": {"foo": [1, 2]},
    58                "valid": true
    59            },
    60            {
    61                "description": "property invalidates property",
    62                "data": {"foo": [1, 2, 3, 4]},
    63                "valid": false
    64            },
    65            {
    66                "description": "patternProperty invalidates property",
    67                "data": {"foo": []},
    68                "valid": false
    69            },
    70            {
    71                "description": "patternProperty validates nonproperty",
    72                "data": {"fxo": [1, 2]},
    73                "valid": true
    74            },
    75            {
    76                "description": "patternProperty invalidates nonproperty",
    77                "data": {"fxo": []},
    78                "valid": false
    79            },
    80            {
    81                "description": "additionalProperty ignores property",
    82                "data": {"bar": []},
    83                "valid": true
    84            },
    85            {
    86                "description": "additionalProperty validates others",
    87                "data": {"quux": 3},
    88                "valid": true
    89            },
    90            {
    91                "description": "additionalProperty invalidates others",
    92                "data": {"quux": "foo"},
    93                "valid": false
    94            }
    95        ]
    96    },
    97    {
    98        "description": "properties with boolean schema",
    99        "schema": {
   100            "properties": {
   101                "foo": true,
   102                "bar": false
   103            }
   104        },
   105        "tests": [
   106            {
   107                "description": "no property present is valid",
   108                "data": {},
   109                "valid": true
   110            },
   111            {
   112                "description": "only 'true' property present is valid",
   113                "data": {"foo": 1},
   114                "valid": true
   115            },
   116            {
   117                "description": "only 'false' property present is invalid",
   118                "data": {"bar": 2},
   119                "valid": false
   120            },
   121            {
   122                "description": "both properties present is invalid",
   123                "data": {"foo": 1, "bar": 2},
   124                "valid": false
   125            }
   126        ]
   127    },
   128    {
   129        "description": "properties with escaped characters",
   130        "schema": {
   131            "properties": {
   132                "foo\nbar": {"type": "number"},
   133                "foo\"bar": {"type": "number"},
   134                "foo\\bar": {"type": "number"},
   135                "foo\rbar": {"type": "number"},
   136                "foo\tbar": {"type": "number"},
   137                "foo\fbar": {"type": "number"}
   138            }
   139        },
   140        "tests": [
   141            {
   142                "description": "object with all numbers is valid",
   143                "data": {
   144                    "foo\nbar": 1,
   145                    "foo\"bar": 1,
   146                    "foo\\bar": 1,
   147                    "foo\rbar": 1,
   148                    "foo\tbar": 1,
   149                    "foo\fbar": 1
   150                },
   151                "valid": true
   152            },
   153            {
   154                "description": "object with strings is invalid",
   155                "data": {
   156                    "foo\nbar": "1",
   157                    "foo\"bar": "1",
   158                    "foo\\bar": "1",
   159                    "foo\rbar": "1",
   160                    "foo\tbar": "1",
   161                    "foo\fbar": "1"
   162                },
   163                "valid": false
   164            }
   165        ]
   166    }
   167]

View as plain text