...

Text file src/github.com/qri-io/jsonschema/testdata/draft7/contains.json

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

     1[
     2    {
     3        "description": "contains keyword validation",
     4        "schema": {
     5            "contains": {"minimum": 5}
     6        },
     7        "tests": [
     8            {
     9                "description": "array with item matching schema (5) is valid",
    10                "data": [3, 4, 5],
    11                "valid": true
    12            },
    13            {
    14                "description": "array with item matching schema (6) is valid",
    15                "data": [3, 4, 6],
    16                "valid": true
    17            },
    18            {
    19                "description": "array with two items matching schema (5, 6) is valid",
    20                "data": [3, 4, 5, 6],
    21                "valid": true
    22            },
    23            {
    24                "description": "array without items matching schema is invalid",
    25                "data": [2, 3, 4],
    26                "valid": false
    27            },
    28            {
    29                "description": "empty array is invalid",
    30                "data": [],
    31                "valid": false
    32            },
    33            {
    34                "description": "not array is valid",
    35                "data": {},
    36                "valid": true
    37            }
    38        ]
    39    },
    40    {
    41        "description": "contains keyword with const keyword",
    42        "schema": {
    43            "contains": { "const": 5 }
    44        },
    45        "tests": [
    46            {
    47                "description": "array with item 5 is valid",
    48                "data": [3, 4, 5],
    49                "valid": true
    50            },
    51            {
    52                "description": "array with two items 5 is valid",
    53                "data": [3, 4, 5, 5],
    54                "valid": true
    55            },
    56            {
    57                "description": "array without item 5 is invalid",
    58                "data": [1, 2, 3, 4],
    59                "valid": false
    60            }
    61        ]
    62    },
    63    {
    64        "description": "contains keyword with boolean schema true",
    65        "schema": {"contains": true},
    66        "tests": [
    67            {
    68                "description": "any non-empty array is valid",
    69                "data": ["foo"],
    70                "valid": true
    71            },
    72            {
    73                "description": "empty array is invalid",
    74                "data": [],
    75                "valid": false
    76            }
    77        ]
    78    },
    79    {
    80        "description": "contains keyword with boolean schema false",
    81        "schema": {"contains": false},
    82        "tests": [
    83            {
    84                "description": "any non-empty array is invalid",
    85                "data": ["foo"],
    86                "valid": false
    87            },
    88            {
    89                "description": "empty array is invalid",
    90                "data": [],
    91                "valid": false
    92            },
    93            {
    94                "description": "non-arrays are valid",
    95                "data": "contains does not apply to strings",
    96                "valid": true
    97            }
    98        ]
    99    }
   100]

View as plain text