github.com/kaptinlin/jsonschema@v0.4.6/testdata/JSON-Schema-Test-Suite/tests/draft2020-12/optional/ecmascript-regex.json (about)

     1  [
     2      {
     3          "description": "ECMA 262 regex $ does not match trailing newline",
     4          "schema": {
     5              "$schema": "https://json-schema.org/draft/2020-12/schema",
     6              "type": "string",
     7              "pattern": "^abc$"
     8          },
     9          "tests": [
    10              {
    11                  "description": "matches in Python, but not in ECMA 262",
    12                  "data": "abc\\n",
    13                  "valid": false
    14              },
    15              {
    16                  "description": "matches",
    17                  "data": "abc",
    18                  "valid": true
    19              }
    20          ]
    21      },
    22      {
    23          "description": "ECMA 262 regex converts \\t to horizontal tab",
    24          "schema": {
    25              "$schema": "https://json-schema.org/draft/2020-12/schema",
    26              "type": "string",
    27              "pattern": "^\\t$"
    28          },
    29          "tests": [
    30              {
    31                  "description": "does not match",
    32                  "data": "\\t",
    33                  "valid": false
    34              },
    35              {
    36                  "description": "matches",
    37                  "data": "\u0009",
    38                  "valid": true
    39              }
    40          ]
    41      },
    42      {
    43          "description": "ECMA 262 regex escapes control codes with \\c and upper letter",
    44          "schema": {
    45              "$schema": "https://json-schema.org/draft/2020-12/schema",
    46              "type": "string",
    47              "pattern": "^\\cC$"
    48          },
    49          "tests": [
    50              {
    51                  "description": "does not match",
    52                  "data": "\\cC",
    53                  "valid": false
    54              },
    55              {
    56                  "description": "matches",
    57                  "data": "\u0003",
    58                  "valid": true
    59              }
    60          ]
    61      },
    62      {
    63          "description": "ECMA 262 regex escapes control codes with \\c and lower letter",
    64          "schema": {
    65              "$schema": "https://json-schema.org/draft/2020-12/schema",
    66              "type": "string",
    67              "pattern": "^\\cc$"
    68          },
    69          "tests": [
    70              {
    71                  "description": "does not match",
    72                  "data": "\\cc",
    73                  "valid": false
    74              },
    75              {
    76                  "description": "matches",
    77                  "data": "\u0003",
    78                  "valid": true
    79              }
    80          ]
    81      },
    82      {
    83          "description": "ECMA 262 \\d matches ascii digits only",
    84          "schema": {
    85              "$schema": "https://json-schema.org/draft/2020-12/schema",
    86              "type": "string",
    87              "pattern": "^\\d$"
    88          },
    89          "tests": [
    90              {
    91                  "description": "ASCII zero matches",
    92                  "data": "0",
    93                  "valid": true
    94              },
    95              {
    96                  "description": "NKO DIGIT ZERO does not match (unlike e.g. Python)",
    97                  "data": "߀",
    98                  "valid": false
    99              },
   100              {
   101                  "description": "NKO DIGIT ZERO (as \\u escape) does not match",
   102                  "data": "\u07c0",
   103                  "valid": false
   104              }
   105          ]
   106      },
   107      {
   108          "description": "ECMA 262 \\D matches everything but ascii digits",
   109          "schema": {
   110              "$schema": "https://json-schema.org/draft/2020-12/schema",
   111              "type": "string",
   112              "pattern": "^\\D$"
   113          },
   114          "tests": [
   115              {
   116                  "description": "ASCII zero does not match",
   117                  "data": "0",
   118                  "valid": false
   119              },
   120              {
   121                  "description": "NKO DIGIT ZERO matches (unlike e.g. Python)",
   122                  "data": "߀",
   123                  "valid": true
   124              },
   125              {
   126                  "description": "NKO DIGIT ZERO (as \\u escape) matches",
   127                  "data": "\u07c0",
   128                  "valid": true
   129              }
   130          ]
   131      },
   132      {
   133          "description": "ECMA 262 \\w matches ascii letters only",
   134          "schema": {
   135              "$schema": "https://json-schema.org/draft/2020-12/schema",
   136              "type": "string",
   137              "pattern": "^\\w$"
   138          },
   139          "tests": [
   140              {
   141                  "description": "ASCII 'a' matches",
   142                  "data": "a",
   143                  "valid": true
   144              },
   145              {
   146                  "description": "latin-1 e-acute does not match (unlike e.g. Python)",
   147                  "data": "é",
   148                  "valid": false
   149              }
   150          ]
   151      },
   152      {
   153          "description": "ECMA 262 \\W matches everything but ascii letters",
   154          "schema": {
   155              "$schema": "https://json-schema.org/draft/2020-12/schema",
   156              "type": "string",
   157              "pattern": "^\\W$"
   158          },
   159          "tests": [
   160              {
   161                  "description": "ASCII 'a' does not match",
   162                  "data": "a",
   163                  "valid": false
   164              },
   165              {
   166                  "description": "latin-1 e-acute matches (unlike e.g. Python)",
   167                  "data": "é",
   168                  "valid": true
   169              }
   170          ]
   171      },
   172      {
   173          "description": "ECMA 262 \\s matches whitespace",
   174          "schema": {
   175              "$schema": "https://json-schema.org/draft/2020-12/schema",
   176              "type": "string",
   177              "pattern": "^\\s$"
   178          },
   179          "tests": [
   180              {
   181                  "description": "ASCII space matches",
   182                  "data": " ",
   183                  "valid": true
   184              },
   185              {
   186                  "description": "Character tabulation matches",
   187                  "data": "\t",
   188                  "valid": true
   189              },
   190              {
   191                  "description": "Line tabulation matches",
   192                  "data": "\u000b",
   193                  "valid": true
   194              },
   195              {
   196                  "description": "Form feed matches",
   197                  "data": "\u000c",
   198                  "valid": true
   199              },
   200              {
   201                  "description": "latin-1 non-breaking-space matches",
   202                  "data": "\u00a0",
   203                  "valid": true
   204              },
   205              {
   206                  "description": "zero-width whitespace matches",
   207                  "data": "\ufeff",
   208                  "valid": true
   209              },
   210              {
   211                  "description": "line feed matches (line terminator)",
   212                  "data": "\u000a",
   213                  "valid": true
   214              },
   215              {
   216                  "description": "paragraph separator matches (line terminator)",
   217                  "data": "\u2029",
   218                  "valid": true
   219              },
   220              {
   221                  "description": "EM SPACE matches (Space_Separator)",
   222                  "data": "\u2003",
   223                  "valid": true
   224              },
   225              {
   226                  "description": "Non-whitespace control does not match",
   227                  "data": "\u0001",
   228                  "valid": false
   229              },
   230              {
   231                  "description": "Non-whitespace does not match",
   232                  "data": "\u2013",
   233                  "valid": false
   234              }
   235          ]
   236      },
   237      {
   238          "description": "ECMA 262 \\S matches everything but whitespace",
   239          "schema": {
   240              "$schema": "https://json-schema.org/draft/2020-12/schema",
   241              "type": "string",
   242              "pattern": "^\\S$"
   243          },
   244          "tests": [
   245              {
   246                  "description": "ASCII space does not match",
   247                  "data": " ",
   248                  "valid": false
   249              },
   250              {
   251                  "description": "Character tabulation does not match",
   252                  "data": "\t",
   253                  "valid": false
   254              },
   255              {
   256                  "description": "Line tabulation does not match",
   257                  "data": "\u000b",
   258                  "valid": false
   259              },
   260              {
   261                  "description": "Form feed does not match",
   262                  "data": "\u000c",
   263                  "valid": false
   264              },
   265              {
   266                  "description": "latin-1 non-breaking-space does not match",
   267                  "data": "\u00a0",
   268                  "valid": false
   269              },
   270              {
   271                  "description": "zero-width whitespace does not match",
   272                  "data": "\ufeff",
   273                  "valid": false
   274              },
   275              {
   276                  "description": "line feed does not match (line terminator)",
   277                  "data": "\u000a",
   278                  "valid": false
   279              },
   280              {
   281                  "description": "paragraph separator does not match (line terminator)",
   282                  "data": "\u2029",
   283                  "valid": false
   284              },
   285              {
   286                  "description": "EM SPACE does not match (Space_Separator)",
   287                  "data": "\u2003",
   288                  "valid": false
   289              },
   290              {
   291                  "description": "Non-whitespace control matches",
   292                  "data": "\u0001",
   293                  "valid": true
   294              },
   295              {
   296                  "description": "Non-whitespace matches",
   297                  "data": "\u2013",
   298                  "valid": true
   299              }
   300          ]
   301      },
   302      {
   303          "description": "patterns always use unicode semantics with pattern",
   304          "schema": {
   305              "$schema": "https://json-schema.org/draft/2020-12/schema",
   306              "pattern": "\\p{Letter}cole"
   307          },
   308          "tests": [
   309              {
   310                  "description": "ascii character in json string",
   311                  "data": "Les hivers de mon enfance etaient des saisons longues, longues. Nous vivions en trois lieux: l'ecole, l'eglise et la patinoire; mais la vraie vie etait sur la patinoire.",
   312                  "valid": true
   313              },
   314              {
   315                  "description": "literal unicode character in json string",
   316                  "data": "Les hivers de mon enfance étaient des saisons longues, longues. Nous vivions en trois lieux: l'école, l'église et la patinoire; mais la vraie vie était sur la patinoire.",
   317                  "valid": true
   318              },
   319              {
   320                  "description": "unicode character in hex format in string",
   321                  "data": "Les hivers de mon enfance étaient des saisons longues, longues. Nous vivions en trois lieux: l'\u00e9cole, l'église et la patinoire; mais la vraie vie était sur la patinoire.",
   322                  "valid": true
   323              },
   324              {
   325                  "description": "unicode matching is case-sensitive",
   326                  "data": "LES HIVERS DE MON ENFANCE ÉTAIENT DES SAISONS LONGUES, LONGUES. NOUS VIVIONS EN TROIS LIEUX: L'ÉCOLE, L'ÉGLISE ET LA PATINOIRE; MAIS LA VRAIE VIE ÉTAIT SUR LA PATINOIRE.",
   327                  "valid": false
   328              }
   329          ]
   330      },
   331      {
   332          "description": "\\w in patterns matches [A-Za-z0-9_], not unicode letters",
   333          "schema": {
   334              "$schema": "https://json-schema.org/draft/2020-12/schema",
   335              "pattern": "\\wcole"
   336          },
   337          "tests": [
   338              {
   339                  "description": "ascii character in json string",
   340                  "data": "Les hivers de mon enfance etaient des saisons longues, longues. Nous vivions en trois lieux: l'ecole, l'eglise et la patinoire; mais la vraie vie etait sur la patinoire.",
   341                  "valid": true
   342              },
   343              {
   344                  "description": "literal unicode character in json string",
   345                  "data": "Les hivers de mon enfance étaient des saisons longues, longues. Nous vivions en trois lieux: l'école, l'église et la patinoire; mais la vraie vie était sur la patinoire.",
   346                  "valid": false
   347              },
   348              {
   349                  "description": "unicode character in hex format in string",
   350                  "data": "Les hivers de mon enfance étaient des saisons longues, longues. Nous vivions en trois lieux: l'\u00e9cole, l'église et la patinoire; mais la vraie vie était sur la patinoire.",
   351                  "valid": false
   352              },
   353              {
   354                  "description": "unicode matching is case-sensitive",
   355                  "data": "LES HIVERS DE MON ENFANCE ÉTAIENT DES SAISONS LONGUES, LONGUES. NOUS VIVIONS EN TROIS LIEUX: L'ÉCOLE, L'ÉGLISE ET LA PATINOIRE; MAIS LA VRAIE VIE ÉTAIT SUR LA PATINOIRE.",
   356                  "valid": false
   357              }
   358          ]
   359      },
   360      {
   361          "description": "pattern with ASCII ranges",
   362          "schema": {
   363              "$schema": "https://json-schema.org/draft/2020-12/schema",
   364              "pattern": "[a-z]cole"
   365          },
   366          "tests": [
   367              {
   368                  "description": "literal unicode character in json string",
   369                  "data": "Les hivers de mon enfance étaient des saisons longues, longues. Nous vivions en trois lieux: l'école, l'église et la patinoire; mais la vraie vie était sur la patinoire.",
   370                  "valid": false
   371              },
   372              {
   373                  "description": "unicode character in hex format in string",
   374                  "data": "Les hivers de mon enfance étaient des saisons longues, longues. Nous vivions en trois lieux: l'\u00e9cole, l'église et la patinoire; mais la vraie vie était sur la patinoire.",
   375                  "valid": false
   376              },
   377              {
   378                  "description": "ascii characters match",
   379                  "data": "Les hivers de mon enfance etaient des saisons longues, longues. Nous vivions en trois lieux: l'ecole, l'eglise et la patinoire; mais la vraie vie etait sur la patinoire.",
   380                  "valid": true
   381              }
   382          ]
   383      },
   384      {
   385          "description": "\\d in pattern matches [0-9], not unicode digits",
   386          "schema": {
   387              "$schema": "https://json-schema.org/draft/2020-12/schema",
   388              "pattern": "^\\d+$"
   389          },
   390          "tests": [
   391              {
   392                  "description": "ascii digits",
   393                  "data": "42",
   394                  "valid": true
   395              },
   396              {
   397                  "description": "ascii non-digits",
   398                  "data": "-%#",
   399                  "valid": false
   400              },
   401              {
   402                  "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)",
   403                  "data": "৪২",
   404                  "valid": false
   405              }
   406          ]
   407      },
   408      {
   409          "description": "\\a is not an ECMA 262 control escape",
   410          "schema": {
   411              "$schema": "https://json-schema.org/draft/2020-12/schema",
   412              "$ref": "https://json-schema.org/draft/2020-12/schema"
   413          },
   414          "tests": [
   415              {
   416                  "description": "when used as a pattern",
   417                  "data": { "pattern": "\\a" },
   418                  "valid": false
   419              }
   420          ]
   421      },
   422      {
   423          "description": "pattern with non-ASCII digits",
   424          "schema": {
   425              "$schema": "https://json-schema.org/draft/2020-12/schema",
   426              "pattern": "^\\p{digit}+$"
   427          },
   428          "tests": [
   429              {
   430                  "description": "ascii digits",
   431                  "data": "42",
   432                  "valid": true
   433              },
   434              {
   435                  "description": "ascii non-digits",
   436                  "data": "-%#",
   437                  "valid": false
   438              },
   439              {
   440                  "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)",
   441                  "data": "৪২",
   442                  "valid": true
   443              }
   444          ]
   445      },
   446      {
   447          "description": "patterns always use unicode semantics with patternProperties",
   448          "schema": {
   449              "$schema": "https://json-schema.org/draft/2020-12/schema",
   450              "type": "object",
   451              "patternProperties": {
   452                  "\\p{Letter}cole": true
   453              },
   454              "additionalProperties": false
   455          },
   456          "tests": [
   457              {
   458                  "description": "ascii character in json string",
   459                  "data": { "l'ecole": "pas de vraie vie" },
   460                  "valid": true
   461              },
   462              {
   463                  "description": "literal unicode character in json string",
   464                  "data": { "l'école": "pas de vraie vie" },
   465                  "valid": true
   466              },
   467              {
   468                  "description": "unicode character in hex format in string",
   469                  "data": { "l'\u00e9cole": "pas de vraie vie" },
   470                  "valid": true
   471              },
   472              {
   473                  "description": "unicode matching is case-sensitive",
   474                  "data": { "L'ÉCOLE": "PAS DE VRAIE VIE" },
   475                  "valid": false
   476              }
   477          ]
   478      },
   479      {
   480          "description": "\\w in patternProperties matches [A-Za-z0-9_], not unicode letters",
   481          "schema": {
   482              "$schema": "https://json-schema.org/draft/2020-12/schema",
   483              "type": "object",
   484              "patternProperties": {
   485                  "\\wcole": true
   486              },
   487              "additionalProperties": false
   488          },
   489          "tests": [
   490              {
   491                  "description": "ascii character in json string",
   492                  "data": { "l'ecole": "pas de vraie vie" },
   493                  "valid": true
   494              },
   495              {
   496                  "description": "literal unicode character in json string",
   497                  "data": { "l'école": "pas de vraie vie" },
   498                  "valid": false
   499              },
   500              {
   501                  "description": "unicode character in hex format in string",
   502                  "data": { "l'\u00e9cole": "pas de vraie vie" },
   503                  "valid": false
   504              },
   505              {
   506                  "description": "unicode matching is case-sensitive",
   507                  "data": { "L'ÉCOLE": "PAS DE VRAIE VIE" },
   508                  "valid": false
   509              }
   510          ]
   511      },
   512      {
   513          "description": "patternProperties with ASCII ranges",
   514          "schema": {
   515              "$schema": "https://json-schema.org/draft/2020-12/schema",
   516              "type": "object",
   517              "patternProperties": {
   518                  "[a-z]cole": true
   519              },
   520              "additionalProperties": false
   521          },
   522          "tests": [
   523              {
   524                  "description": "literal unicode character in json string",
   525                  "data": { "l'école": "pas de vraie vie" },
   526                  "valid": false
   527              },
   528              {
   529                  "description": "unicode character in hex format in string",
   530                  "data": { "l'\u00e9cole": "pas de vraie vie" },
   531                  "valid": false
   532              },
   533              {
   534                  "description": "ascii characters match",
   535                  "data": { "l'ecole": "pas de vraie vie" },
   536                  "valid": true
   537              }
   538          ]
   539      },
   540      {
   541          "description": "\\d in patternProperties matches [0-9], not unicode digits",
   542          "schema": {
   543              "$schema": "https://json-schema.org/draft/2020-12/schema",
   544              "type": "object",
   545              "patternProperties": {
   546                  "^\\d+$": true
   547              },
   548              "additionalProperties": false
   549          },
   550          "tests": [
   551              {
   552                  "description": "ascii digits",
   553                  "data": { "42": "life, the universe, and everything" },
   554                  "valid": true
   555              },
   556              {
   557                  "description": "ascii non-digits",
   558                  "data": { "-%#": "spending the year dead for tax reasons" },
   559                  "valid": false
   560              },
   561              {
   562                  "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)",
   563                  "data": { "৪২": "khajit has wares if you have coin" },
   564                  "valid": false
   565              }
   566          ]
   567      },
   568      {
   569          "description": "patternProperties with non-ASCII digits",
   570          "schema": {
   571              "$schema": "https://json-schema.org/draft/2020-12/schema",
   572              "type": "object",
   573              "patternProperties": {
   574                  "^\\p{digit}+$": true
   575              },
   576              "additionalProperties": false
   577          },
   578          "tests": [
   579              {
   580                  "description": "ascii digits",
   581                  "data": { "42": "life, the universe, and everything" },
   582                  "valid": true
   583              },
   584              {
   585                  "description": "ascii non-digits",
   586                  "data": { "-%#": "spending the year dead for tax reasons" },
   587                  "valid": false
   588              },
   589              {
   590                  "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)",
   591                  "data": { "৪২": "khajit has wares if you have coin" },
   592                  "valid": true
   593              }
   594          ]
   595      }
   596  ]