github.com/kaptinlin/jsonschema@v0.4.6/testdata/JSON-Schema-Test-Suite/tests/draft-next/patternProperties.json (about)

     1  [
     2      {
     3          "description":
     4              "patternProperties validates properties matching a regex",
     5          "schema": {
     6              "$schema": "https://json-schema.org/draft/next/schema",
     7              "patternProperties": {
     8                  "f.*o": {"type": "integer"}
     9              }
    10          },
    11          "tests": [
    12              {
    13                  "description": "a single valid match is valid",
    14                  "data": {"foo": 1},
    15                  "valid": true
    16              },
    17              {
    18                  "description": "multiple valid matches is valid",
    19                  "data": {"foo": 1, "foooooo" : 2},
    20                  "valid": true
    21              },
    22              {
    23                  "description": "a single invalid match is invalid",
    24                  "data": {"foo": "bar", "fooooo": 2},
    25                  "valid": false
    26              },
    27              {
    28                  "description": "multiple invalid matches is invalid",
    29                  "data": {"foo": "bar", "foooooo" : "baz"},
    30                  "valid": false
    31              },
    32              {
    33                  "description": "ignores arrays",
    34                  "data": ["foo"],
    35                  "valid": true
    36              },
    37              {
    38                  "description": "ignores strings",
    39                  "data": "foo",
    40                  "valid": true
    41              },
    42              {
    43                  "description": "ignores other non-objects",
    44                  "data": 12,
    45                  "valid": true
    46              }
    47          ]
    48      },
    49      {
    50          "description": "multiple simultaneous patternProperties are validated",
    51          "schema": {
    52              "$schema": "https://json-schema.org/draft/next/schema",
    53              "patternProperties": {
    54                  "a*": {"type": "integer"},
    55                  "aaa*": {"maximum": 20}
    56              }
    57          },
    58          "tests": [
    59              {
    60                  "description": "a single valid match is valid",
    61                  "data": {"a": 21},
    62                  "valid": true
    63              },
    64              {
    65                  "description": "a simultaneous match is valid",
    66                  "data": {"aaaa": 18},
    67                  "valid": true
    68              },
    69              {
    70                  "description": "multiple matches is valid",
    71                  "data": {"a": 21, "aaaa": 18},
    72                  "valid": true
    73              },
    74              {
    75                  "description": "an invalid due to one is invalid",
    76                  "data": {"a": "bar"},
    77                  "valid": false
    78              },
    79              {
    80                  "description": "an invalid due to the other is invalid",
    81                  "data": {"aaaa": 31},
    82                  "valid": false
    83              },
    84              {
    85                  "description": "an invalid due to both is invalid",
    86                  "data": {"aaa": "foo", "aaaa": 31},
    87                  "valid": false
    88              }
    89          ]
    90      },
    91      {
    92          "description": "regexes are not anchored by default and are case sensitive",
    93          "schema": {
    94              "$schema": "https://json-schema.org/draft/next/schema",
    95              "patternProperties": {
    96                  "[0-9]{2,}": { "type": "boolean" },
    97                  "X_": { "type": "string" }
    98              }
    99          },
   100          "tests": [
   101              {
   102                  "description": "non recognized members are ignored",
   103                  "data": { "answer 1": "42" },
   104                  "valid": true
   105              },
   106              {
   107                  "description": "recognized members are accounted for",
   108                  "data": { "a31b": null },
   109                  "valid": false
   110              },
   111              {
   112                  "description": "regexes are case sensitive",
   113                  "data": { "a_x_3": 3 },
   114                  "valid": true
   115              },
   116              {
   117                  "description": "regexes are case sensitive, 2",
   118                  "data": { "a_X_3": 3 },
   119                  "valid": false
   120              }
   121          ]
   122      },
   123      {
   124          "description": "patternProperties with boolean schemas",
   125          "schema": {
   126              "$schema": "https://json-schema.org/draft/next/schema",
   127              "patternProperties": {
   128                  "f.*": true,
   129                  "b.*": false
   130              }
   131          },
   132          "tests": [
   133              {
   134                  "description": "object with property matching schema true is valid",
   135                  "data": {"foo": 1},
   136                  "valid": true
   137              },
   138              {
   139                  "description": "object with property matching schema false is invalid",
   140                  "data": {"bar": 2},
   141                  "valid": false
   142              },
   143              {
   144                  "description": "object with both properties is invalid",
   145                  "data": {"foo": 1, "bar": 2},
   146                  "valid": false
   147              },
   148              {
   149                  "description": "object with a property matching both true and false is invalid",
   150                  "data": {"foobar":1},
   151                  "valid": false
   152              },
   153              {
   154                  "description": "empty object is valid",
   155                  "data": {},
   156                  "valid": true
   157              }
   158          ]
   159      },
   160      {
   161          "description": "patternProperties with null valued instance properties",
   162          "schema": {
   163              "$schema": "https://json-schema.org/draft/next/schema",
   164              "patternProperties": {
   165                  "^.*bar$": {"type": "null"}
   166              }
   167          },
   168          "tests": [
   169              {
   170                  "description": "allows null values",
   171                  "data": {"foobar": null},
   172                  "valid": true
   173              }
   174          ]
   175      }
   176  ]