...

Text file src/github.com/qri-io/jsonschema/testdata/draft7/if-then-else.json

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

     1[
     2    {
     3        "description": "ignore if without then or else",
     4        "schema": {
     5            "if": {
     6                "const": 0
     7            }
     8        },
     9        "tests": [
    10            {
    11                "description": "valid when valid against lone if",
    12                "data": 0,
    13                "valid": true
    14            },
    15            {
    16                "description": "valid when invalid against lone if",
    17                "data": "hello",
    18                "valid": true
    19            }
    20        ]
    21    },
    22    {
    23        "description": "ignore then without if",
    24        "schema": {
    25            "then": {
    26                "const": 0
    27            }
    28        },
    29        "tests": [
    30            {
    31                "description": "valid when valid against lone then",
    32                "data": 0,
    33                "valid": true
    34            },
    35            {
    36                "description": "valid when invalid against lone then",
    37                "data": "hello",
    38                "valid": true
    39            }
    40        ]
    41    },
    42    {
    43        "description": "ignore else without if",
    44        "schema": {
    45            "else": {
    46                "const": 0
    47            }
    48        },
    49        "tests": [
    50            {
    51                "description": "valid when valid against lone else",
    52                "data": 0,
    53                "valid": true
    54            },
    55            {
    56                "description": "valid when invalid against lone else",
    57                "data": "hello",
    58                "valid": true
    59            }
    60        ]
    61    },
    62    {
    63        "description": "if and then without else",
    64        "schema": {
    65            "if": {
    66                "exclusiveMaximum": 0
    67            },
    68            "then": {
    69                "minimum": -10
    70            }
    71        },
    72        "tests": [
    73            {
    74                "description": "valid through then",
    75                "data": -1,
    76                "valid": true
    77            },
    78            {
    79                "description": "invalid through then",
    80                "data": -100,
    81                "valid": false
    82            },
    83            {
    84                "description": "valid when if test fails",
    85                "data": 3,
    86                "valid": true
    87            }
    88        ]
    89    },
    90    {
    91        "description": "if and else without then",
    92        "schema": {
    93            "if": {
    94                "exclusiveMaximum": 0
    95            },
    96            "else": {
    97                "multipleOf": 2
    98            }
    99        },
   100        "tests": [
   101            {
   102                "description": "valid when if test passes",
   103                "data": -1,
   104                "valid": true
   105            },
   106            {
   107                "description": "valid through else",
   108                "data": 4,
   109                "valid": true
   110            },
   111            {
   112                "description": "invalid through else",
   113                "data": 3,
   114                "valid": false
   115            }
   116        ]
   117    },
   118    {
   119        "description": "validate against correct branch, then vs else",
   120        "schema": {
   121            "if": {
   122                "exclusiveMaximum": 0
   123            },
   124            "then": {
   125                "minimum": -10
   126            },
   127            "else": {
   128                "multipleOf": 2
   129            }
   130        },
   131        "tests": [
   132            {
   133                "description": "valid through then",
   134                "data": -1,
   135                "valid": true
   136            },
   137            {
   138                "description": "invalid through then",
   139                "data": -100,
   140                "valid": false
   141            },
   142            {
   143                "description": "valid through else",
   144                "data": 4,
   145                "valid": true
   146            },
   147            {
   148                "description": "invalid through else",
   149                "data": 3,
   150                "valid": false
   151            }
   152        ]
   153    },
   154    {
   155        "description": "non-interference across combined schemas",
   156        "schema": {
   157            "allOf": [
   158                {
   159                    "if": {
   160                        "exclusiveMaximum": 0
   161                    }
   162                },
   163                {
   164                    "then": {
   165                        "minimum": -10
   166                    }
   167                },
   168                {
   169                    "else": {
   170                        "multipleOf": 2
   171                    }
   172                }
   173            ]
   174        },
   175        "tests": [
   176            {
   177                "description": "valid, but would have been invalid through then",
   178                "data": -100,
   179                "valid": true
   180            },
   181            {
   182                "description": "valid, but would have been invalid through else",
   183                "data": 3,
   184                "valid": true
   185            }
   186        ]
   187    }
   188]

View as plain text