...

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

Documentation: github.com/qri-io/jsonschema/testdata/draft4

     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 escaped characters",
    99        "schema": {
   100            "properties": {
   101                "foo\nbar": {"type": "number"},
   102                "foo\"bar": {"type": "number"},
   103                "foo\\bar": {"type": "number"},
   104                "foo\rbar": {"type": "number"},
   105                "foo\tbar": {"type": "number"},
   106                "foo\fbar": {"type": "number"}
   107            }
   108        },
   109        "tests": [
   110            {
   111                "description": "object with all numbers is valid",
   112                "data": {
   113                    "foo\nbar": 1,
   114                    "foo\"bar": 1,
   115                    "foo\\bar": 1,
   116                    "foo\rbar": 1,
   117                    "foo\tbar": 1,
   118                    "foo\fbar": 1
   119                },
   120                "valid": true
   121            },
   122            {
   123                "description": "object with strings is invalid",
   124                "data": {
   125                    "foo\nbar": "1",
   126                    "foo\"bar": "1",
   127                    "foo\\bar": "1",
   128                    "foo\rbar": "1",
   129                    "foo\tbar": "1",
   130                    "foo\fbar": "1"
   131                },
   132                "valid": false
   133            }
   134        ]
   135    }
   136]

View as plain text