From cf886386cc0996df6743b425f74675a6d8a1a9ca Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Thu, 7 Oct 2021 09:13:10 -0400 Subject: Squashed 'json/' changes from 20c1bb1d9..54440eab4 54440eab4 Merge pull request #516 from ChALkeR/chalker/ipv6 e7b22e1c6 Fix the sanity check by pinning. 8891d8107 Merge pull request #519 from json-schema-org/ether/custom-dialect 5f5fccda3 test the format-assertion vocabulary with a custom metaschema 3fcee3868 Merge pull request #512 from json-schema-org/ether/formats-and-non-strings b349b8797 test that format-assertions are valid with non-string types 8e5b2f10d fix needless inconsistencies in format tests between drafts 02d7cb59a Correct "ref with sibling id" tests 1649470ba More ipv6 tests to increase coverage 7334b4c7e Merge pull request #505 from ChALkeR/chalker/fix-unicode 0fb2d2787 Consolidate optional/unicode into optional/ecmascript-regex 4f8c6d7bf unevaluatedProperties: deep dynamic + refs 9103f3b6f $ref wit id does not test what it is indented to do f300dd15f Add test "same $anchor with different base uri" d128f9d7f Add test to check that $id resolved against nearest parent, not just immediate parent 72e31dd20 Merge pull request #515 from json-schema-org/ether/fix-mandatory-format-tests 0173a0835 Revert "by default, "format" only annotates, not validates" 66e813a90 Merge pull request #506 from json-schema-org/ether/formats-non-ascii 9430972bc fix unicode tests in accordance to pattern/patternProperties spec git-subtree-dir: json git-subtree-split: 54440eab4d50b80a62cc9f9c561e306cdbb19591 --- remotes/draft2020-12/format-assertion-false.json | 12 + remotes/draft2020-12/format-assertion-true.json | 12 + tests/draft-future/anchor.json | 35 +++ tests/draft-future/format.json | 95 -------- tests/draft-future/optional/ecmascript-regex.json | 260 +++++++++++++++++++++ tests/draft-future/optional/format-assertion.json | 42 ++++ tests/draft-future/optional/format/date-time.json | 37 ++- tests/draft-future/optional/format/date.json | 32 ++- tests/draft-future/optional/format/duration.json | 32 ++- tests/draft-future/optional/format/email.json | 32 ++- tests/draft-future/optional/format/hostname.json | 32 ++- tests/draft-future/optional/format/idn-email.json | 32 ++- .../draft-future/optional/format/idn-hostname.json | 30 +++ tests/draft-future/optional/format/ipv4.json | 32 ++- tests/draft-future/optional/format/ipv6.json | 47 +++- .../optional/format/iri-reference.json | 32 ++- tests/draft-future/optional/format/iri.json | 32 ++- .../draft-future/optional/format/json-pointer.json | 32 ++- tests/draft-future/optional/format/regex.json | 32 ++- .../optional/format/relative-json-pointer.json | 32 ++- tests/draft-future/optional/format/time.json | 32 ++- .../optional/format/uri-reference.json | 32 ++- .../draft-future/optional/format/uri-template.json | 32 ++- tests/draft-future/optional/format/uri.json | 2 +- tests/draft-future/optional/unicode.json | 146 ------------ tests/draft-future/ref.json | 36 +++ tests/draft-future/unevaluatedProperties.json | 250 ++++++++++++++++++++ tests/draft2019-09/anchor.json | 35 +++ tests/draft2019-09/format.json | 95 -------- tests/draft2019-09/optional/ecmascript-regex.json | 260 +++++++++++++++++++++ tests/draft2019-09/optional/format/date-time.json | 37 ++- tests/draft2019-09/optional/format/date.json | 32 ++- tests/draft2019-09/optional/format/duration.json | 32 ++- tests/draft2019-09/optional/format/email.json | 32 ++- tests/draft2019-09/optional/format/hostname.json | 32 ++- tests/draft2019-09/optional/format/idn-email.json | 32 ++- .../draft2019-09/optional/format/idn-hostname.json | 30 +++ tests/draft2019-09/optional/format/ipv4.json | 32 ++- tests/draft2019-09/optional/format/ipv6.json | 47 +++- .../optional/format/iri-reference.json | 32 ++- tests/draft2019-09/optional/format/iri.json | 32 ++- .../draft2019-09/optional/format/json-pointer.json | 32 ++- tests/draft2019-09/optional/format/regex.json | 32 ++- .../optional/format/relative-json-pointer.json | 32 ++- tests/draft2019-09/optional/format/time.json | 32 ++- .../optional/format/uri-reference.json | 32 ++- .../draft2019-09/optional/format/uri-template.json | 32 ++- tests/draft2019-09/optional/format/uri.json | 2 +- tests/draft2019-09/optional/unicode.json | 146 ------------ tests/draft2019-09/ref.json | 36 +++ tests/draft2019-09/unevaluatedProperties.json | 250 ++++++++++++++++++++ tests/draft2020-12/anchor.json | 35 +++ tests/draft2020-12/format.json | 95 -------- tests/draft2020-12/optional/ecmascript-regex.json | 260 +++++++++++++++++++++ tests/draft2020-12/optional/format-assertion.json | 42 ++++ tests/draft2020-12/optional/format/date-time.json | 37 ++- tests/draft2020-12/optional/format/date.json | 32 ++- tests/draft2020-12/optional/format/duration.json | 32 ++- tests/draft2020-12/optional/format/email.json | 32 ++- tests/draft2020-12/optional/format/hostname.json | 32 ++- tests/draft2020-12/optional/format/idn-email.json | 32 ++- .../draft2020-12/optional/format/idn-hostname.json | 30 +++ tests/draft2020-12/optional/format/ipv4.json | 32 ++- tests/draft2020-12/optional/format/ipv6.json | 47 +++- .../optional/format/iri-reference.json | 32 ++- tests/draft2020-12/optional/format/iri.json | 32 ++- .../draft2020-12/optional/format/json-pointer.json | 32 ++- tests/draft2020-12/optional/format/regex.json | 32 ++- .../optional/format/relative-json-pointer.json | 32 ++- tests/draft2020-12/optional/format/time.json | 32 ++- .../optional/format/uri-reference.json | 32 ++- .../draft2020-12/optional/format/uri-template.json | 32 ++- tests/draft2020-12/optional/format/uri.json | 2 +- tests/draft2020-12/optional/unicode.json | 146 ------------ tests/draft2020-12/ref.json | 36 +++ tests/draft2020-12/unevaluatedProperties.json | 250 ++++++++++++++++++++ tests/draft3/optional/format/color.json | 2 +- tests/draft3/optional/format/date-time.json | 2 +- tests/draft3/optional/format/date.json | 2 +- tests/draft3/optional/format/email.json | 2 +- tests/draft3/optional/format/host-name.json | 2 +- tests/draft3/optional/format/ip-address.json | 2 +- tests/draft3/optional/format/ipv6.json | 2 +- tests/draft3/optional/format/regex.json | 2 +- tests/draft3/optional/format/time.json | 2 +- tests/draft3/optional/format/uri.json | 2 +- tests/draft3/ref.json | 16 +- tests/draft4/optional/ecmascript-regex.json | 260 +++++++++++++++++++++ tests/draft4/optional/format/date-time.json | 37 ++- tests/draft4/optional/format/email.json | 32 ++- tests/draft4/optional/format/hostname.json | 38 ++- tests/draft4/optional/format/ipv4.json | 32 ++- tests/draft4/optional/format/ipv6.json | 47 +++- tests/draft4/optional/format/uri.json | 2 +- tests/draft4/optional/unicode.json | 146 ------------ tests/draft4/ref.json | 52 ++++- tests/draft6/optional/ecmascript-regex.json | 260 +++++++++++++++++++++ tests/draft6/optional/format/date-time.json | 32 ++- tests/draft6/optional/format/email.json | 32 ++- tests/draft6/optional/format/hostname.json | 37 ++- tests/draft6/optional/format/ipv4.json | 32 ++- tests/draft6/optional/format/ipv6.json | 47 +++- tests/draft6/optional/format/json-pointer.json | 32 ++- tests/draft6/optional/format/uri-reference.json | 32 ++- tests/draft6/optional/format/uri-template.json | 32 ++- tests/draft6/optional/format/uri.json | 2 +- tests/draft6/optional/unicode.json | 146 ------------ tests/draft6/ref.json | 16 +- tests/draft7/optional/ecmascript-regex.json | 260 +++++++++++++++++++++ tests/draft7/optional/format/date-time.json | 37 ++- tests/draft7/optional/format/date.json | 32 ++- tests/draft7/optional/format/email.json | 32 ++- tests/draft7/optional/format/hostname.json | 32 ++- tests/draft7/optional/format/idn-email.json | 32 ++- tests/draft7/optional/format/idn-hostname.json | 34 ++- tests/draft7/optional/format/ipv4.json | 32 ++- tests/draft7/optional/format/ipv6.json | 47 +++- tests/draft7/optional/format/iri-reference.json | 32 ++- tests/draft7/optional/format/iri.json | 32 ++- tests/draft7/optional/format/json-pointer.json | 32 ++- tests/draft7/optional/format/regex.json | 32 ++- .../optional/format/relative-json-pointer.json | 32 ++- tests/draft7/optional/format/time.json | 32 ++- tests/draft7/optional/format/uri-reference.json | 32 ++- tests/draft7/optional/format/uri-template.json | 32 ++- tests/draft7/optional/format/uri.json | 2 +- tests/draft7/optional/unicode.json | 146 ------------ tests/draft7/ref.json | 52 ++++- tox.ini | 2 +- 129 files changed, 5355 insertions(+), 1289 deletions(-) create mode 100644 remotes/draft2020-12/format-assertion-false.json create mode 100644 remotes/draft2020-12/format-assertion-true.json create mode 100644 tests/draft-future/optional/format-assertion.json delete mode 100644 tests/draft-future/optional/unicode.json delete mode 100644 tests/draft2019-09/optional/unicode.json create mode 100644 tests/draft2020-12/optional/format-assertion.json delete mode 100644 tests/draft2020-12/optional/unicode.json delete mode 100644 tests/draft4/optional/unicode.json delete mode 100644 tests/draft6/optional/unicode.json delete mode 100644 tests/draft7/optional/unicode.json diff --git a/remotes/draft2020-12/format-assertion-false.json b/remotes/draft2020-12/format-assertion-false.json new file mode 100644 index 0000000..f1c64d2 --- /dev/null +++ b/remotes/draft2020-12/format-assertion-false.json @@ -0,0 +1,12 @@ +{ + "$id": "http://localhost:1234/draft2020-12/format-assertion-false.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$vocabulary": { + "https://json-schema.org/draft/2020-12/vocab/core": true, + "https://json-schema.org/draft/2020-12/vocab/format-assertion": false + }, + "allOf": [ + { "$ref": "https://json-schema.org/draft/2020-12/schema/meta/core" }, + { "$ref": "https://json-schema.org/draft/2020-12/schema/meta/format-assertion" } + ] +} diff --git a/remotes/draft2020-12/format-assertion-true.json b/remotes/draft2020-12/format-assertion-true.json new file mode 100644 index 0000000..e3d12c8 --- /dev/null +++ b/remotes/draft2020-12/format-assertion-true.json @@ -0,0 +1,12 @@ +{ + "$id": "http://localhost:1234/draft2020-12/format-assertion-true.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$vocabulary": { + "https://json-schema.org/draft/2020-12/vocab/core": true, + "https://json-schema.org/draft/2020-12/vocab/format-assertion": true + }, + "allOf": [ + { "$ref": "https://json-schema.org/draft/2020-12/schema/meta/core" }, + { "$ref": "https://json-schema.org/draft/2020-12/schema/meta/format-assertion" } + ] +} diff --git a/tests/draft-future/anchor.json b/tests/draft-future/anchor.json index 045cdc3..416c224 100644 --- a/tests/draft-future/anchor.json +++ b/tests/draft-future/anchor.json @@ -134,5 +134,40 @@ "valid": false } ] + }, + { + "description": "same $anchor with different base uri", + "schema": { + "$id": "http://localhost:1234/foobar", + "$defs": { + "A": { + "$id": "child1", + "allOf": [ + { + "$id": "child2", + "$anchor": "my_anchor", + "type": "number" + }, + { + "$anchor": "my_anchor", + "type": "string" + } + ] + } + }, + "$ref": "child1#my_anchor" + }, + "tests": [ + { + "description": "$ref should resolve to /$defs/A/allOf/1", + "data": "a", + "valid": true + }, + { + "description": "$ref should not resolve to /$defs/A/allOf/0", + "data": 1, + "valid": false + } + ] } ] diff --git a/tests/draft-future/format.json b/tests/draft-future/format.json index f10b211..a4b51d2 100644 --- a/tests/draft-future/format.json +++ b/tests/draft-future/format.json @@ -32,11 +32,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid email string is only an annotation by default", - "data": "2962", - "valid": true } ] }, @@ -73,11 +68,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid idn-email string is only an annotation by default", - "data": "2962", - "valid": true } ] }, @@ -114,11 +104,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid regex string is only an annotation by default", - "data": "^(abc]", - "valid": true } ] }, @@ -155,11 +140,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid ipv4 string is only an annotation by default", - "data": "127.0.0.0.1", - "valid": true } ] }, @@ -196,11 +176,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid ipv6 string is only an annotation by default", - "data": "12345::", - "valid": true } ] }, @@ -237,11 +212,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid idn-hostname string is only an annotation by default", - "data": "〮실례.테스트", - "valid": true } ] }, @@ -278,11 +248,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid hostname string is only an annotation by default", - "data": "-a-host-name-that-starts-with--", - "valid": true } ] }, @@ -319,11 +284,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid date string is only an annotation by default", - "data": "06/19/1963", - "valid": true } ] }, @@ -360,11 +320,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid date-time string is only an annotation by default", - "data": "1990-02-31T15:59:60.123-08:00", - "valid": true } ] }, @@ -401,11 +356,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid time string is only an annotation by default", - "data": "08:30:06 PST", - "valid": true } ] }, @@ -442,11 +392,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid json-pointer string is only an annotation by default", - "data": "/foo/bar~", - "valid": true } ] }, @@ -483,11 +428,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid relative-json-pointer string is only an annotation by default", - "data": "/foo/bar", - "valid": true } ] }, @@ -524,11 +464,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid iri string is only an annotation by default", - "data": "http://2001:0db8:85a3:0000:0000:8a2e:0370:7334", - "valid": true } ] }, @@ -565,11 +500,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid iri-reference string is only an annotation by default", - "data": "\\\\WINDOWS\\filëßåré", - "valid": true } ] }, @@ -606,11 +536,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid uri string is only an annotation by default", - "data": "//foo.bar/?baz=qux#quux", - "valid": true } ] }, @@ -647,11 +572,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid uri-reference string is only an annotation by default", - "data": "\\\\WINDOWS\\fileshare", - "valid": true } ] }, @@ -688,11 +608,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid uri-template string is only an annotation by default", - "data": "http://example.com/dictionary/{term:1}/{term", - "valid": true } ] }, @@ -729,11 +644,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid uuid string is only an annotation by default", - "data": "2eb8aa08-aa98-11ea-b4aa-73b441d1638", - "valid": true } ] }, @@ -770,11 +680,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid duration string is only an annotation by default", - "data": "PT1D", - "valid": true } ] } diff --git a/tests/draft-future/optional/ecmascript-regex.json b/tests/draft-future/optional/ecmascript-regex.json index fb02e99..1beb0b3 100644 --- a/tests/draft-future/optional/ecmascript-regex.json +++ b/tests/draft-future/optional/ecmascript-regex.json @@ -288,5 +288,265 @@ "valid": true } ] + }, + { + "description": "unicode semantics should be used for all pattern matching", + "schema": { "pattern": "\\p{Letter}cole" }, + "tests": [ + { + "description": "ascii character in json string", + "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.", + "valid": true + }, + { + "description": "literal unicode character in json string", + "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.", + "valid": true + }, + { + "description": "unicode character in hex format in string", + "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.", + "valid": true + }, + { + "description": "unicode matching is case-sensitive", + "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.", + "valid": false + } + ] + }, + { + "description": "\\w in patterns matches [A-Za-z0-9_], not unicode letters", + "schema": { "pattern": "\\wcole" }, + "tests": [ + { + "description": "ascii character in json string", + "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.", + "valid": true + }, + { + "description": "literal unicode character in json string", + "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.", + "valid": false + }, + { + "description": "unicode character in hex format in string", + "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.", + "valid": false + }, + { + "description": "unicode matching is case-sensitive", + "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.", + "valid": false + } + ] + }, + { + "description": "unicode characters do not match ascii ranges", + "schema": { "pattern": "[a-z]cole" }, + "tests": [ + { + "description": "literal unicode character in json string", + "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.", + "valid": false + }, + { + "description": "unicode character in hex format in string", + "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.", + "valid": false + }, + { + "description": "ascii characters match", + "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.", + "valid": true + } + ] + }, + { + "description": "\\d in pattern matches [0-9], not unicode digits", + "schema": { "pattern": "^\\d+$" }, + "tests": [ + { + "description": "ascii digits", + "data": "42", + "valid": true + }, + { + "description": "ascii non-digits", + "data": "-%#", + "valid": false + }, + { + "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", + "data": "৪২", + "valid": false + } + ] + }, + { + "description": "unicode digits are more than 0 through 9", + "schema": { "pattern": "^\\p{digit}+$" }, + "tests": [ + { + "description": "ascii digits", + "data": "42", + "valid": true + }, + { + "description": "ascii non-digits", + "data": "-%#", + "valid": false + }, + { + "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", + "data": "৪২", + "valid": true + } + ] + }, + { + "description": "unicode semantics should be used for all patternProperties matching", + "schema": { + "type": "object", + "patternProperties": { + "\\p{Letter}cole": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "ascii character in json string", + "data": { "l'ecole": "pas de vraie vie" }, + "valid": true + }, + { + "description": "literal unicode character in json string", + "data": { "l'école": "pas de vraie vie" }, + "valid": true + }, + { + "description": "unicode character in hex format in string", + "data": { "l'\u00e9cole": "pas de vraie vie" }, + "valid": true + }, + { + "description": "unicode matching is case-sensitive", + "data": { "L'ÉCOLE": "PAS DE VRAIE VIE" }, + "valid": false + } + ] + }, + { + "description": "\\w in patternProperties matches [A-Za-z0-9_], not unicode letters", + "schema": { + "type": "object", + "patternProperties": { + "\\wcole": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "ascii character in json string", + "data": { "l'ecole": "pas de vraie vie" }, + "valid": true + }, + { + "description": "literal unicode character in json string", + "data": { "l'école": "pas de vraie vie" }, + "valid": false + }, + { + "description": "unicode character in hex format in string", + "data": { "l'\u00e9cole": "pas de vraie vie" }, + "valid": false + }, + { + "description": "unicode matching is case-sensitive", + "data": { "L'ÉCOLE": "PAS DE VRAIE VIE" }, + "valid": false + } + ] + }, + { + "description": "unicode characters do not match ascii ranges", + "schema": { + "type": "object", + "patternProperties": { + "[a-z]cole": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "literal unicode character in json string", + "data": { "l'école": "pas de vraie vie" }, + "valid": false + }, + { + "description": "unicode character in hex format in string", + "data": { "l'\u00e9cole": "pas de vraie vie" }, + "valid": false + }, + { + "description": "ascii characters match", + "data": { "l'ecole": "pas de vraie vie" }, + "valid": true + } + ] + }, + { + "description": "\\d in patternProperties matches [0-9], not unicode digits", + "schema": { + "type": "object", + "patternProperties": { + "^\\d+$": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "ascii digits", + "data": { "42": "life, the universe, and everything" }, + "valid": true + }, + { + "description": "ascii non-digits", + "data": { "-%#": "spending the year dead for tax reasons" }, + "valid": false + }, + { + "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", + "data": { "৪২": "khajit has wares if you have coin" }, + "valid": false + } + ] + }, + { + "description": "unicode digits are more than 0 through 9", + "schema": { + "type": "object", + "patternProperties": { + "^\\p{digit}+$": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "ascii digits", + "data": { "42": "life, the universe, and everything" }, + "valid": true + }, + { + "description": "ascii non-digits", + "data": { "-%#": "spending the year dead for tax reasons" }, + "valid": false + }, + { + "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", + "data": { "৪২": "khajit has wares if you have coin" }, + "valid": true + } + ] } ] diff --git a/tests/draft-future/optional/format-assertion.json b/tests/draft-future/optional/format-assertion.json new file mode 100644 index 0000000..0340037 --- /dev/null +++ b/tests/draft-future/optional/format-assertion.json @@ -0,0 +1,42 @@ +[ + { + "description": "schema that uses custom metaschema with format-assertion: false", + "schema": { + "$id": "https://schema/using/format-assertion/false", + "$schema": "http://localhost:1234/draft2020-12/format-assertion-false.json", + "format": "ipv4" + }, + "tests": [ + { + "description": "format-assertion: false: valid string", + "data": "127.0.0.1", + "valid": true + }, + { + "description": "format-assertion: false: invalid string", + "data": "not-an-ipv4", + "valid": false + } + ] + }, + { + "description": "schema that uses custom metaschema with format-assertion: true", + "schema": { + "$id": "https://schema/using/format-assertion/true", + "$schema": "http://localhost:1234/draft2020-12/format-assertion-true.json", + "format": "ipv4" + }, + "tests": [ + { + "description": "format-assertion: true: valid string", + "data": "127.0.0.1", + "valid": true + }, + { + "description": "format-assertion: true: invalid string", + "data": "not-an-ipv4", + "valid": false + } + ] + } +] diff --git a/tests/draft-future/optional/format/date-time.json b/tests/draft-future/optional/format/date-time.json index 5f911ef..119179c 100644 --- a/tests/draft-future/optional/format/date-time.json +++ b/tests/draft-future/optional/format/date-time.json @@ -1,8 +1,38 @@ [ { "description": "validation of date-time strings", - "schema": {"format": "date-time"}, + "schema": { "format": "date-time" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid date-time string", "data": "1963-06-19T08:30:06.283185Z", @@ -33,6 +63,11 @@ "data": "1990-12-31T15:59:60-24:00", "valid": false }, + { + "description": "an invalid closing Z after time-zone offset", + "data": "1963-06-19T08:30:06.28123+01:00Z", + "valid": false + }, { "description": "an invalid date-time string", "data": "06/19/1963 08:30:06 PST", diff --git a/tests/draft-future/optional/format/date.json b/tests/draft-future/optional/format/date.json index 6cc2feb..b4f61ee 100644 --- a/tests/draft-future/optional/format/date.json +++ b/tests/draft-future/optional/format/date.json @@ -1,8 +1,38 @@ [ { "description": "validation of date strings", - "schema": {"format": "date"}, + "schema": { "format": "date" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid date string", "data": "1963-06-19", diff --git a/tests/draft-future/optional/format/duration.json b/tests/draft-future/optional/format/duration.json index eb33dbb..741348a 100644 --- a/tests/draft-future/optional/format/duration.json +++ b/tests/draft-future/optional/format/duration.json @@ -1,8 +1,38 @@ [ { "description": "validation of duration strings", - "schema": {"format": "duration"}, + "schema": { "format": "duration" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid duration string", "data": "P4DT12H30M5S", diff --git a/tests/draft-future/optional/format/email.json b/tests/draft-future/optional/format/email.json index 02396d2..d6761a4 100644 --- a/tests/draft-future/optional/format/email.json +++ b/tests/draft-future/optional/format/email.json @@ -1,8 +1,38 @@ [ { "description": "validation of e-mail addresses", - "schema": {"format": "email"}, + "schema": { "format": "email" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid e-mail address", "data": "joe.bloggs@example.com", diff --git a/tests/draft-future/optional/format/hostname.json b/tests/draft-future/optional/format/hostname.json index 476541a..8a67fda 100644 --- a/tests/draft-future/optional/format/hostname.json +++ b/tests/draft-future/optional/format/hostname.json @@ -1,8 +1,38 @@ [ { "description": "validation of host names", - "schema": {"format": "hostname"}, + "schema": { "format": "hostname" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid host name", "data": "www.example.com", diff --git a/tests/draft-future/optional/format/idn-email.json b/tests/draft-future/optional/format/idn-email.json index 552d106..6e21374 100644 --- a/tests/draft-future/optional/format/idn-email.json +++ b/tests/draft-future/optional/format/idn-email.json @@ -1,8 +1,38 @@ [ { "description": "validation of an internationalized e-mail addresses", - "schema": {"format": "idn-email"}, + "schema": { "format": "idn-email" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid idn e-mail (example@example.test in Hangul)", "data": "실례@실례.테스트", diff --git a/tests/draft-future/optional/format/idn-hostname.json b/tests/draft-future/optional/format/idn-hostname.json index bbb257b..6c8f86a 100644 --- a/tests/draft-future/optional/format/idn-hostname.json +++ b/tests/draft-future/optional/format/idn-hostname.json @@ -3,6 +3,36 @@ "description": "validation of internationalized host names", "schema": { "format": "idn-hostname" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid host name (example.test in Hangul)", "data": "실례.테스트", diff --git a/tests/draft-future/optional/format/ipv4.json b/tests/draft-future/optional/format/ipv4.json index 4d10927..6b166c7 100644 --- a/tests/draft-future/optional/format/ipv4.json +++ b/tests/draft-future/optional/format/ipv4.json @@ -1,8 +1,38 @@ [ { "description": "validation of IP addresses", - "schema": {"format": "ipv4"}, + "schema": { "format": "ipv4" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid IP address", "data": "192.168.0.1", diff --git a/tests/draft-future/optional/format/ipv6.json b/tests/draft-future/optional/format/ipv6.json index cf629c6..6379927 100644 --- a/tests/draft-future/optional/format/ipv6.json +++ b/tests/draft-future/optional/format/ipv6.json @@ -1,8 +1,38 @@ [ { "description": "validation of IPv6 addresses", - "schema": {"format": "ipv6"}, + "schema": { "format": "ipv6" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid IPv6 address", "data": "::1", @@ -13,6 +43,16 @@ "data": "12345::", "valid": false }, + { + "description": "trailing 4 hex symbols is valid", + "data": "::abef", + "valid": true + }, + { + "description": "trailing 5 hex symbols is invalid", + "data": "::abcef", + "valid": false + }, { "description": "an IPv6 address with too many components", "data": "1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1", @@ -53,6 +93,11 @@ "data": ":2:3:4::8", "valid": false }, + { + "description": "single set of double colons in the middle is valid", + "data": "1:d6::42", + "valid": true + }, { "description": "two sets of double colons is invalid", "data": "1::d6::42", diff --git a/tests/draft-future/optional/format/iri-reference.json b/tests/draft-future/optional/format/iri-reference.json index 1fd779c..c6b4c22 100644 --- a/tests/draft-future/optional/format/iri-reference.json +++ b/tests/draft-future/optional/format/iri-reference.json @@ -1,8 +1,38 @@ [ { "description": "validation of IRI References", - "schema": {"format": "iri-reference"}, + "schema": { "format": "iri-reference" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid IRI", "data": "http://ƒøø.ßår/?∂éœ=πîx#πîüx", diff --git a/tests/draft-future/optional/format/iri.json b/tests/draft-future/optional/format/iri.json index 1414f2e..a0d12ae 100644 --- a/tests/draft-future/optional/format/iri.json +++ b/tests/draft-future/optional/format/iri.json @@ -1,8 +1,38 @@ [ { "description": "validation of IRIs", - "schema": {"format": "iri"}, + "schema": { "format": "iri" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid IRI with anchor tag", "data": "http://ƒøø.ßår/?∂éœ=πîx#πîüx", diff --git a/tests/draft-future/optional/format/json-pointer.json b/tests/draft-future/optional/format/json-pointer.json index 65c2f06..a0346b5 100644 --- a/tests/draft-future/optional/format/json-pointer.json +++ b/tests/draft-future/optional/format/json-pointer.json @@ -1,8 +1,38 @@ [ { "description": "validation of JSON-pointers (JSON String Representation)", - "schema": {"format": "json-pointer"}, + "schema": { "format": "json-pointer" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid JSON-pointer", "data": "/foo/bar~0/baz~1/%a", diff --git a/tests/draft-future/optional/format/regex.json b/tests/draft-future/optional/format/regex.json index d99d021..3449177 100644 --- a/tests/draft-future/optional/format/regex.json +++ b/tests/draft-future/optional/format/regex.json @@ -1,8 +1,38 @@ [ { "description": "validation of regular expressions", - "schema": {"format": "regex"}, + "schema": { "format": "regex" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid regular expression", "data": "([abc])+\\s+$", diff --git a/tests/draft-future/optional/format/relative-json-pointer.json b/tests/draft-future/optional/format/relative-json-pointer.json index 22fb14e..9309986 100644 --- a/tests/draft-future/optional/format/relative-json-pointer.json +++ b/tests/draft-future/optional/format/relative-json-pointer.json @@ -1,8 +1,38 @@ [ { "description": "validation of Relative JSON Pointers (RJP)", - "schema": {"format": "relative-json-pointer"}, + "schema": { "format": "relative-json-pointer" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid upwards RJP", "data": "1", diff --git a/tests/draft-future/optional/format/time.json b/tests/draft-future/optional/format/time.json index 0a8da0e..5011d78 100644 --- a/tests/draft-future/optional/format/time.json +++ b/tests/draft-future/optional/format/time.json @@ -1,8 +1,38 @@ [ { "description": "validation of time strings", - "schema": {"format": "time"}, + "schema": { "format": "time" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid time string", "data": "08:30:06Z", diff --git a/tests/draft-future/optional/format/uri-reference.json b/tests/draft-future/optional/format/uri-reference.json index e4c9eef..7cdf228 100644 --- a/tests/draft-future/optional/format/uri-reference.json +++ b/tests/draft-future/optional/format/uri-reference.json @@ -1,8 +1,38 @@ [ { "description": "validation of URI References", - "schema": {"format": "uri-reference"}, + "schema": { "format": "uri-reference" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid URI", "data": "http://foo.bar/?baz=qux#quux", diff --git a/tests/draft-future/optional/format/uri-template.json b/tests/draft-future/optional/format/uri-template.json index 33ab76e..df355c5 100644 --- a/tests/draft-future/optional/format/uri-template.json +++ b/tests/draft-future/optional/format/uri-template.json @@ -1,8 +1,38 @@ [ { "description": "format: uri-template", - "schema": {"format": "uri-template"}, + "schema": { "format": "uri-template" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid uri-template", "data": "http://example.com/dictionary/{term:1}/{term}", diff --git a/tests/draft-future/optional/format/uri.json b/tests/draft-future/optional/format/uri.json index 58d3085..792d71a 100644 --- a/tests/draft-future/optional/format/uri.json +++ b/tests/draft-future/optional/format/uri.json @@ -1,7 +1,7 @@ [ { "description": "validation of URIs", - "schema": {"format": "uri"}, + "schema": { "format": "uri" }, "tests": [ { "description": "a valid URL with anchor tag", diff --git a/tests/draft-future/optional/unicode.json b/tests/draft-future/optional/unicode.json deleted file mode 100644 index 1dc5940..0000000 --- a/tests/draft-future/optional/unicode.json +++ /dev/null @@ -1,146 +0,0 @@ -[ - { - "description": "unicode semantics should be used for all pattern matching", - "schema": { "pattern": "\\wcole" }, - "tests": [ - { - "description": "literal unicode character in json string", - "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.", - "valid": true - }, - { - "description": "unicode character in hex format in string", - "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.", - "valid": true - }, - { - "description": "unicode matching is case-sensitive", - "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.", - "valid": false - } - ] - }, - { - "description": "unicode characters do not match ascii ranges", - "schema": { "pattern": "[a-z]cole" }, - "tests": [ - { - "description": "literal unicode character in json string", - "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.", - "valid": false - }, - { - "description": "unicode character in hex format in string", - "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.", - "valid": false - }, - { - "description": "ascii characters match", - "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.", - "valid": true - } - ] - }, - { - "description": "unicode digits are more than 0 through 9", - "schema": { "pattern": "^\\d+$" }, - "tests": [ - { - "description": "ascii digits", - "data": "42", - "valid": true - }, - { - "description": "ascii non-digits", - "data": "-%#", - "valid": false - }, - { - "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", - "data": "৪২", - "valid": true - } - ] - }, - { - "description": "unicode semantics should be used for all patternProperties matching", - "schema": { - "type": "object", - "patternProperties": { - "\\wcole": true - }, - "additionalProperties": false - }, - "tests": [ - { - "description": "literal unicode character in json string", - "data": { "l'école": "pas de vraie vie" }, - "valid": true - }, - { - "description": "unicode character in hex format in string", - "data": { "l'\u00e9cole": "pas de vraie vie" }, - "valid": true - }, - { - "description": "unicode matching is case-sensitive", - "data": { "L'ÉCOLE": "PAS DE VRAIE VIE" }, - "valid": false - } - ] - }, - { - "description": "unicode characters do not match ascii ranges", - "schema": { - "type": "object", - "patternProperties": { - "[a-z]cole": true - }, - "additionalProperties": false - }, - "tests": [ - { - "description": "literal unicode character in json string", - "data": { "l'école": "pas de vraie vie" }, - "valid": false - }, - { - "description": "unicode character in hex format in string", - "data": { "l'\u00e9cole": "pas de vraie vie" }, - "valid": false - }, - { - "description": "ascii characters match", - "data": { "l'ecole": "pas de vraie vie" }, - "valid": true - } - ] - }, - { - "description": "unicode digits are more than 0 through 9", - "schema": { - "type": "object", - "patternProperties": { - "^\\d+$": true - }, - "additionalProperties": false - }, - "tests": [ - { - "description": "ascii digits", - "data": { "42": "life, the universe, and everything" }, - "valid": true - }, - { - "description": "ascii non-digits", - "data": { "-%#": "spending the year dead for tax reasons" }, - "valid": false - }, - { - "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", - "data": { "৪২": "khajit has wares if you have coin" }, - "valid": true - } - ] - } -] diff --git a/tests/draft-future/ref.json b/tests/draft-future/ref.json index e42ef6d..4bb12f5 100644 --- a/tests/draft-future/ref.json +++ b/tests/draft-future/ref.json @@ -541,5 +541,41 @@ "valid": true } ] + }, + { + "description": "$id must be resolved against nearest parent, not just immediate parent", + "schema": { + "$id": "http://example.com/a.json", + "$defs": { + "x": { + "$id": "http://example.com/b/c.json", + "not": { + "$defs": { + "y": { + "$id": "d.json", + "type": "number" + } + } + } + } + }, + "allOf": [ + { + "$ref": "http://example.com/b/d.json" + } + ] + }, + "tests": [ + { + "description": "number should pass", + "data": 1, + "valid": true + }, + { + "description": "non-number should fail", + "data": "a", + "valid": false + } + ] } ] diff --git a/tests/draft-future/unevaluatedProperties.json b/tests/draft-future/unevaluatedProperties.json index 7a5f3f9..bfcb79d 100644 --- a/tests/draft-future/unevaluatedProperties.json +++ b/tests/draft-future/unevaluatedProperties.json @@ -1058,6 +1058,256 @@ } ] }, + { + "description": "unevaluatedProperties + single cyclic ref", + "schema": { + "type": "object", + "properties": { + "x": { "$ref": "#" } + }, + "unevaluatedProperties": false + }, + "tests": [ + { + "description": "Empty is valid", + "data": {}, + "valid": true + }, + { + "description": "Single is valid", + "data": { "x": {} }, + "valid": true + }, + { + "description": "Unevaluated on 1st level is invalid", + "data": { "x": {}, "y": {} }, + "valid": false + }, + { + "description": "Nested is valid", + "data": { "x": { "x": {} } }, + "valid": true + }, + { + "description": "Unevaluated on 2nd level is invalid", + "data": { "x": { "x": {}, "y": {} } }, + "valid": false + }, + { + "description": "Deep nested is valid", + "data": { "x": { "x": { "x": {} } } }, + "valid": true + }, + { + "description": "Unevaluated on 3rd level is invalid", + "data": { "x": { "x": { "x": {}, "y": {} } } }, + "valid": false + } + ] + }, + { + "description": "unevaluatedProperties + ref inside allOf / oneOf", + "schema": { + "$defs": { + "one": { + "properties": { "a": true } + }, + "two": { + "required": ["x"], + "properties": { "x": true } + } + }, + "allOf": [ + { "$ref": "#/$defs/one" }, + { "properties": { "b": true } }, + { + "oneOf": [ + { "$ref": "#/$defs/two" }, + { + "required": ["y"], + "properties": { "y": true } + } + ] + } + ], + "unevaluatedProperties": false + }, + "tests": [ + { + "description": "Empty is invalid (no x or y)", + "data": {}, + "valid": false + }, + { + "description": "a and b are invalid (no x or y)", + "data": { "a": 1, "b": 1 }, + "valid": false + }, + { + "description": "x and y are invalid", + "data": { "x": 1, "y": 1 }, + "valid": false + }, + { + "description": "a and x are valid", + "data": { "a": 1, "x": 1 }, + "valid": true + }, + { + "description": "a and y are valid", + "data": { "a": 1, "y": 1 }, + "valid": true + }, + { + "description": "a and b and x are valid", + "data": { "a": 1, "b": 1, "x": 1 }, + "valid": true + }, + { + "description": "a and b and y are valid", + "data": { "a": 1, "b": 1, "y": 1 }, + "valid": true + }, + { + "description": "a and b and x and y are invalid", + "data": { "a": 1, "b": 1, "x": 1, "y": 1 }, + "valid": false + } + ] + }, + { + "description": "dynamic evalation inside nested refs", + "schema": { + "$defs": { + "one": { + "oneOf": [ + { "$ref": "#/$defs/two" }, + { "required": ["b"], "properties": { "b": true } }, + { "required": ["xx"], "patternProperties": { "x": true } }, + { "required": ["all"], "unevaluatedProperties": true } + ] + }, + "two": { + "oneOf": [ + { "required": ["c"], "properties": { "c": true } }, + { "required": ["d"], "properties": { "d": true } } + ] + } + }, + "oneOf": [ + { "$ref": "#/$defs/one" }, + { "required": ["a"], "properties": { "a": true } } + ], + "unevaluatedProperties": false + }, + "tests": [ + { + "description": "Empty is invalid", + "data": {}, + "valid": false + }, + { + "description": "a is valid", + "data": { "a": 1 }, + "valid": true + }, + { + "description": "b is valid", + "data": { "b": 1 }, + "valid": true + }, + { + "description": "c is valid", + "data": { "c": 1 }, + "valid": true + }, + { + "description": "d is valid", + "data": { "d": 1 }, + "valid": true + }, + { + "description": "a + b is invalid", + "data": { "a": 1, "b": 1 }, + "valid": false + }, + { + "description": "a + c is invalid", + "data": { "a": 1, "c": 1 }, + "valid": false + }, + { + "description": "a + d is invalid", + "data": { "a": 1, "d": 1 }, + "valid": false + }, + { + "description": "b + c is invalid", + "data": { "b": 1, "c": 1 }, + "valid": false + }, + { + "description": "b + d is invalid", + "data": { "b": 1, "d": 1 }, + "valid": false + }, + { + "description": "c + d is invalid", + "data": { "c": 1, "d": 1 }, + "valid": false + }, + { + "description": "xx is valid", + "data": { "xx": 1 }, + "valid": true + }, + { + "description": "xx + foox is valid", + "data": { "xx": 1, "foox": 1 }, + "valid": true + }, + { + "description": "xx + foo is invalid", + "data": { "xx": 1, "foo": 1 }, + "valid": false + }, + { + "description": "xx + a is invalid", + "data": { "xx": 1, "a": 1 }, + "valid": false + }, + { + "description": "xx + b is invalid", + "data": { "xx": 1, "b": 1 }, + "valid": false + }, + { + "description": "xx + c is invalid", + "data": { "xx": 1, "c": 1 }, + "valid": false + }, + { + "description": "xx + d is invalid", + "data": { "xx": 1, "d": 1 }, + "valid": false + }, + { + "description": "all is valid", + "data": { "all": 1 }, + "valid": true + }, + { + "description": "all + foo is valid", + "data": { "all": 1, "foo": 1 }, + "valid": true + }, + { + "description": "all + a is invalid", + "data": { "all": 1, "a": 1 }, + "valid": false + } + ] + }, { "description": "unevaluatedProperties depends on adjacent contains", "schema": { diff --git a/tests/draft2019-09/anchor.json b/tests/draft2019-09/anchor.json index 045cdc3..416c224 100644 --- a/tests/draft2019-09/anchor.json +++ b/tests/draft2019-09/anchor.json @@ -134,5 +134,40 @@ "valid": false } ] + }, + { + "description": "same $anchor with different base uri", + "schema": { + "$id": "http://localhost:1234/foobar", + "$defs": { + "A": { + "$id": "child1", + "allOf": [ + { + "$id": "child2", + "$anchor": "my_anchor", + "type": "number" + }, + { + "$anchor": "my_anchor", + "type": "string" + } + ] + } + }, + "$ref": "child1#my_anchor" + }, + "tests": [ + { + "description": "$ref should resolve to /$defs/A/allOf/1", + "data": "a", + "valid": true + }, + { + "description": "$ref should not resolve to /$defs/A/allOf/0", + "data": 1, + "valid": false + } + ] } ] diff --git a/tests/draft2019-09/format.json b/tests/draft2019-09/format.json index f10b211..a4b51d2 100644 --- a/tests/draft2019-09/format.json +++ b/tests/draft2019-09/format.json @@ -32,11 +32,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid email string is only an annotation by default", - "data": "2962", - "valid": true } ] }, @@ -73,11 +68,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid idn-email string is only an annotation by default", - "data": "2962", - "valid": true } ] }, @@ -114,11 +104,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid regex string is only an annotation by default", - "data": "^(abc]", - "valid": true } ] }, @@ -155,11 +140,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid ipv4 string is only an annotation by default", - "data": "127.0.0.0.1", - "valid": true } ] }, @@ -196,11 +176,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid ipv6 string is only an annotation by default", - "data": "12345::", - "valid": true } ] }, @@ -237,11 +212,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid idn-hostname string is only an annotation by default", - "data": "〮실례.테스트", - "valid": true } ] }, @@ -278,11 +248,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid hostname string is only an annotation by default", - "data": "-a-host-name-that-starts-with--", - "valid": true } ] }, @@ -319,11 +284,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid date string is only an annotation by default", - "data": "06/19/1963", - "valid": true } ] }, @@ -360,11 +320,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid date-time string is only an annotation by default", - "data": "1990-02-31T15:59:60.123-08:00", - "valid": true } ] }, @@ -401,11 +356,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid time string is only an annotation by default", - "data": "08:30:06 PST", - "valid": true } ] }, @@ -442,11 +392,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid json-pointer string is only an annotation by default", - "data": "/foo/bar~", - "valid": true } ] }, @@ -483,11 +428,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid relative-json-pointer string is only an annotation by default", - "data": "/foo/bar", - "valid": true } ] }, @@ -524,11 +464,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid iri string is only an annotation by default", - "data": "http://2001:0db8:85a3:0000:0000:8a2e:0370:7334", - "valid": true } ] }, @@ -565,11 +500,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid iri-reference string is only an annotation by default", - "data": "\\\\WINDOWS\\filëßåré", - "valid": true } ] }, @@ -606,11 +536,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid uri string is only an annotation by default", - "data": "//foo.bar/?baz=qux#quux", - "valid": true } ] }, @@ -647,11 +572,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid uri-reference string is only an annotation by default", - "data": "\\\\WINDOWS\\fileshare", - "valid": true } ] }, @@ -688,11 +608,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid uri-template string is only an annotation by default", - "data": "http://example.com/dictionary/{term:1}/{term", - "valid": true } ] }, @@ -729,11 +644,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid uuid string is only an annotation by default", - "data": "2eb8aa08-aa98-11ea-b4aa-73b441d1638", - "valid": true } ] }, @@ -770,11 +680,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid duration string is only an annotation by default", - "data": "PT1D", - "valid": true } ] } diff --git a/tests/draft2019-09/optional/ecmascript-regex.json b/tests/draft2019-09/optional/ecmascript-regex.json index fb02e99..1beb0b3 100644 --- a/tests/draft2019-09/optional/ecmascript-regex.json +++ b/tests/draft2019-09/optional/ecmascript-regex.json @@ -288,5 +288,265 @@ "valid": true } ] + }, + { + "description": "unicode semantics should be used for all pattern matching", + "schema": { "pattern": "\\p{Letter}cole" }, + "tests": [ + { + "description": "ascii character in json string", + "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.", + "valid": true + }, + { + "description": "literal unicode character in json string", + "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.", + "valid": true + }, + { + "description": "unicode character in hex format in string", + "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.", + "valid": true + }, + { + "description": "unicode matching is case-sensitive", + "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.", + "valid": false + } + ] + }, + { + "description": "\\w in patterns matches [A-Za-z0-9_], not unicode letters", + "schema": { "pattern": "\\wcole" }, + "tests": [ + { + "description": "ascii character in json string", + "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.", + "valid": true + }, + { + "description": "literal unicode character in json string", + "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.", + "valid": false + }, + { + "description": "unicode character in hex format in string", + "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.", + "valid": false + }, + { + "description": "unicode matching is case-sensitive", + "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.", + "valid": false + } + ] + }, + { + "description": "unicode characters do not match ascii ranges", + "schema": { "pattern": "[a-z]cole" }, + "tests": [ + { + "description": "literal unicode character in json string", + "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.", + "valid": false + }, + { + "description": "unicode character in hex format in string", + "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.", + "valid": false + }, + { + "description": "ascii characters match", + "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.", + "valid": true + } + ] + }, + { + "description": "\\d in pattern matches [0-9], not unicode digits", + "schema": { "pattern": "^\\d+$" }, + "tests": [ + { + "description": "ascii digits", + "data": "42", + "valid": true + }, + { + "description": "ascii non-digits", + "data": "-%#", + "valid": false + }, + { + "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", + "data": "৪২", + "valid": false + } + ] + }, + { + "description": "unicode digits are more than 0 through 9", + "schema": { "pattern": "^\\p{digit}+$" }, + "tests": [ + { + "description": "ascii digits", + "data": "42", + "valid": true + }, + { + "description": "ascii non-digits", + "data": "-%#", + "valid": false + }, + { + "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", + "data": "৪২", + "valid": true + } + ] + }, + { + "description": "unicode semantics should be used for all patternProperties matching", + "schema": { + "type": "object", + "patternProperties": { + "\\p{Letter}cole": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "ascii character in json string", + "data": { "l'ecole": "pas de vraie vie" }, + "valid": true + }, + { + "description": "literal unicode character in json string", + "data": { "l'école": "pas de vraie vie" }, + "valid": true + }, + { + "description": "unicode character in hex format in string", + "data": { "l'\u00e9cole": "pas de vraie vie" }, + "valid": true + }, + { + "description": "unicode matching is case-sensitive", + "data": { "L'ÉCOLE": "PAS DE VRAIE VIE" }, + "valid": false + } + ] + }, + { + "description": "\\w in patternProperties matches [A-Za-z0-9_], not unicode letters", + "schema": { + "type": "object", + "patternProperties": { + "\\wcole": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "ascii character in json string", + "data": { "l'ecole": "pas de vraie vie" }, + "valid": true + }, + { + "description": "literal unicode character in json string", + "data": { "l'école": "pas de vraie vie" }, + "valid": false + }, + { + "description": "unicode character in hex format in string", + "data": { "l'\u00e9cole": "pas de vraie vie" }, + "valid": false + }, + { + "description": "unicode matching is case-sensitive", + "data": { "L'ÉCOLE": "PAS DE VRAIE VIE" }, + "valid": false + } + ] + }, + { + "description": "unicode characters do not match ascii ranges", + "schema": { + "type": "object", + "patternProperties": { + "[a-z]cole": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "literal unicode character in json string", + "data": { "l'école": "pas de vraie vie" }, + "valid": false + }, + { + "description": "unicode character in hex format in string", + "data": { "l'\u00e9cole": "pas de vraie vie" }, + "valid": false + }, + { + "description": "ascii characters match", + "data": { "l'ecole": "pas de vraie vie" }, + "valid": true + } + ] + }, + { + "description": "\\d in patternProperties matches [0-9], not unicode digits", + "schema": { + "type": "object", + "patternProperties": { + "^\\d+$": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "ascii digits", + "data": { "42": "life, the universe, and everything" }, + "valid": true + }, + { + "description": "ascii non-digits", + "data": { "-%#": "spending the year dead for tax reasons" }, + "valid": false + }, + { + "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", + "data": { "৪২": "khajit has wares if you have coin" }, + "valid": false + } + ] + }, + { + "description": "unicode digits are more than 0 through 9", + "schema": { + "type": "object", + "patternProperties": { + "^\\p{digit}+$": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "ascii digits", + "data": { "42": "life, the universe, and everything" }, + "valid": true + }, + { + "description": "ascii non-digits", + "data": { "-%#": "spending the year dead for tax reasons" }, + "valid": false + }, + { + "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", + "data": { "৪২": "khajit has wares if you have coin" }, + "valid": true + } + ] } ] diff --git a/tests/draft2019-09/optional/format/date-time.json b/tests/draft2019-09/optional/format/date-time.json index 5f911ef..119179c 100644 --- a/tests/draft2019-09/optional/format/date-time.json +++ b/tests/draft2019-09/optional/format/date-time.json @@ -1,8 +1,38 @@ [ { "description": "validation of date-time strings", - "schema": {"format": "date-time"}, + "schema": { "format": "date-time" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid date-time string", "data": "1963-06-19T08:30:06.283185Z", @@ -33,6 +63,11 @@ "data": "1990-12-31T15:59:60-24:00", "valid": false }, + { + "description": "an invalid closing Z after time-zone offset", + "data": "1963-06-19T08:30:06.28123+01:00Z", + "valid": false + }, { "description": "an invalid date-time string", "data": "06/19/1963 08:30:06 PST", diff --git a/tests/draft2019-09/optional/format/date.json b/tests/draft2019-09/optional/format/date.json index 6cc2feb..b4f61ee 100644 --- a/tests/draft2019-09/optional/format/date.json +++ b/tests/draft2019-09/optional/format/date.json @@ -1,8 +1,38 @@ [ { "description": "validation of date strings", - "schema": {"format": "date"}, + "schema": { "format": "date" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid date string", "data": "1963-06-19", diff --git a/tests/draft2019-09/optional/format/duration.json b/tests/draft2019-09/optional/format/duration.json index eb33dbb..741348a 100644 --- a/tests/draft2019-09/optional/format/duration.json +++ b/tests/draft2019-09/optional/format/duration.json @@ -1,8 +1,38 @@ [ { "description": "validation of duration strings", - "schema": {"format": "duration"}, + "schema": { "format": "duration" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid duration string", "data": "P4DT12H30M5S", diff --git a/tests/draft2019-09/optional/format/email.json b/tests/draft2019-09/optional/format/email.json index 02396d2..d6761a4 100644 --- a/tests/draft2019-09/optional/format/email.json +++ b/tests/draft2019-09/optional/format/email.json @@ -1,8 +1,38 @@ [ { "description": "validation of e-mail addresses", - "schema": {"format": "email"}, + "schema": { "format": "email" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid e-mail address", "data": "joe.bloggs@example.com", diff --git a/tests/draft2019-09/optional/format/hostname.json b/tests/draft2019-09/optional/format/hostname.json index 476541a..8a67fda 100644 --- a/tests/draft2019-09/optional/format/hostname.json +++ b/tests/draft2019-09/optional/format/hostname.json @@ -1,8 +1,38 @@ [ { "description": "validation of host names", - "schema": {"format": "hostname"}, + "schema": { "format": "hostname" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid host name", "data": "www.example.com", diff --git a/tests/draft2019-09/optional/format/idn-email.json b/tests/draft2019-09/optional/format/idn-email.json index 552d106..6e21374 100644 --- a/tests/draft2019-09/optional/format/idn-email.json +++ b/tests/draft2019-09/optional/format/idn-email.json @@ -1,8 +1,38 @@ [ { "description": "validation of an internationalized e-mail addresses", - "schema": {"format": "idn-email"}, + "schema": { "format": "idn-email" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid idn e-mail (example@example.test in Hangul)", "data": "실례@실례.테스트", diff --git a/tests/draft2019-09/optional/format/idn-hostname.json b/tests/draft2019-09/optional/format/idn-hostname.json index bbb257b..6c8f86a 100644 --- a/tests/draft2019-09/optional/format/idn-hostname.json +++ b/tests/draft2019-09/optional/format/idn-hostname.json @@ -3,6 +3,36 @@ "description": "validation of internationalized host names", "schema": { "format": "idn-hostname" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid host name (example.test in Hangul)", "data": "실례.테스트", diff --git a/tests/draft2019-09/optional/format/ipv4.json b/tests/draft2019-09/optional/format/ipv4.json index 4d10927..6b166c7 100644 --- a/tests/draft2019-09/optional/format/ipv4.json +++ b/tests/draft2019-09/optional/format/ipv4.json @@ -1,8 +1,38 @@ [ { "description": "validation of IP addresses", - "schema": {"format": "ipv4"}, + "schema": { "format": "ipv4" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid IP address", "data": "192.168.0.1", diff --git a/tests/draft2019-09/optional/format/ipv6.json b/tests/draft2019-09/optional/format/ipv6.json index cf629c6..6379927 100644 --- a/tests/draft2019-09/optional/format/ipv6.json +++ b/tests/draft2019-09/optional/format/ipv6.json @@ -1,8 +1,38 @@ [ { "description": "validation of IPv6 addresses", - "schema": {"format": "ipv6"}, + "schema": { "format": "ipv6" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid IPv6 address", "data": "::1", @@ -13,6 +43,16 @@ "data": "12345::", "valid": false }, + { + "description": "trailing 4 hex symbols is valid", + "data": "::abef", + "valid": true + }, + { + "description": "trailing 5 hex symbols is invalid", + "data": "::abcef", + "valid": false + }, { "description": "an IPv6 address with too many components", "data": "1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1", @@ -53,6 +93,11 @@ "data": ":2:3:4::8", "valid": false }, + { + "description": "single set of double colons in the middle is valid", + "data": "1:d6::42", + "valid": true + }, { "description": "two sets of double colons is invalid", "data": "1::d6::42", diff --git a/tests/draft2019-09/optional/format/iri-reference.json b/tests/draft2019-09/optional/format/iri-reference.json index 1fd779c..c6b4c22 100644 --- a/tests/draft2019-09/optional/format/iri-reference.json +++ b/tests/draft2019-09/optional/format/iri-reference.json @@ -1,8 +1,38 @@ [ { "description": "validation of IRI References", - "schema": {"format": "iri-reference"}, + "schema": { "format": "iri-reference" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid IRI", "data": "http://ƒøø.ßår/?∂éœ=πîx#πîüx", diff --git a/tests/draft2019-09/optional/format/iri.json b/tests/draft2019-09/optional/format/iri.json index 1414f2e..a0d12ae 100644 --- a/tests/draft2019-09/optional/format/iri.json +++ b/tests/draft2019-09/optional/format/iri.json @@ -1,8 +1,38 @@ [ { "description": "validation of IRIs", - "schema": {"format": "iri"}, + "schema": { "format": "iri" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid IRI with anchor tag", "data": "http://ƒøø.ßår/?∂éœ=πîx#πîüx", diff --git a/tests/draft2019-09/optional/format/json-pointer.json b/tests/draft2019-09/optional/format/json-pointer.json index 65c2f06..a0346b5 100644 --- a/tests/draft2019-09/optional/format/json-pointer.json +++ b/tests/draft2019-09/optional/format/json-pointer.json @@ -1,8 +1,38 @@ [ { "description": "validation of JSON-pointers (JSON String Representation)", - "schema": {"format": "json-pointer"}, + "schema": { "format": "json-pointer" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid JSON-pointer", "data": "/foo/bar~0/baz~1/%a", diff --git a/tests/draft2019-09/optional/format/regex.json b/tests/draft2019-09/optional/format/regex.json index d99d021..3449177 100644 --- a/tests/draft2019-09/optional/format/regex.json +++ b/tests/draft2019-09/optional/format/regex.json @@ -1,8 +1,38 @@ [ { "description": "validation of regular expressions", - "schema": {"format": "regex"}, + "schema": { "format": "regex" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid regular expression", "data": "([abc])+\\s+$", diff --git a/tests/draft2019-09/optional/format/relative-json-pointer.json b/tests/draft2019-09/optional/format/relative-json-pointer.json index 22fb14e..9309986 100644 --- a/tests/draft2019-09/optional/format/relative-json-pointer.json +++ b/tests/draft2019-09/optional/format/relative-json-pointer.json @@ -1,8 +1,38 @@ [ { "description": "validation of Relative JSON Pointers (RJP)", - "schema": {"format": "relative-json-pointer"}, + "schema": { "format": "relative-json-pointer" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid upwards RJP", "data": "1", diff --git a/tests/draft2019-09/optional/format/time.json b/tests/draft2019-09/optional/format/time.json index 0a8da0e..5011d78 100644 --- a/tests/draft2019-09/optional/format/time.json +++ b/tests/draft2019-09/optional/format/time.json @@ -1,8 +1,38 @@ [ { "description": "validation of time strings", - "schema": {"format": "time"}, + "schema": { "format": "time" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid time string", "data": "08:30:06Z", diff --git a/tests/draft2019-09/optional/format/uri-reference.json b/tests/draft2019-09/optional/format/uri-reference.json index e4c9eef..7cdf228 100644 --- a/tests/draft2019-09/optional/format/uri-reference.json +++ b/tests/draft2019-09/optional/format/uri-reference.json @@ -1,8 +1,38 @@ [ { "description": "validation of URI References", - "schema": {"format": "uri-reference"}, + "schema": { "format": "uri-reference" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid URI", "data": "http://foo.bar/?baz=qux#quux", diff --git a/tests/draft2019-09/optional/format/uri-template.json b/tests/draft2019-09/optional/format/uri-template.json index 33ab76e..df355c5 100644 --- a/tests/draft2019-09/optional/format/uri-template.json +++ b/tests/draft2019-09/optional/format/uri-template.json @@ -1,8 +1,38 @@ [ { "description": "format: uri-template", - "schema": {"format": "uri-template"}, + "schema": { "format": "uri-template" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid uri-template", "data": "http://example.com/dictionary/{term:1}/{term}", diff --git a/tests/draft2019-09/optional/format/uri.json b/tests/draft2019-09/optional/format/uri.json index 58d3085..792d71a 100644 --- a/tests/draft2019-09/optional/format/uri.json +++ b/tests/draft2019-09/optional/format/uri.json @@ -1,7 +1,7 @@ [ { "description": "validation of URIs", - "schema": {"format": "uri"}, + "schema": { "format": "uri" }, "tests": [ { "description": "a valid URL with anchor tag", diff --git a/tests/draft2019-09/optional/unicode.json b/tests/draft2019-09/optional/unicode.json deleted file mode 100644 index 1dc5940..0000000 --- a/tests/draft2019-09/optional/unicode.json +++ /dev/null @@ -1,146 +0,0 @@ -[ - { - "description": "unicode semantics should be used for all pattern matching", - "schema": { "pattern": "\\wcole" }, - "tests": [ - { - "description": "literal unicode character in json string", - "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.", - "valid": true - }, - { - "description": "unicode character in hex format in string", - "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.", - "valid": true - }, - { - "description": "unicode matching is case-sensitive", - "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.", - "valid": false - } - ] - }, - { - "description": "unicode characters do not match ascii ranges", - "schema": { "pattern": "[a-z]cole" }, - "tests": [ - { - "description": "literal unicode character in json string", - "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.", - "valid": false - }, - { - "description": "unicode character in hex format in string", - "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.", - "valid": false - }, - { - "description": "ascii characters match", - "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.", - "valid": true - } - ] - }, - { - "description": "unicode digits are more than 0 through 9", - "schema": { "pattern": "^\\d+$" }, - "tests": [ - { - "description": "ascii digits", - "data": "42", - "valid": true - }, - { - "description": "ascii non-digits", - "data": "-%#", - "valid": false - }, - { - "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", - "data": "৪২", - "valid": true - } - ] - }, - { - "description": "unicode semantics should be used for all patternProperties matching", - "schema": { - "type": "object", - "patternProperties": { - "\\wcole": true - }, - "additionalProperties": false - }, - "tests": [ - { - "description": "literal unicode character in json string", - "data": { "l'école": "pas de vraie vie" }, - "valid": true - }, - { - "description": "unicode character in hex format in string", - "data": { "l'\u00e9cole": "pas de vraie vie" }, - "valid": true - }, - { - "description": "unicode matching is case-sensitive", - "data": { "L'ÉCOLE": "PAS DE VRAIE VIE" }, - "valid": false - } - ] - }, - { - "description": "unicode characters do not match ascii ranges", - "schema": { - "type": "object", - "patternProperties": { - "[a-z]cole": true - }, - "additionalProperties": false - }, - "tests": [ - { - "description": "literal unicode character in json string", - "data": { "l'école": "pas de vraie vie" }, - "valid": false - }, - { - "description": "unicode character in hex format in string", - "data": { "l'\u00e9cole": "pas de vraie vie" }, - "valid": false - }, - { - "description": "ascii characters match", - "data": { "l'ecole": "pas de vraie vie" }, - "valid": true - } - ] - }, - { - "description": "unicode digits are more than 0 through 9", - "schema": { - "type": "object", - "patternProperties": { - "^\\d+$": true - }, - "additionalProperties": false - }, - "tests": [ - { - "description": "ascii digits", - "data": { "42": "life, the universe, and everything" }, - "valid": true - }, - { - "description": "ascii non-digits", - "data": { "-%#": "spending the year dead for tax reasons" }, - "valid": false - }, - { - "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", - "data": { "৪২": "khajit has wares if you have coin" }, - "valid": true - } - ] - } -] diff --git a/tests/draft2019-09/ref.json b/tests/draft2019-09/ref.json index 4cb7bcd..fd8a3b2 100644 --- a/tests/draft2019-09/ref.json +++ b/tests/draft2019-09/ref.json @@ -539,5 +539,41 @@ "valid": true } ] + }, + { + "description": "$id must be resolved against nearest parent, not just immediate parent", + "schema": { + "$id": "http://example.com/a.json", + "$defs": { + "x": { + "$id": "http://example.com/b/c.json", + "not": { + "$defs": { + "y": { + "$id": "d.json", + "type": "number" + } + } + } + } + }, + "allOf": [ + { + "$ref": "http://example.com/b/d.json" + } + ] + }, + "tests": [ + { + "description": "number should pass", + "data": 1, + "valid": true + }, + { + "description": "non-number should fail", + "data": "a", + "valid": false + } + ] } ] diff --git a/tests/draft2019-09/unevaluatedProperties.json b/tests/draft2019-09/unevaluatedProperties.json index 9f498d0..7cb56bd 100644 --- a/tests/draft2019-09/unevaluatedProperties.json +++ b/tests/draft2019-09/unevaluatedProperties.json @@ -1057,5 +1057,255 @@ "valid": true } ] + }, + { + "description": "unevaluatedProperties + single cyclic ref", + "schema": { + "type": "object", + "properties": { + "x": { "$ref": "#" } + }, + "unevaluatedProperties": false + }, + "tests": [ + { + "description": "Empty is valid", + "data": {}, + "valid": true + }, + { + "description": "Single is valid", + "data": { "x": {} }, + "valid": true + }, + { + "description": "Unevaluated on 1st level is invalid", + "data": { "x": {}, "y": {} }, + "valid": false + }, + { + "description": "Nested is valid", + "data": { "x": { "x": {} } }, + "valid": true + }, + { + "description": "Unevaluated on 2nd level is invalid", + "data": { "x": { "x": {}, "y": {} } }, + "valid": false + }, + { + "description": "Deep nested is valid", + "data": { "x": { "x": { "x": {} } } }, + "valid": true + }, + { + "description": "Unevaluated on 3rd level is invalid", + "data": { "x": { "x": { "x": {}, "y": {} } } }, + "valid": false + } + ] + }, + { + "description": "unevaluatedProperties + ref inside allOf / oneOf", + "schema": { + "$defs": { + "one": { + "properties": { "a": true } + }, + "two": { + "required": ["x"], + "properties": { "x": true } + } + }, + "allOf": [ + { "$ref": "#/$defs/one" }, + { "properties": { "b": true } }, + { + "oneOf": [ + { "$ref": "#/$defs/two" }, + { + "required": ["y"], + "properties": { "y": true } + } + ] + } + ], + "unevaluatedProperties": false + }, + "tests": [ + { + "description": "Empty is invalid (no x or y)", + "data": {}, + "valid": false + }, + { + "description": "a and b are invalid (no x or y)", + "data": { "a": 1, "b": 1 }, + "valid": false + }, + { + "description": "x and y are invalid", + "data": { "x": 1, "y": 1 }, + "valid": false + }, + { + "description": "a and x are valid", + "data": { "a": 1, "x": 1 }, + "valid": true + }, + { + "description": "a and y are valid", + "data": { "a": 1, "y": 1 }, + "valid": true + }, + { + "description": "a and b and x are valid", + "data": { "a": 1, "b": 1, "x": 1 }, + "valid": true + }, + { + "description": "a and b and y are valid", + "data": { "a": 1, "b": 1, "y": 1 }, + "valid": true + }, + { + "description": "a and b and x and y are invalid", + "data": { "a": 1, "b": 1, "x": 1, "y": 1 }, + "valid": false + } + ] + }, + { + "description": "dynamic evalation inside nested refs", + "schema": { + "$defs": { + "one": { + "oneOf": [ + { "$ref": "#/$defs/two" }, + { "required": ["b"], "properties": { "b": true } }, + { "required": ["xx"], "patternProperties": { "x": true } }, + { "required": ["all"], "unevaluatedProperties": true } + ] + }, + "two": { + "oneOf": [ + { "required": ["c"], "properties": { "c": true } }, + { "required": ["d"], "properties": { "d": true } } + ] + } + }, + "oneOf": [ + { "$ref": "#/$defs/one" }, + { "required": ["a"], "properties": { "a": true } } + ], + "unevaluatedProperties": false + }, + "tests": [ + { + "description": "Empty is invalid", + "data": {}, + "valid": false + }, + { + "description": "a is valid", + "data": { "a": 1 }, + "valid": true + }, + { + "description": "b is valid", + "data": { "b": 1 }, + "valid": true + }, + { + "description": "c is valid", + "data": { "c": 1 }, + "valid": true + }, + { + "description": "d is valid", + "data": { "d": 1 }, + "valid": true + }, + { + "description": "a + b is invalid", + "data": { "a": 1, "b": 1 }, + "valid": false + }, + { + "description": "a + c is invalid", + "data": { "a": 1, "c": 1 }, + "valid": false + }, + { + "description": "a + d is invalid", + "data": { "a": 1, "d": 1 }, + "valid": false + }, + { + "description": "b + c is invalid", + "data": { "b": 1, "c": 1 }, + "valid": false + }, + { + "description": "b + d is invalid", + "data": { "b": 1, "d": 1 }, + "valid": false + }, + { + "description": "c + d is invalid", + "data": { "c": 1, "d": 1 }, + "valid": false + }, + { + "description": "xx is valid", + "data": { "xx": 1 }, + "valid": true + }, + { + "description": "xx + foox is valid", + "data": { "xx": 1, "foox": 1 }, + "valid": true + }, + { + "description": "xx + foo is invalid", + "data": { "xx": 1, "foo": 1 }, + "valid": false + }, + { + "description": "xx + a is invalid", + "data": { "xx": 1, "a": 1 }, + "valid": false + }, + { + "description": "xx + b is invalid", + "data": { "xx": 1, "b": 1 }, + "valid": false + }, + { + "description": "xx + c is invalid", + "data": { "xx": 1, "c": 1 }, + "valid": false + }, + { + "description": "xx + d is invalid", + "data": { "xx": 1, "d": 1 }, + "valid": false + }, + { + "description": "all is valid", + "data": { "all": 1 }, + "valid": true + }, + { + "description": "all + foo is valid", + "data": { "all": 1, "foo": 1 }, + "valid": true + }, + { + "description": "all + a is invalid", + "data": { "all": 1, "a": 1 }, + "valid": false + } + ] } ] diff --git a/tests/draft2020-12/anchor.json b/tests/draft2020-12/anchor.json index 045cdc3..416c224 100644 --- a/tests/draft2020-12/anchor.json +++ b/tests/draft2020-12/anchor.json @@ -134,5 +134,40 @@ "valid": false } ] + }, + { + "description": "same $anchor with different base uri", + "schema": { + "$id": "http://localhost:1234/foobar", + "$defs": { + "A": { + "$id": "child1", + "allOf": [ + { + "$id": "child2", + "$anchor": "my_anchor", + "type": "number" + }, + { + "$anchor": "my_anchor", + "type": "string" + } + ] + } + }, + "$ref": "child1#my_anchor" + }, + "tests": [ + { + "description": "$ref should resolve to /$defs/A/allOf/1", + "data": "a", + "valid": true + }, + { + "description": "$ref should not resolve to /$defs/A/allOf/0", + "data": 1, + "valid": false + } + ] } ] diff --git a/tests/draft2020-12/format.json b/tests/draft2020-12/format.json index f10b211..a4b51d2 100644 --- a/tests/draft2020-12/format.json +++ b/tests/draft2020-12/format.json @@ -32,11 +32,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid email string is only an annotation by default", - "data": "2962", - "valid": true } ] }, @@ -73,11 +68,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid idn-email string is only an annotation by default", - "data": "2962", - "valid": true } ] }, @@ -114,11 +104,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid regex string is only an annotation by default", - "data": "^(abc]", - "valid": true } ] }, @@ -155,11 +140,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid ipv4 string is only an annotation by default", - "data": "127.0.0.0.1", - "valid": true } ] }, @@ -196,11 +176,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid ipv6 string is only an annotation by default", - "data": "12345::", - "valid": true } ] }, @@ -237,11 +212,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid idn-hostname string is only an annotation by default", - "data": "〮실례.테스트", - "valid": true } ] }, @@ -278,11 +248,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid hostname string is only an annotation by default", - "data": "-a-host-name-that-starts-with--", - "valid": true } ] }, @@ -319,11 +284,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid date string is only an annotation by default", - "data": "06/19/1963", - "valid": true } ] }, @@ -360,11 +320,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid date-time string is only an annotation by default", - "data": "1990-02-31T15:59:60.123-08:00", - "valid": true } ] }, @@ -401,11 +356,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid time string is only an annotation by default", - "data": "08:30:06 PST", - "valid": true } ] }, @@ -442,11 +392,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid json-pointer string is only an annotation by default", - "data": "/foo/bar~", - "valid": true } ] }, @@ -483,11 +428,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid relative-json-pointer string is only an annotation by default", - "data": "/foo/bar", - "valid": true } ] }, @@ -524,11 +464,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid iri string is only an annotation by default", - "data": "http://2001:0db8:85a3:0000:0000:8a2e:0370:7334", - "valid": true } ] }, @@ -565,11 +500,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid iri-reference string is only an annotation by default", - "data": "\\\\WINDOWS\\filëßåré", - "valid": true } ] }, @@ -606,11 +536,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid uri string is only an annotation by default", - "data": "//foo.bar/?baz=qux#quux", - "valid": true } ] }, @@ -647,11 +572,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid uri-reference string is only an annotation by default", - "data": "\\\\WINDOWS\\fileshare", - "valid": true } ] }, @@ -688,11 +608,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid uri-template string is only an annotation by default", - "data": "http://example.com/dictionary/{term:1}/{term", - "valid": true } ] }, @@ -729,11 +644,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid uuid string is only an annotation by default", - "data": "2eb8aa08-aa98-11ea-b4aa-73b441d1638", - "valid": true } ] }, @@ -770,11 +680,6 @@ "description": "all string formats ignore nulls", "data": null, "valid": true - }, - { - "description": "invalid duration string is only an annotation by default", - "data": "PT1D", - "valid": true } ] } diff --git a/tests/draft2020-12/optional/ecmascript-regex.json b/tests/draft2020-12/optional/ecmascript-regex.json index fb02e99..1beb0b3 100644 --- a/tests/draft2020-12/optional/ecmascript-regex.json +++ b/tests/draft2020-12/optional/ecmascript-regex.json @@ -288,5 +288,265 @@ "valid": true } ] + }, + { + "description": "unicode semantics should be used for all pattern matching", + "schema": { "pattern": "\\p{Letter}cole" }, + "tests": [ + { + "description": "ascii character in json string", + "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.", + "valid": true + }, + { + "description": "literal unicode character in json string", + "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.", + "valid": true + }, + { + "description": "unicode character in hex format in string", + "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.", + "valid": true + }, + { + "description": "unicode matching is case-sensitive", + "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.", + "valid": false + } + ] + }, + { + "description": "\\w in patterns matches [A-Za-z0-9_], not unicode letters", + "schema": { "pattern": "\\wcole" }, + "tests": [ + { + "description": "ascii character in json string", + "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.", + "valid": true + }, + { + "description": "literal unicode character in json string", + "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.", + "valid": false + }, + { + "description": "unicode character in hex format in string", + "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.", + "valid": false + }, + { + "description": "unicode matching is case-sensitive", + "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.", + "valid": false + } + ] + }, + { + "description": "unicode characters do not match ascii ranges", + "schema": { "pattern": "[a-z]cole" }, + "tests": [ + { + "description": "literal unicode character in json string", + "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.", + "valid": false + }, + { + "description": "unicode character in hex format in string", + "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.", + "valid": false + }, + { + "description": "ascii characters match", + "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.", + "valid": true + } + ] + }, + { + "description": "\\d in pattern matches [0-9], not unicode digits", + "schema": { "pattern": "^\\d+$" }, + "tests": [ + { + "description": "ascii digits", + "data": "42", + "valid": true + }, + { + "description": "ascii non-digits", + "data": "-%#", + "valid": false + }, + { + "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", + "data": "৪২", + "valid": false + } + ] + }, + { + "description": "unicode digits are more than 0 through 9", + "schema": { "pattern": "^\\p{digit}+$" }, + "tests": [ + { + "description": "ascii digits", + "data": "42", + "valid": true + }, + { + "description": "ascii non-digits", + "data": "-%#", + "valid": false + }, + { + "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", + "data": "৪২", + "valid": true + } + ] + }, + { + "description": "unicode semantics should be used for all patternProperties matching", + "schema": { + "type": "object", + "patternProperties": { + "\\p{Letter}cole": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "ascii character in json string", + "data": { "l'ecole": "pas de vraie vie" }, + "valid": true + }, + { + "description": "literal unicode character in json string", + "data": { "l'école": "pas de vraie vie" }, + "valid": true + }, + { + "description": "unicode character in hex format in string", + "data": { "l'\u00e9cole": "pas de vraie vie" }, + "valid": true + }, + { + "description": "unicode matching is case-sensitive", + "data": { "L'ÉCOLE": "PAS DE VRAIE VIE" }, + "valid": false + } + ] + }, + { + "description": "\\w in patternProperties matches [A-Za-z0-9_], not unicode letters", + "schema": { + "type": "object", + "patternProperties": { + "\\wcole": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "ascii character in json string", + "data": { "l'ecole": "pas de vraie vie" }, + "valid": true + }, + { + "description": "literal unicode character in json string", + "data": { "l'école": "pas de vraie vie" }, + "valid": false + }, + { + "description": "unicode character in hex format in string", + "data": { "l'\u00e9cole": "pas de vraie vie" }, + "valid": false + }, + { + "description": "unicode matching is case-sensitive", + "data": { "L'ÉCOLE": "PAS DE VRAIE VIE" }, + "valid": false + } + ] + }, + { + "description": "unicode characters do not match ascii ranges", + "schema": { + "type": "object", + "patternProperties": { + "[a-z]cole": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "literal unicode character in json string", + "data": { "l'école": "pas de vraie vie" }, + "valid": false + }, + { + "description": "unicode character in hex format in string", + "data": { "l'\u00e9cole": "pas de vraie vie" }, + "valid": false + }, + { + "description": "ascii characters match", + "data": { "l'ecole": "pas de vraie vie" }, + "valid": true + } + ] + }, + { + "description": "\\d in patternProperties matches [0-9], not unicode digits", + "schema": { + "type": "object", + "patternProperties": { + "^\\d+$": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "ascii digits", + "data": { "42": "life, the universe, and everything" }, + "valid": true + }, + { + "description": "ascii non-digits", + "data": { "-%#": "spending the year dead for tax reasons" }, + "valid": false + }, + { + "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", + "data": { "৪২": "khajit has wares if you have coin" }, + "valid": false + } + ] + }, + { + "description": "unicode digits are more than 0 through 9", + "schema": { + "type": "object", + "patternProperties": { + "^\\p{digit}+$": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "ascii digits", + "data": { "42": "life, the universe, and everything" }, + "valid": true + }, + { + "description": "ascii non-digits", + "data": { "-%#": "spending the year dead for tax reasons" }, + "valid": false + }, + { + "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", + "data": { "৪২": "khajit has wares if you have coin" }, + "valid": true + } + ] } ] diff --git a/tests/draft2020-12/optional/format-assertion.json b/tests/draft2020-12/optional/format-assertion.json new file mode 100644 index 0000000..0340037 --- /dev/null +++ b/tests/draft2020-12/optional/format-assertion.json @@ -0,0 +1,42 @@ +[ + { + "description": "schema that uses custom metaschema with format-assertion: false", + "schema": { + "$id": "https://schema/using/format-assertion/false", + "$schema": "http://localhost:1234/draft2020-12/format-assertion-false.json", + "format": "ipv4" + }, + "tests": [ + { + "description": "format-assertion: false: valid string", + "data": "127.0.0.1", + "valid": true + }, + { + "description": "format-assertion: false: invalid string", + "data": "not-an-ipv4", + "valid": false + } + ] + }, + { + "description": "schema that uses custom metaschema with format-assertion: true", + "schema": { + "$id": "https://schema/using/format-assertion/true", + "$schema": "http://localhost:1234/draft2020-12/format-assertion-true.json", + "format": "ipv4" + }, + "tests": [ + { + "description": "format-assertion: true: valid string", + "data": "127.0.0.1", + "valid": true + }, + { + "description": "format-assertion: true: invalid string", + "data": "not-an-ipv4", + "valid": false + } + ] + } +] diff --git a/tests/draft2020-12/optional/format/date-time.json b/tests/draft2020-12/optional/format/date-time.json index 5f911ef..119179c 100644 --- a/tests/draft2020-12/optional/format/date-time.json +++ b/tests/draft2020-12/optional/format/date-time.json @@ -1,8 +1,38 @@ [ { "description": "validation of date-time strings", - "schema": {"format": "date-time"}, + "schema": { "format": "date-time" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid date-time string", "data": "1963-06-19T08:30:06.283185Z", @@ -33,6 +63,11 @@ "data": "1990-12-31T15:59:60-24:00", "valid": false }, + { + "description": "an invalid closing Z after time-zone offset", + "data": "1963-06-19T08:30:06.28123+01:00Z", + "valid": false + }, { "description": "an invalid date-time string", "data": "06/19/1963 08:30:06 PST", diff --git a/tests/draft2020-12/optional/format/date.json b/tests/draft2020-12/optional/format/date.json index 6cc2feb..b4f61ee 100644 --- a/tests/draft2020-12/optional/format/date.json +++ b/tests/draft2020-12/optional/format/date.json @@ -1,8 +1,38 @@ [ { "description": "validation of date strings", - "schema": {"format": "date"}, + "schema": { "format": "date" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid date string", "data": "1963-06-19", diff --git a/tests/draft2020-12/optional/format/duration.json b/tests/draft2020-12/optional/format/duration.json index eb33dbb..741348a 100644 --- a/tests/draft2020-12/optional/format/duration.json +++ b/tests/draft2020-12/optional/format/duration.json @@ -1,8 +1,38 @@ [ { "description": "validation of duration strings", - "schema": {"format": "duration"}, + "schema": { "format": "duration" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid duration string", "data": "P4DT12H30M5S", diff --git a/tests/draft2020-12/optional/format/email.json b/tests/draft2020-12/optional/format/email.json index 02396d2..d6761a4 100644 --- a/tests/draft2020-12/optional/format/email.json +++ b/tests/draft2020-12/optional/format/email.json @@ -1,8 +1,38 @@ [ { "description": "validation of e-mail addresses", - "schema": {"format": "email"}, + "schema": { "format": "email" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid e-mail address", "data": "joe.bloggs@example.com", diff --git a/tests/draft2020-12/optional/format/hostname.json b/tests/draft2020-12/optional/format/hostname.json index 476541a..8a67fda 100644 --- a/tests/draft2020-12/optional/format/hostname.json +++ b/tests/draft2020-12/optional/format/hostname.json @@ -1,8 +1,38 @@ [ { "description": "validation of host names", - "schema": {"format": "hostname"}, + "schema": { "format": "hostname" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid host name", "data": "www.example.com", diff --git a/tests/draft2020-12/optional/format/idn-email.json b/tests/draft2020-12/optional/format/idn-email.json index 552d106..6e21374 100644 --- a/tests/draft2020-12/optional/format/idn-email.json +++ b/tests/draft2020-12/optional/format/idn-email.json @@ -1,8 +1,38 @@ [ { "description": "validation of an internationalized e-mail addresses", - "schema": {"format": "idn-email"}, + "schema": { "format": "idn-email" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid idn e-mail (example@example.test in Hangul)", "data": "실례@실례.테스트", diff --git a/tests/draft2020-12/optional/format/idn-hostname.json b/tests/draft2020-12/optional/format/idn-hostname.json index bbb257b..6c8f86a 100644 --- a/tests/draft2020-12/optional/format/idn-hostname.json +++ b/tests/draft2020-12/optional/format/idn-hostname.json @@ -3,6 +3,36 @@ "description": "validation of internationalized host names", "schema": { "format": "idn-hostname" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid host name (example.test in Hangul)", "data": "실례.테스트", diff --git a/tests/draft2020-12/optional/format/ipv4.json b/tests/draft2020-12/optional/format/ipv4.json index 4d10927..6b166c7 100644 --- a/tests/draft2020-12/optional/format/ipv4.json +++ b/tests/draft2020-12/optional/format/ipv4.json @@ -1,8 +1,38 @@ [ { "description": "validation of IP addresses", - "schema": {"format": "ipv4"}, + "schema": { "format": "ipv4" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid IP address", "data": "192.168.0.1", diff --git a/tests/draft2020-12/optional/format/ipv6.json b/tests/draft2020-12/optional/format/ipv6.json index cf629c6..6379927 100644 --- a/tests/draft2020-12/optional/format/ipv6.json +++ b/tests/draft2020-12/optional/format/ipv6.json @@ -1,8 +1,38 @@ [ { "description": "validation of IPv6 addresses", - "schema": {"format": "ipv6"}, + "schema": { "format": "ipv6" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid IPv6 address", "data": "::1", @@ -13,6 +43,16 @@ "data": "12345::", "valid": false }, + { + "description": "trailing 4 hex symbols is valid", + "data": "::abef", + "valid": true + }, + { + "description": "trailing 5 hex symbols is invalid", + "data": "::abcef", + "valid": false + }, { "description": "an IPv6 address with too many components", "data": "1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1", @@ -53,6 +93,11 @@ "data": ":2:3:4::8", "valid": false }, + { + "description": "single set of double colons in the middle is valid", + "data": "1:d6::42", + "valid": true + }, { "description": "two sets of double colons is invalid", "data": "1::d6::42", diff --git a/tests/draft2020-12/optional/format/iri-reference.json b/tests/draft2020-12/optional/format/iri-reference.json index 1fd779c..c6b4c22 100644 --- a/tests/draft2020-12/optional/format/iri-reference.json +++ b/tests/draft2020-12/optional/format/iri-reference.json @@ -1,8 +1,38 @@ [ { "description": "validation of IRI References", - "schema": {"format": "iri-reference"}, + "schema": { "format": "iri-reference" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid IRI", "data": "http://ƒøø.ßår/?∂éœ=πîx#πîüx", diff --git a/tests/draft2020-12/optional/format/iri.json b/tests/draft2020-12/optional/format/iri.json index 1414f2e..a0d12ae 100644 --- a/tests/draft2020-12/optional/format/iri.json +++ b/tests/draft2020-12/optional/format/iri.json @@ -1,8 +1,38 @@ [ { "description": "validation of IRIs", - "schema": {"format": "iri"}, + "schema": { "format": "iri" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid IRI with anchor tag", "data": "http://ƒøø.ßår/?∂éœ=πîx#πîüx", diff --git a/tests/draft2020-12/optional/format/json-pointer.json b/tests/draft2020-12/optional/format/json-pointer.json index 65c2f06..a0346b5 100644 --- a/tests/draft2020-12/optional/format/json-pointer.json +++ b/tests/draft2020-12/optional/format/json-pointer.json @@ -1,8 +1,38 @@ [ { "description": "validation of JSON-pointers (JSON String Representation)", - "schema": {"format": "json-pointer"}, + "schema": { "format": "json-pointer" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid JSON-pointer", "data": "/foo/bar~0/baz~1/%a", diff --git a/tests/draft2020-12/optional/format/regex.json b/tests/draft2020-12/optional/format/regex.json index d99d021..3449177 100644 --- a/tests/draft2020-12/optional/format/regex.json +++ b/tests/draft2020-12/optional/format/regex.json @@ -1,8 +1,38 @@ [ { "description": "validation of regular expressions", - "schema": {"format": "regex"}, + "schema": { "format": "regex" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid regular expression", "data": "([abc])+\\s+$", diff --git a/tests/draft2020-12/optional/format/relative-json-pointer.json b/tests/draft2020-12/optional/format/relative-json-pointer.json index 22fb14e..9309986 100644 --- a/tests/draft2020-12/optional/format/relative-json-pointer.json +++ b/tests/draft2020-12/optional/format/relative-json-pointer.json @@ -1,8 +1,38 @@ [ { "description": "validation of Relative JSON Pointers (RJP)", - "schema": {"format": "relative-json-pointer"}, + "schema": { "format": "relative-json-pointer" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid upwards RJP", "data": "1", diff --git a/tests/draft2020-12/optional/format/time.json b/tests/draft2020-12/optional/format/time.json index 0a8da0e..5011d78 100644 --- a/tests/draft2020-12/optional/format/time.json +++ b/tests/draft2020-12/optional/format/time.json @@ -1,8 +1,38 @@ [ { "description": "validation of time strings", - "schema": {"format": "time"}, + "schema": { "format": "time" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid time string", "data": "08:30:06Z", diff --git a/tests/draft2020-12/optional/format/uri-reference.json b/tests/draft2020-12/optional/format/uri-reference.json index e4c9eef..7cdf228 100644 --- a/tests/draft2020-12/optional/format/uri-reference.json +++ b/tests/draft2020-12/optional/format/uri-reference.json @@ -1,8 +1,38 @@ [ { "description": "validation of URI References", - "schema": {"format": "uri-reference"}, + "schema": { "format": "uri-reference" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid URI", "data": "http://foo.bar/?baz=qux#quux", diff --git a/tests/draft2020-12/optional/format/uri-template.json b/tests/draft2020-12/optional/format/uri-template.json index 33ab76e..df355c5 100644 --- a/tests/draft2020-12/optional/format/uri-template.json +++ b/tests/draft2020-12/optional/format/uri-template.json @@ -1,8 +1,38 @@ [ { "description": "format: uri-template", - "schema": {"format": "uri-template"}, + "schema": { "format": "uri-template" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid uri-template", "data": "http://example.com/dictionary/{term:1}/{term}", diff --git a/tests/draft2020-12/optional/format/uri.json b/tests/draft2020-12/optional/format/uri.json index 58d3085..792d71a 100644 --- a/tests/draft2020-12/optional/format/uri.json +++ b/tests/draft2020-12/optional/format/uri.json @@ -1,7 +1,7 @@ [ { "description": "validation of URIs", - "schema": {"format": "uri"}, + "schema": { "format": "uri" }, "tests": [ { "description": "a valid URL with anchor tag", diff --git a/tests/draft2020-12/optional/unicode.json b/tests/draft2020-12/optional/unicode.json deleted file mode 100644 index 1dc5940..0000000 --- a/tests/draft2020-12/optional/unicode.json +++ /dev/null @@ -1,146 +0,0 @@ -[ - { - "description": "unicode semantics should be used for all pattern matching", - "schema": { "pattern": "\\wcole" }, - "tests": [ - { - "description": "literal unicode character in json string", - "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.", - "valid": true - }, - { - "description": "unicode character in hex format in string", - "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.", - "valid": true - }, - { - "description": "unicode matching is case-sensitive", - "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.", - "valid": false - } - ] - }, - { - "description": "unicode characters do not match ascii ranges", - "schema": { "pattern": "[a-z]cole" }, - "tests": [ - { - "description": "literal unicode character in json string", - "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.", - "valid": false - }, - { - "description": "unicode character in hex format in string", - "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.", - "valid": false - }, - { - "description": "ascii characters match", - "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.", - "valid": true - } - ] - }, - { - "description": "unicode digits are more than 0 through 9", - "schema": { "pattern": "^\\d+$" }, - "tests": [ - { - "description": "ascii digits", - "data": "42", - "valid": true - }, - { - "description": "ascii non-digits", - "data": "-%#", - "valid": false - }, - { - "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", - "data": "৪২", - "valid": true - } - ] - }, - { - "description": "unicode semantics should be used for all patternProperties matching", - "schema": { - "type": "object", - "patternProperties": { - "\\wcole": true - }, - "additionalProperties": false - }, - "tests": [ - { - "description": "literal unicode character in json string", - "data": { "l'école": "pas de vraie vie" }, - "valid": true - }, - { - "description": "unicode character in hex format in string", - "data": { "l'\u00e9cole": "pas de vraie vie" }, - "valid": true - }, - { - "description": "unicode matching is case-sensitive", - "data": { "L'ÉCOLE": "PAS DE VRAIE VIE" }, - "valid": false - } - ] - }, - { - "description": "unicode characters do not match ascii ranges", - "schema": { - "type": "object", - "patternProperties": { - "[a-z]cole": true - }, - "additionalProperties": false - }, - "tests": [ - { - "description": "literal unicode character in json string", - "data": { "l'école": "pas de vraie vie" }, - "valid": false - }, - { - "description": "unicode character in hex format in string", - "data": { "l'\u00e9cole": "pas de vraie vie" }, - "valid": false - }, - { - "description": "ascii characters match", - "data": { "l'ecole": "pas de vraie vie" }, - "valid": true - } - ] - }, - { - "description": "unicode digits are more than 0 through 9", - "schema": { - "type": "object", - "patternProperties": { - "^\\d+$": true - }, - "additionalProperties": false - }, - "tests": [ - { - "description": "ascii digits", - "data": { "42": "life, the universe, and everything" }, - "valid": true - }, - { - "description": "ascii non-digits", - "data": { "-%#": "spending the year dead for tax reasons" }, - "valid": false - }, - { - "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", - "data": { "৪২": "khajit has wares if you have coin" }, - "valid": true - } - ] - } -] diff --git a/tests/draft2020-12/ref.json b/tests/draft2020-12/ref.json index 6071a7e..8a65e51 100644 --- a/tests/draft2020-12/ref.json +++ b/tests/draft2020-12/ref.json @@ -541,5 +541,41 @@ "valid": true } ] + }, + { + "description": "$id must be resolved against nearest parent, not just immediate parent", + "schema": { + "$id": "http://example.com/a.json", + "$defs": { + "x": { + "$id": "http://example.com/b/c.json", + "not": { + "$defs": { + "y": { + "$id": "d.json", + "type": "number" + } + } + } + } + }, + "allOf": [ + { + "$ref": "http://example.com/b/d.json" + } + ] + }, + "tests": [ + { + "description": "number should pass", + "data": 1, + "valid": true + }, + { + "description": "non-number should fail", + "data": "a", + "valid": false + } + ] } ] diff --git a/tests/draft2020-12/unevaluatedProperties.json b/tests/draft2020-12/unevaluatedProperties.json index 9f498d0..7cb56bd 100644 --- a/tests/draft2020-12/unevaluatedProperties.json +++ b/tests/draft2020-12/unevaluatedProperties.json @@ -1057,5 +1057,255 @@ "valid": true } ] + }, + { + "description": "unevaluatedProperties + single cyclic ref", + "schema": { + "type": "object", + "properties": { + "x": { "$ref": "#" } + }, + "unevaluatedProperties": false + }, + "tests": [ + { + "description": "Empty is valid", + "data": {}, + "valid": true + }, + { + "description": "Single is valid", + "data": { "x": {} }, + "valid": true + }, + { + "description": "Unevaluated on 1st level is invalid", + "data": { "x": {}, "y": {} }, + "valid": false + }, + { + "description": "Nested is valid", + "data": { "x": { "x": {} } }, + "valid": true + }, + { + "description": "Unevaluated on 2nd level is invalid", + "data": { "x": { "x": {}, "y": {} } }, + "valid": false + }, + { + "description": "Deep nested is valid", + "data": { "x": { "x": { "x": {} } } }, + "valid": true + }, + { + "description": "Unevaluated on 3rd level is invalid", + "data": { "x": { "x": { "x": {}, "y": {} } } }, + "valid": false + } + ] + }, + { + "description": "unevaluatedProperties + ref inside allOf / oneOf", + "schema": { + "$defs": { + "one": { + "properties": { "a": true } + }, + "two": { + "required": ["x"], + "properties": { "x": true } + } + }, + "allOf": [ + { "$ref": "#/$defs/one" }, + { "properties": { "b": true } }, + { + "oneOf": [ + { "$ref": "#/$defs/two" }, + { + "required": ["y"], + "properties": { "y": true } + } + ] + } + ], + "unevaluatedProperties": false + }, + "tests": [ + { + "description": "Empty is invalid (no x or y)", + "data": {}, + "valid": false + }, + { + "description": "a and b are invalid (no x or y)", + "data": { "a": 1, "b": 1 }, + "valid": false + }, + { + "description": "x and y are invalid", + "data": { "x": 1, "y": 1 }, + "valid": false + }, + { + "description": "a and x are valid", + "data": { "a": 1, "x": 1 }, + "valid": true + }, + { + "description": "a and y are valid", + "data": { "a": 1, "y": 1 }, + "valid": true + }, + { + "description": "a and b and x are valid", + "data": { "a": 1, "b": 1, "x": 1 }, + "valid": true + }, + { + "description": "a and b and y are valid", + "data": { "a": 1, "b": 1, "y": 1 }, + "valid": true + }, + { + "description": "a and b and x and y are invalid", + "data": { "a": 1, "b": 1, "x": 1, "y": 1 }, + "valid": false + } + ] + }, + { + "description": "dynamic evalation inside nested refs", + "schema": { + "$defs": { + "one": { + "oneOf": [ + { "$ref": "#/$defs/two" }, + { "required": ["b"], "properties": { "b": true } }, + { "required": ["xx"], "patternProperties": { "x": true } }, + { "required": ["all"], "unevaluatedProperties": true } + ] + }, + "two": { + "oneOf": [ + { "required": ["c"], "properties": { "c": true } }, + { "required": ["d"], "properties": { "d": true } } + ] + } + }, + "oneOf": [ + { "$ref": "#/$defs/one" }, + { "required": ["a"], "properties": { "a": true } } + ], + "unevaluatedProperties": false + }, + "tests": [ + { + "description": "Empty is invalid", + "data": {}, + "valid": false + }, + { + "description": "a is valid", + "data": { "a": 1 }, + "valid": true + }, + { + "description": "b is valid", + "data": { "b": 1 }, + "valid": true + }, + { + "description": "c is valid", + "data": { "c": 1 }, + "valid": true + }, + { + "description": "d is valid", + "data": { "d": 1 }, + "valid": true + }, + { + "description": "a + b is invalid", + "data": { "a": 1, "b": 1 }, + "valid": false + }, + { + "description": "a + c is invalid", + "data": { "a": 1, "c": 1 }, + "valid": false + }, + { + "description": "a + d is invalid", + "data": { "a": 1, "d": 1 }, + "valid": false + }, + { + "description": "b + c is invalid", + "data": { "b": 1, "c": 1 }, + "valid": false + }, + { + "description": "b + d is invalid", + "data": { "b": 1, "d": 1 }, + "valid": false + }, + { + "description": "c + d is invalid", + "data": { "c": 1, "d": 1 }, + "valid": false + }, + { + "description": "xx is valid", + "data": { "xx": 1 }, + "valid": true + }, + { + "description": "xx + foox is valid", + "data": { "xx": 1, "foox": 1 }, + "valid": true + }, + { + "description": "xx + foo is invalid", + "data": { "xx": 1, "foo": 1 }, + "valid": false + }, + { + "description": "xx + a is invalid", + "data": { "xx": 1, "a": 1 }, + "valid": false + }, + { + "description": "xx + b is invalid", + "data": { "xx": 1, "b": 1 }, + "valid": false + }, + { + "description": "xx + c is invalid", + "data": { "xx": 1, "c": 1 }, + "valid": false + }, + { + "description": "xx + d is invalid", + "data": { "xx": 1, "d": 1 }, + "valid": false + }, + { + "description": "all is valid", + "data": { "all": 1 }, + "valid": true + }, + { + "description": "all + foo is valid", + "data": { "all": 1, "foo": 1 }, + "valid": true + }, + { + "description": "all + a is invalid", + "data": { "all": 1, "a": 1 }, + "valid": false + } + ] } ] diff --git a/tests/draft3/optional/format/color.json b/tests/draft3/optional/format/color.json index e80cb69..0c0b534 100644 --- a/tests/draft3/optional/format/color.json +++ b/tests/draft3/optional/format/color.json @@ -1,7 +1,7 @@ [ { "description": "validation of CSS colors", - "schema": {"format": "color"}, + "schema": { "format": "color" }, "tests": [ { "description": "a valid CSS color name", diff --git a/tests/draft3/optional/format/date-time.json b/tests/draft3/optional/format/date-time.json index 58261fa..1f1e6fb 100644 --- a/tests/draft3/optional/format/date-time.json +++ b/tests/draft3/optional/format/date-time.json @@ -1,7 +1,7 @@ [ { "description": "validation of date-time strings", - "schema": {"format": "date-time"}, + "schema": { "format": "date-time" }, "tests": [ { "description": "a valid date-time string", diff --git a/tests/draft3/optional/format/date.json b/tests/draft3/optional/format/date.json index 554fe54..796bc46 100644 --- a/tests/draft3/optional/format/date.json +++ b/tests/draft3/optional/format/date.json @@ -1,7 +1,7 @@ [ { "description": "validation of date strings", - "schema": {"format": "date"}, + "schema": { "format": "date" }, "tests": [ { "description": "a valid date string", diff --git a/tests/draft3/optional/format/email.json b/tests/draft3/optional/format/email.json index 02396d2..059615a 100644 --- a/tests/draft3/optional/format/email.json +++ b/tests/draft3/optional/format/email.json @@ -1,7 +1,7 @@ [ { "description": "validation of e-mail addresses", - "schema": {"format": "email"}, + "schema": { "format": "email" }, "tests": [ { "description": "a valid e-mail address", diff --git a/tests/draft3/optional/format/host-name.json b/tests/draft3/optional/format/host-name.json index 8f6e28a..d418f37 100644 --- a/tests/draft3/optional/format/host-name.json +++ b/tests/draft3/optional/format/host-name.json @@ -1,7 +1,7 @@ [ { "description": "validation of host names", - "schema": {"format": "host-name"}, + "schema": { "format": "host-name" }, "tests": [ { "description": "a valid host name", diff --git a/tests/draft3/optional/format/ip-address.json b/tests/draft3/optional/format/ip-address.json index c868bfb..91cac9f 100644 --- a/tests/draft3/optional/format/ip-address.json +++ b/tests/draft3/optional/format/ip-address.json @@ -1,7 +1,7 @@ [ { "description": "validation of IP addresses", - "schema": {"format": "ip-address"}, + "schema": { "format": "ip-address" }, "tests": [ { "description": "a valid IP address", diff --git a/tests/draft3/optional/format/ipv6.json b/tests/draft3/optional/format/ipv6.json index 131edb8..c3ef379 100644 --- a/tests/draft3/optional/format/ipv6.json +++ b/tests/draft3/optional/format/ipv6.json @@ -1,7 +1,7 @@ [ { "description": "validation of IPv6 addresses", - "schema": {"format": "ipv6"}, + "schema": { "format": "ipv6" }, "tests": [ { "description": "a valid IPv6 address", diff --git a/tests/draft3/optional/format/regex.json b/tests/draft3/optional/format/regex.json index d99d021..8a37763 100644 --- a/tests/draft3/optional/format/regex.json +++ b/tests/draft3/optional/format/regex.json @@ -1,7 +1,7 @@ [ { "description": "validation of regular expressions", - "schema": {"format": "regex"}, + "schema": { "format": "regex" }, "tests": [ { "description": "a valid regular expression", diff --git a/tests/draft3/optional/format/time.json b/tests/draft3/optional/format/time.json index e97160d..36c823e 100644 --- a/tests/draft3/optional/format/time.json +++ b/tests/draft3/optional/format/time.json @@ -1,7 +1,7 @@ [ { "description": "validation of time strings", - "schema": {"format": "time"}, + "schema": { "format": "time" }, "tests": [ { "description": "a valid time string", diff --git a/tests/draft3/optional/format/uri.json b/tests/draft3/optional/format/uri.json index 9c4de35..f024b62 100644 --- a/tests/draft3/optional/format/uri.json +++ b/tests/draft3/optional/format/uri.json @@ -1,7 +1,7 @@ [ { "description": "validation of URIs", - "schema": {"format": "uri"}, + "schema": { "format": "uri" }, "tests": [ { "description": "a valid URI", diff --git a/tests/draft3/ref.json b/tests/draft3/ref.json index 46dd82d..924db76 100644 --- a/tests/draft3/ref.json +++ b/tests/draft3/ref.json @@ -207,17 +207,17 @@ "definitions": { "foo": { "id": "http://localhost:1234/sibling_id/foo.json", - "minimum": 2 + "type": "string" }, "base_foo": { "$comment": "this canonical uri is http://localhost:1234/sibling_id/base/foo.json", "id": "foo.json", - "minimum": 5 + "type": "number" } }, "allOf": [ { - "$comment": "$ref resolves to http://localhost:1234/sibling_id/base/foo.json, not ttp://localhost:1234/sibling_id/foo.json", + "$comment": "$ref resolves to http://localhost:1234/sibling_id/base/foo.json, not http://localhost:1234/sibling_id/foo.json", "id": "http://localhost:1234/sibling_id/", "$ref": "foo.json" } @@ -225,14 +225,14 @@ }, "tests": [ { - "description": "$ref resolves to /definitions/foo, data validates", - "data": 10, - "valid": true + "description": "$ref resolves to /definitions/base_foo, data does not validate", + "data": "a", + "valid": false }, { - "description": "$ref resolves to /definitions/foo, data does not validate", + "description": "$ref resolves to /definitions/base_foo, data validates", "data": 1, - "valid": false + "valid": true } ] }, diff --git a/tests/draft4/optional/ecmascript-regex.json b/tests/draft4/optional/ecmascript-regex.json index fb02e99..77624cf 100644 --- a/tests/draft4/optional/ecmascript-regex.json +++ b/tests/draft4/optional/ecmascript-regex.json @@ -288,5 +288,265 @@ "valid": true } ] + }, + { + "description": "unicode semantics should be used for all pattern matching", + "schema": { "pattern": "\\p{Letter}cole" }, + "tests": [ + { + "description": "ascii character in json string", + "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.", + "valid": true + }, + { + "description": "literal unicode character in json string", + "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.", + "valid": true + }, + { + "description": "unicode character in hex format in string", + "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.", + "valid": true + }, + { + "description": "unicode matching is case-sensitive", + "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.", + "valid": false + } + ] + }, + { + "description": "\\w in patterns matches [A-Za-z0-9_], not unicode letters", + "schema": { "pattern": "\\wcole" }, + "tests": [ + { + "description": "ascii character in json string", + "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.", + "valid": true + }, + { + "description": "literal unicode character in json string", + "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.", + "valid": false + }, + { + "description": "unicode character in hex format in string", + "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.", + "valid": false + }, + { + "description": "unicode matching is case-sensitive", + "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.", + "valid": false + } + ] + }, + { + "description": "unicode characters do not match ascii ranges", + "schema": { "pattern": "[a-z]cole" }, + "tests": [ + { + "description": "literal unicode character in json string", + "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.", + "valid": false + }, + { + "description": "unicode character in hex format in string", + "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.", + "valid": false + }, + { + "description": "ascii characters match", + "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.", + "valid": true + } + ] + }, + { + "description": "\\d in pattern matches [0-9], not unicode digits", + "schema": { "pattern": "^\\d+$" }, + "tests": [ + { + "description": "ascii digits", + "data": "42", + "valid": true + }, + { + "description": "ascii non-digits", + "data": "-%#", + "valid": false + }, + { + "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", + "data": "৪২", + "valid": false + } + ] + }, + { + "description": "unicode digits are more than 0 through 9", + "schema": { "pattern": "^\\p{digit}+$" }, + "tests": [ + { + "description": "ascii digits", + "data": "42", + "valid": true + }, + { + "description": "ascii non-digits", + "data": "-%#", + "valid": false + }, + { + "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", + "data": "৪২", + "valid": true + } + ] + }, + { + "description": "unicode semantics should be used for all patternProperties matching", + "schema": { + "type": "object", + "patternProperties": { + "\\p{Letter}cole": {} + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "ascii character in json string", + "data": { "l'ecole": "pas de vraie vie" }, + "valid": true + }, + { + "description": "literal unicode character in json string", + "data": { "l'école": "pas de vraie vie" }, + "valid": true + }, + { + "description": "unicode character in hex format in string", + "data": { "l'\u00e9cole": "pas de vraie vie" }, + "valid": true + }, + { + "description": "unicode matching is case-sensitive", + "data": { "L'ÉCOLE": "PAS DE VRAIE VIE" }, + "valid": false + } + ] + }, + { + "description": "\\w in patternProperties matches [A-Za-z0-9_], not unicode letters", + "schema": { + "type": "object", + "patternProperties": { + "\\wcole": {} + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "ascii character in json string", + "data": { "l'ecole": "pas de vraie vie" }, + "valid": true + }, + { + "description": "literal unicode character in json string", + "data": { "l'école": "pas de vraie vie" }, + "valid": false + }, + { + "description": "unicode character in hex format in string", + "data": { "l'\u00e9cole": "pas de vraie vie" }, + "valid": false + }, + { + "description": "unicode matching is case-sensitive", + "data": { "L'ÉCOLE": "PAS DE VRAIE VIE" }, + "valid": false + } + ] + }, + { + "description": "unicode characters do not match ascii ranges", + "schema": { + "type": "object", + "patternProperties": { + "[a-z]cole": {} + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "literal unicode character in json string", + "data": { "l'école": "pas de vraie vie" }, + "valid": false + }, + { + "description": "unicode character in hex format in string", + "data": { "l'\u00e9cole": "pas de vraie vie" }, + "valid": false + }, + { + "description": "ascii characters match", + "data": { "l'ecole": "pas de vraie vie" }, + "valid": true + } + ] + }, + { + "description": "\\d in patternProperties matches [0-9], not unicode digits", + "schema": { + "type": "object", + "patternProperties": { + "^\\d+$": {} + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "ascii digits", + "data": { "42": "life, the universe, and everything" }, + "valid": true + }, + { + "description": "ascii non-digits", + "data": { "-%#": "spending the year dead for tax reasons" }, + "valid": false + }, + { + "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", + "data": { "৪২": "khajit has wares if you have coin" }, + "valid": false + } + ] + }, + { + "description": "unicode digits are more than 0 through 9", + "schema": { + "type": "object", + "patternProperties": { + "^\\p{digit}+$": {} + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "ascii digits", + "data": { "42": "life, the universe, and everything" }, + "valid": true + }, + { + "description": "ascii non-digits", + "data": { "-%#": "spending the year dead for tax reasons" }, + "valid": false + }, + { + "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", + "data": { "৪২": "khajit has wares if you have coin" }, + "valid": true + } + ] } ] diff --git a/tests/draft4/optional/format/date-time.json b/tests/draft4/optional/format/date-time.json index 5f911ef..119179c 100644 --- a/tests/draft4/optional/format/date-time.json +++ b/tests/draft4/optional/format/date-time.json @@ -1,8 +1,38 @@ [ { "description": "validation of date-time strings", - "schema": {"format": "date-time"}, + "schema": { "format": "date-time" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid date-time string", "data": "1963-06-19T08:30:06.283185Z", @@ -33,6 +63,11 @@ "data": "1990-12-31T15:59:60-24:00", "valid": false }, + { + "description": "an invalid closing Z after time-zone offset", + "data": "1963-06-19T08:30:06.28123+01:00Z", + "valid": false + }, { "description": "an invalid date-time string", "data": "06/19/1963 08:30:06 PST", diff --git a/tests/draft4/optional/format/email.json b/tests/draft4/optional/format/email.json index 02396d2..d6761a4 100644 --- a/tests/draft4/optional/format/email.json +++ b/tests/draft4/optional/format/email.json @@ -1,8 +1,38 @@ [ { "description": "validation of e-mail addresses", - "schema": {"format": "email"}, + "schema": { "format": "email" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid e-mail address", "data": "joe.bloggs@example.com", diff --git a/tests/draft4/optional/format/hostname.json b/tests/draft4/optional/format/hostname.json index e913aba..8a67fda 100644 --- a/tests/draft4/optional/format/hostname.json +++ b/tests/draft4/optional/format/hostname.json @@ -1,13 +1,48 @@ [ { "description": "validation of host names", - "schema": {"format": "hostname"}, + "schema": { "format": "hostname" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid host name", "data": "www.example.com", "valid": true }, + { + "description": "a valid punycoded IDN hostname", + "data": "xn--4gbwdl.xn--wgbh1c", + "valid": true + }, { "description": "a host name starting with an illegal character", "data": "-a-host-name-that-starts-with--", @@ -61,4 +96,3 @@ ] } ] - diff --git a/tests/draft4/optional/format/ipv4.json b/tests/draft4/optional/format/ipv4.json index 4d10927..6b166c7 100644 --- a/tests/draft4/optional/format/ipv4.json +++ b/tests/draft4/optional/format/ipv4.json @@ -1,8 +1,38 @@ [ { "description": "validation of IP addresses", - "schema": {"format": "ipv4"}, + "schema": { "format": "ipv4" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid IP address", "data": "192.168.0.1", diff --git a/tests/draft4/optional/format/ipv6.json b/tests/draft4/optional/format/ipv6.json index cf629c6..6379927 100644 --- a/tests/draft4/optional/format/ipv6.json +++ b/tests/draft4/optional/format/ipv6.json @@ -1,8 +1,38 @@ [ { "description": "validation of IPv6 addresses", - "schema": {"format": "ipv6"}, + "schema": { "format": "ipv6" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid IPv6 address", "data": "::1", @@ -13,6 +43,16 @@ "data": "12345::", "valid": false }, + { + "description": "trailing 4 hex symbols is valid", + "data": "::abef", + "valid": true + }, + { + "description": "trailing 5 hex symbols is invalid", + "data": "::abcef", + "valid": false + }, { "description": "an IPv6 address with too many components", "data": "1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1", @@ -53,6 +93,11 @@ "data": ":2:3:4::8", "valid": false }, + { + "description": "single set of double colons in the middle is valid", + "data": "1:d6::42", + "valid": true + }, { "description": "two sets of double colons is invalid", "data": "1::d6::42", diff --git a/tests/draft4/optional/format/uri.json b/tests/draft4/optional/format/uri.json index 58d3085..792d71a 100644 --- a/tests/draft4/optional/format/uri.json +++ b/tests/draft4/optional/format/uri.json @@ -1,7 +1,7 @@ [ { "description": "validation of URIs", - "schema": {"format": "uri"}, + "schema": { "format": "uri" }, "tests": [ { "description": "a valid URL with anchor tag", diff --git a/tests/draft4/optional/unicode.json b/tests/draft4/optional/unicode.json deleted file mode 100644 index 8e709b4..0000000 --- a/tests/draft4/optional/unicode.json +++ /dev/null @@ -1,146 +0,0 @@ -[ - { - "description": "unicode semantics should be used for all pattern matching", - "schema": { "pattern": "\\wcole" }, - "tests": [ - { - "description": "literal unicode character in json string", - "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.", - "valid": true - }, - { - "description": "unicode character in hex format in string", - "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.", - "valid": true - }, - { - "description": "unicode matching is case-sensitive", - "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.", - "valid": false - } - ] - }, - { - "description": "unicode characters do not match ascii ranges", - "schema": { "pattern": "[a-z]cole" }, - "tests": [ - { - "description": "literal unicode character in json string", - "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.", - "valid": false - }, - { - "description": "unicode character in hex format in string", - "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.", - "valid": false - }, - { - "description": "ascii characters match", - "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.", - "valid": true - } - ] - }, - { - "description": "unicode digits are more than 0 through 9", - "schema": { "pattern": "^\\d+$" }, - "tests": [ - { - "description": "ascii digits", - "data": "42", - "valid": true - }, - { - "description": "ascii non-digits", - "data": "-%#", - "valid": false - }, - { - "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", - "data": "৪২", - "valid": true - } - ] - }, - { - "description": "unicode semantics should be used for all patternProperties matching", - "schema": { - "type": "object", - "patternProperties": { - "\\wcole": {} - }, - "additionalProperties": false - }, - "tests": [ - { - "description": "literal unicode character in json string", - "data": { "l'école": "pas de vraie vie" }, - "valid": true - }, - { - "description": "unicode character in hex format in string", - "data": { "l'\u00e9cole": "pas de vraie vie" }, - "valid": true - }, - { - "description": "unicode matching is case-sensitive", - "data": { "L'ÉCOLE": "PAS DE VRAIE VIE" }, - "valid": false - } - ] - }, - { - "description": "unicode characters do not match ascii ranges", - "schema": { - "type": "object", - "patternProperties": { - "[a-z]cole": {} - }, - "additionalProperties": false - }, - "tests": [ - { - "description": "literal unicode character in json string", - "data": { "l'école": "pas de vraie vie" }, - "valid": false - }, - { - "description": "unicode character in hex format in string", - "data": { "l'\u00e9cole": "pas de vraie vie" }, - "valid": false - }, - { - "description": "ascii characters match", - "data": { "l'ecole": "pas de vraie vie" }, - "valid": true - } - ] - }, - { - "description": "unicode digits are more than 0 through 9", - "schema": { - "type": "object", - "patternProperties": { - "^\\d+$": {} - }, - "additionalProperties": false - }, - "tests": [ - { - "description": "ascii digits", - "data": { "42": "life, the universe, and everything" }, - "valid": true - }, - { - "description": "ascii non-digits", - "data": { "-%#": "spending the year dead for tax reasons" }, - "valid": false - }, - { - "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", - "data": { "৪২": "khajit has wares if you have coin" }, - "valid": true - } - ] - } -] diff --git a/tests/draft4/ref.json b/tests/draft4/ref.json index 7f5a211..d9978e9 100644 --- a/tests/draft4/ref.json +++ b/tests/draft4/ref.json @@ -182,17 +182,17 @@ "definitions": { "foo": { "id": "http://localhost:1234/sibling_id/foo.json", - "minimum": 2 + "type": "string" }, "base_foo": { "$comment": "this canonical uri is http://localhost:1234/sibling_id/base/foo.json", "id": "foo.json", - "minimum": 5 + "type": "number" } }, "allOf": [ { - "$comment": "$ref resolves to http://localhost:1234/sibling_id/base/foo.json, not ttp://localhost:1234/sibling_id/foo.json", + "$comment": "$ref resolves to http://localhost:1234/sibling_id/base/foo.json, not http://localhost:1234/sibling_id/foo.json", "id": "http://localhost:1234/sibling_id/", "$ref": "foo.json" } @@ -200,14 +200,14 @@ }, "tests": [ { - "description": "$ref resolves to /definitions/foo, data validates", - "data": 10, - "valid": true + "description": "$ref resolves to /definitions/base_foo, data does not validate", + "data": "a", + "valid": false }, { - "description": "$ref resolves to /definitions/foo, data does not validate", + "description": "$ref resolves to /definitions/base_foo, data validates", "data": 1, - "valid": false + "valid": true } ] }, @@ -467,5 +467,41 @@ "valid": true } ] + }, + { + "description": "id must be resolved against nearest parent, not just immediate parent", + "schema": { + "id": "http://example.com/a.json", + "definitions": { + "x": { + "id": "http://example.com/b/c.json", + "not": { + "definitions": { + "y": { + "id": "d.json", + "type": "number" + } + } + } + } + }, + "allOf": [ + { + "$ref": "http://example.com/b/d.json" + } + ] + }, + "tests": [ + { + "description": "number should pass", + "data": 1, + "valid": true + }, + { + "description": "non-number should fail", + "data": "a", + "valid": false + } + ] } ] diff --git a/tests/draft6/optional/ecmascript-regex.json b/tests/draft6/optional/ecmascript-regex.json index fb02e99..1beb0b3 100644 --- a/tests/draft6/optional/ecmascript-regex.json +++ b/tests/draft6/optional/ecmascript-regex.json @@ -288,5 +288,265 @@ "valid": true } ] + }, + { + "description": "unicode semantics should be used for all pattern matching", + "schema": { "pattern": "\\p{Letter}cole" }, + "tests": [ + { + "description": "ascii character in json string", + "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.", + "valid": true + }, + { + "description": "literal unicode character in json string", + "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.", + "valid": true + }, + { + "description": "unicode character in hex format in string", + "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.", + "valid": true + }, + { + "description": "unicode matching is case-sensitive", + "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.", + "valid": false + } + ] + }, + { + "description": "\\w in patterns matches [A-Za-z0-9_], not unicode letters", + "schema": { "pattern": "\\wcole" }, + "tests": [ + { + "description": "ascii character in json string", + "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.", + "valid": true + }, + { + "description": "literal unicode character in json string", + "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.", + "valid": false + }, + { + "description": "unicode character in hex format in string", + "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.", + "valid": false + }, + { + "description": "unicode matching is case-sensitive", + "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.", + "valid": false + } + ] + }, + { + "description": "unicode characters do not match ascii ranges", + "schema": { "pattern": "[a-z]cole" }, + "tests": [ + { + "description": "literal unicode character in json string", + "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.", + "valid": false + }, + { + "description": "unicode character in hex format in string", + "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.", + "valid": false + }, + { + "description": "ascii characters match", + "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.", + "valid": true + } + ] + }, + { + "description": "\\d in pattern matches [0-9], not unicode digits", + "schema": { "pattern": "^\\d+$" }, + "tests": [ + { + "description": "ascii digits", + "data": "42", + "valid": true + }, + { + "description": "ascii non-digits", + "data": "-%#", + "valid": false + }, + { + "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", + "data": "৪২", + "valid": false + } + ] + }, + { + "description": "unicode digits are more than 0 through 9", + "schema": { "pattern": "^\\p{digit}+$" }, + "tests": [ + { + "description": "ascii digits", + "data": "42", + "valid": true + }, + { + "description": "ascii non-digits", + "data": "-%#", + "valid": false + }, + { + "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", + "data": "৪২", + "valid": true + } + ] + }, + { + "description": "unicode semantics should be used for all patternProperties matching", + "schema": { + "type": "object", + "patternProperties": { + "\\p{Letter}cole": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "ascii character in json string", + "data": { "l'ecole": "pas de vraie vie" }, + "valid": true + }, + { + "description": "literal unicode character in json string", + "data": { "l'école": "pas de vraie vie" }, + "valid": true + }, + { + "description": "unicode character in hex format in string", + "data": { "l'\u00e9cole": "pas de vraie vie" }, + "valid": true + }, + { + "description": "unicode matching is case-sensitive", + "data": { "L'ÉCOLE": "PAS DE VRAIE VIE" }, + "valid": false + } + ] + }, + { + "description": "\\w in patternProperties matches [A-Za-z0-9_], not unicode letters", + "schema": { + "type": "object", + "patternProperties": { + "\\wcole": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "ascii character in json string", + "data": { "l'ecole": "pas de vraie vie" }, + "valid": true + }, + { + "description": "literal unicode character in json string", + "data": { "l'école": "pas de vraie vie" }, + "valid": false + }, + { + "description": "unicode character in hex format in string", + "data": { "l'\u00e9cole": "pas de vraie vie" }, + "valid": false + }, + { + "description": "unicode matching is case-sensitive", + "data": { "L'ÉCOLE": "PAS DE VRAIE VIE" }, + "valid": false + } + ] + }, + { + "description": "unicode characters do not match ascii ranges", + "schema": { + "type": "object", + "patternProperties": { + "[a-z]cole": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "literal unicode character in json string", + "data": { "l'école": "pas de vraie vie" }, + "valid": false + }, + { + "description": "unicode character in hex format in string", + "data": { "l'\u00e9cole": "pas de vraie vie" }, + "valid": false + }, + { + "description": "ascii characters match", + "data": { "l'ecole": "pas de vraie vie" }, + "valid": true + } + ] + }, + { + "description": "\\d in patternProperties matches [0-9], not unicode digits", + "schema": { + "type": "object", + "patternProperties": { + "^\\d+$": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "ascii digits", + "data": { "42": "life, the universe, and everything" }, + "valid": true + }, + { + "description": "ascii non-digits", + "data": { "-%#": "spending the year dead for tax reasons" }, + "valid": false + }, + { + "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", + "data": { "৪২": "khajit has wares if you have coin" }, + "valid": false + } + ] + }, + { + "description": "unicode digits are more than 0 through 9", + "schema": { + "type": "object", + "patternProperties": { + "^\\p{digit}+$": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "ascii digits", + "data": { "42": "life, the universe, and everything" }, + "valid": true + }, + { + "description": "ascii non-digits", + "data": { "-%#": "spending the year dead for tax reasons" }, + "valid": false + }, + { + "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", + "data": { "৪২": "khajit has wares if you have coin" }, + "valid": true + } + ] } ] diff --git a/tests/draft6/optional/format/date-time.json b/tests/draft6/optional/format/date-time.json index 2dd214a..119179c 100644 --- a/tests/draft6/optional/format/date-time.json +++ b/tests/draft6/optional/format/date-time.json @@ -1,8 +1,38 @@ [ { "description": "validation of date-time strings", - "schema": {"format": "date-time"}, + "schema": { "format": "date-time" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid date-time string", "data": "1963-06-19T08:30:06.283185Z", diff --git a/tests/draft6/optional/format/email.json b/tests/draft6/optional/format/email.json index 02396d2..d6761a4 100644 --- a/tests/draft6/optional/format/email.json +++ b/tests/draft6/optional/format/email.json @@ -1,8 +1,38 @@ [ { "description": "validation of e-mail addresses", - "schema": {"format": "email"}, + "schema": { "format": "email" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid e-mail address", "data": "joe.bloggs@example.com", diff --git a/tests/draft6/optional/format/hostname.json b/tests/draft6/optional/format/hostname.json index d7654e0..8a67fda 100644 --- a/tests/draft6/optional/format/hostname.json +++ b/tests/draft6/optional/format/hostname.json @@ -1,13 +1,48 @@ [ { "description": "validation of host names", - "schema": {"format": "hostname"}, + "schema": { "format": "hostname" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid host name", "data": "www.example.com", "valid": true }, + { + "description": "a valid punycoded IDN hostname", + "data": "xn--4gbwdl.xn--wgbh1c", + "valid": true + }, { "description": "a host name starting with an illegal character", "data": "-a-host-name-that-starts-with--", diff --git a/tests/draft6/optional/format/ipv4.json b/tests/draft6/optional/format/ipv4.json index 4d10927..6b166c7 100644 --- a/tests/draft6/optional/format/ipv4.json +++ b/tests/draft6/optional/format/ipv4.json @@ -1,8 +1,38 @@ [ { "description": "validation of IP addresses", - "schema": {"format": "ipv4"}, + "schema": { "format": "ipv4" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid IP address", "data": "192.168.0.1", diff --git a/tests/draft6/optional/format/ipv6.json b/tests/draft6/optional/format/ipv6.json index cf629c6..6379927 100644 --- a/tests/draft6/optional/format/ipv6.json +++ b/tests/draft6/optional/format/ipv6.json @@ -1,8 +1,38 @@ [ { "description": "validation of IPv6 addresses", - "schema": {"format": "ipv6"}, + "schema": { "format": "ipv6" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid IPv6 address", "data": "::1", @@ -13,6 +43,16 @@ "data": "12345::", "valid": false }, + { + "description": "trailing 4 hex symbols is valid", + "data": "::abef", + "valid": true + }, + { + "description": "trailing 5 hex symbols is invalid", + "data": "::abcef", + "valid": false + }, { "description": "an IPv6 address with too many components", "data": "1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1", @@ -53,6 +93,11 @@ "data": ":2:3:4::8", "valid": false }, + { + "description": "single set of double colons in the middle is valid", + "data": "1:d6::42", + "valid": true + }, { "description": "two sets of double colons is invalid", "data": "1::d6::42", diff --git a/tests/draft6/optional/format/json-pointer.json b/tests/draft6/optional/format/json-pointer.json index 65c2f06..a0346b5 100644 --- a/tests/draft6/optional/format/json-pointer.json +++ b/tests/draft6/optional/format/json-pointer.json @@ -1,8 +1,38 @@ [ { "description": "validation of JSON-pointers (JSON String Representation)", - "schema": {"format": "json-pointer"}, + "schema": { "format": "json-pointer" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid JSON-pointer", "data": "/foo/bar~0/baz~1/%a", diff --git a/tests/draft6/optional/format/uri-reference.json b/tests/draft6/optional/format/uri-reference.json index e4c9eef..7cdf228 100644 --- a/tests/draft6/optional/format/uri-reference.json +++ b/tests/draft6/optional/format/uri-reference.json @@ -1,8 +1,38 @@ [ { "description": "validation of URI References", - "schema": {"format": "uri-reference"}, + "schema": { "format": "uri-reference" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid URI", "data": "http://foo.bar/?baz=qux#quux", diff --git a/tests/draft6/optional/format/uri-template.json b/tests/draft6/optional/format/uri-template.json index 33ab76e..df355c5 100644 --- a/tests/draft6/optional/format/uri-template.json +++ b/tests/draft6/optional/format/uri-template.json @@ -1,8 +1,38 @@ [ { "description": "format: uri-template", - "schema": {"format": "uri-template"}, + "schema": { "format": "uri-template" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid uri-template", "data": "http://example.com/dictionary/{term:1}/{term}", diff --git a/tests/draft6/optional/format/uri.json b/tests/draft6/optional/format/uri.json index 58d3085..792d71a 100644 --- a/tests/draft6/optional/format/uri.json +++ b/tests/draft6/optional/format/uri.json @@ -1,7 +1,7 @@ [ { "description": "validation of URIs", - "schema": {"format": "uri"}, + "schema": { "format": "uri" }, "tests": [ { "description": "a valid URL with anchor tag", diff --git a/tests/draft6/optional/unicode.json b/tests/draft6/optional/unicode.json deleted file mode 100644 index 1dc5940..0000000 --- a/tests/draft6/optional/unicode.json +++ /dev/null @@ -1,146 +0,0 @@ -[ - { - "description": "unicode semantics should be used for all pattern matching", - "schema": { "pattern": "\\wcole" }, - "tests": [ - { - "description": "literal unicode character in json string", - "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.", - "valid": true - }, - { - "description": "unicode character in hex format in string", - "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.", - "valid": true - }, - { - "description": "unicode matching is case-sensitive", - "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.", - "valid": false - } - ] - }, - { - "description": "unicode characters do not match ascii ranges", - "schema": { "pattern": "[a-z]cole" }, - "tests": [ - { - "description": "literal unicode character in json string", - "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.", - "valid": false - }, - { - "description": "unicode character in hex format in string", - "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.", - "valid": false - }, - { - "description": "ascii characters match", - "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.", - "valid": true - } - ] - }, - { - "description": "unicode digits are more than 0 through 9", - "schema": { "pattern": "^\\d+$" }, - "tests": [ - { - "description": "ascii digits", - "data": "42", - "valid": true - }, - { - "description": "ascii non-digits", - "data": "-%#", - "valid": false - }, - { - "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", - "data": "৪২", - "valid": true - } - ] - }, - { - "description": "unicode semantics should be used for all patternProperties matching", - "schema": { - "type": "object", - "patternProperties": { - "\\wcole": true - }, - "additionalProperties": false - }, - "tests": [ - { - "description": "literal unicode character in json string", - "data": { "l'école": "pas de vraie vie" }, - "valid": true - }, - { - "description": "unicode character in hex format in string", - "data": { "l'\u00e9cole": "pas de vraie vie" }, - "valid": true - }, - { - "description": "unicode matching is case-sensitive", - "data": { "L'ÉCOLE": "PAS DE VRAIE VIE" }, - "valid": false - } - ] - }, - { - "description": "unicode characters do not match ascii ranges", - "schema": { - "type": "object", - "patternProperties": { - "[a-z]cole": true - }, - "additionalProperties": false - }, - "tests": [ - { - "description": "literal unicode character in json string", - "data": { "l'école": "pas de vraie vie" }, - "valid": false - }, - { - "description": "unicode character in hex format in string", - "data": { "l'\u00e9cole": "pas de vraie vie" }, - "valid": false - }, - { - "description": "ascii characters match", - "data": { "l'ecole": "pas de vraie vie" }, - "valid": true - } - ] - }, - { - "description": "unicode digits are more than 0 through 9", - "schema": { - "type": "object", - "patternProperties": { - "^\\d+$": true - }, - "additionalProperties": false - }, - "tests": [ - { - "description": "ascii digits", - "data": { "42": "life, the universe, and everything" }, - "valid": true - }, - { - "description": "ascii non-digits", - "data": { "-%#": "spending the year dead for tax reasons" }, - "valid": false - }, - { - "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", - "data": { "৪২": "khajit has wares if you have coin" }, - "valid": true - } - ] - } -] diff --git a/tests/draft6/ref.json b/tests/draft6/ref.json index 7780c3f..ce5caf6 100644 --- a/tests/draft6/ref.json +++ b/tests/draft6/ref.json @@ -182,17 +182,17 @@ "definitions": { "foo": { "$id": "http://localhost:1234/sibling_id/foo.json", - "minimum": 2 + "type": "string" }, "base_foo": { "$comment": "this canonical uri is http://localhost:1234/sibling_id/base/foo.json", "$id": "foo.json", - "minimum": 5 + "type": "number" } }, "allOf": [ { - "$comment": "$ref resolves to http://localhost:1234/sibling_id/base/foo.json, not ttp://localhost:1234/sibling_id/foo.json", + "$comment": "$ref resolves to http://localhost:1234/sibling_id/base/foo.json, not http://localhost:1234/sibling_id/foo.json", "$id": "http://localhost:1234/sibling_id/", "$ref": "foo.json" } @@ -200,14 +200,14 @@ }, "tests": [ { - "description": "$ref resolves to /definitions/foo, data validates", - "data": 10, - "valid": true + "description": "$ref resolves to /definitions/base_foo, data does not validate", + "data": "a", + "valid": false }, { - "description": "$ref resolves to /definitions/foo, data does not validate", + "description": "$ref resolves to /definitions/base_foo, data validates", "data": 1, - "valid": false + "valid": true } ] }, diff --git a/tests/draft7/optional/ecmascript-regex.json b/tests/draft7/optional/ecmascript-regex.json index fb02e99..1beb0b3 100644 --- a/tests/draft7/optional/ecmascript-regex.json +++ b/tests/draft7/optional/ecmascript-regex.json @@ -288,5 +288,265 @@ "valid": true } ] + }, + { + "description": "unicode semantics should be used for all pattern matching", + "schema": { "pattern": "\\p{Letter}cole" }, + "tests": [ + { + "description": "ascii character in json string", + "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.", + "valid": true + }, + { + "description": "literal unicode character in json string", + "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.", + "valid": true + }, + { + "description": "unicode character in hex format in string", + "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.", + "valid": true + }, + { + "description": "unicode matching is case-sensitive", + "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.", + "valid": false + } + ] + }, + { + "description": "\\w in patterns matches [A-Za-z0-9_], not unicode letters", + "schema": { "pattern": "\\wcole" }, + "tests": [ + { + "description": "ascii character in json string", + "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.", + "valid": true + }, + { + "description": "literal unicode character in json string", + "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.", + "valid": false + }, + { + "description": "unicode character in hex format in string", + "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.", + "valid": false + }, + { + "description": "unicode matching is case-sensitive", + "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.", + "valid": false + } + ] + }, + { + "description": "unicode characters do not match ascii ranges", + "schema": { "pattern": "[a-z]cole" }, + "tests": [ + { + "description": "literal unicode character in json string", + "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.", + "valid": false + }, + { + "description": "unicode character in hex format in string", + "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.", + "valid": false + }, + { + "description": "ascii characters match", + "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.", + "valid": true + } + ] + }, + { + "description": "\\d in pattern matches [0-9], not unicode digits", + "schema": { "pattern": "^\\d+$" }, + "tests": [ + { + "description": "ascii digits", + "data": "42", + "valid": true + }, + { + "description": "ascii non-digits", + "data": "-%#", + "valid": false + }, + { + "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", + "data": "৪২", + "valid": false + } + ] + }, + { + "description": "unicode digits are more than 0 through 9", + "schema": { "pattern": "^\\p{digit}+$" }, + "tests": [ + { + "description": "ascii digits", + "data": "42", + "valid": true + }, + { + "description": "ascii non-digits", + "data": "-%#", + "valid": false + }, + { + "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", + "data": "৪২", + "valid": true + } + ] + }, + { + "description": "unicode semantics should be used for all patternProperties matching", + "schema": { + "type": "object", + "patternProperties": { + "\\p{Letter}cole": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "ascii character in json string", + "data": { "l'ecole": "pas de vraie vie" }, + "valid": true + }, + { + "description": "literal unicode character in json string", + "data": { "l'école": "pas de vraie vie" }, + "valid": true + }, + { + "description": "unicode character in hex format in string", + "data": { "l'\u00e9cole": "pas de vraie vie" }, + "valid": true + }, + { + "description": "unicode matching is case-sensitive", + "data": { "L'ÉCOLE": "PAS DE VRAIE VIE" }, + "valid": false + } + ] + }, + { + "description": "\\w in patternProperties matches [A-Za-z0-9_], not unicode letters", + "schema": { + "type": "object", + "patternProperties": { + "\\wcole": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "ascii character in json string", + "data": { "l'ecole": "pas de vraie vie" }, + "valid": true + }, + { + "description": "literal unicode character in json string", + "data": { "l'école": "pas de vraie vie" }, + "valid": false + }, + { + "description": "unicode character in hex format in string", + "data": { "l'\u00e9cole": "pas de vraie vie" }, + "valid": false + }, + { + "description": "unicode matching is case-sensitive", + "data": { "L'ÉCOLE": "PAS DE VRAIE VIE" }, + "valid": false + } + ] + }, + { + "description": "unicode characters do not match ascii ranges", + "schema": { + "type": "object", + "patternProperties": { + "[a-z]cole": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "literal unicode character in json string", + "data": { "l'école": "pas de vraie vie" }, + "valid": false + }, + { + "description": "unicode character in hex format in string", + "data": { "l'\u00e9cole": "pas de vraie vie" }, + "valid": false + }, + { + "description": "ascii characters match", + "data": { "l'ecole": "pas de vraie vie" }, + "valid": true + } + ] + }, + { + "description": "\\d in patternProperties matches [0-9], not unicode digits", + "schema": { + "type": "object", + "patternProperties": { + "^\\d+$": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "ascii digits", + "data": { "42": "life, the universe, and everything" }, + "valid": true + }, + { + "description": "ascii non-digits", + "data": { "-%#": "spending the year dead for tax reasons" }, + "valid": false + }, + { + "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", + "data": { "৪২": "khajit has wares if you have coin" }, + "valid": false + } + ] + }, + { + "description": "unicode digits are more than 0 through 9", + "schema": { + "type": "object", + "patternProperties": { + "^\\p{digit}+$": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "ascii digits", + "data": { "42": "life, the universe, and everything" }, + "valid": true + }, + { + "description": "ascii non-digits", + "data": { "-%#": "spending the year dead for tax reasons" }, + "valid": false + }, + { + "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", + "data": { "৪২": "khajit has wares if you have coin" }, + "valid": true + } + ] } ] diff --git a/tests/draft7/optional/format/date-time.json b/tests/draft7/optional/format/date-time.json index 5f911ef..119179c 100644 --- a/tests/draft7/optional/format/date-time.json +++ b/tests/draft7/optional/format/date-time.json @@ -1,8 +1,38 @@ [ { "description": "validation of date-time strings", - "schema": {"format": "date-time"}, + "schema": { "format": "date-time" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid date-time string", "data": "1963-06-19T08:30:06.283185Z", @@ -33,6 +63,11 @@ "data": "1990-12-31T15:59:60-24:00", "valid": false }, + { + "description": "an invalid closing Z after time-zone offset", + "data": "1963-06-19T08:30:06.28123+01:00Z", + "valid": false + }, { "description": "an invalid date-time string", "data": "06/19/1963 08:30:06 PST", diff --git a/tests/draft7/optional/format/date.json b/tests/draft7/optional/format/date.json index 6cc2feb..b4f61ee 100644 --- a/tests/draft7/optional/format/date.json +++ b/tests/draft7/optional/format/date.json @@ -1,8 +1,38 @@ [ { "description": "validation of date strings", - "schema": {"format": "date"}, + "schema": { "format": "date" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid date string", "data": "1963-06-19", diff --git a/tests/draft7/optional/format/email.json b/tests/draft7/optional/format/email.json index 02396d2..d6761a4 100644 --- a/tests/draft7/optional/format/email.json +++ b/tests/draft7/optional/format/email.json @@ -1,8 +1,38 @@ [ { "description": "validation of e-mail addresses", - "schema": {"format": "email"}, + "schema": { "format": "email" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid e-mail address", "data": "joe.bloggs@example.com", diff --git a/tests/draft7/optional/format/hostname.json b/tests/draft7/optional/format/hostname.json index 476541a..8a67fda 100644 --- a/tests/draft7/optional/format/hostname.json +++ b/tests/draft7/optional/format/hostname.json @@ -1,8 +1,38 @@ [ { "description": "validation of host names", - "schema": {"format": "hostname"}, + "schema": { "format": "hostname" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid host name", "data": "www.example.com", diff --git a/tests/draft7/optional/format/idn-email.json b/tests/draft7/optional/format/idn-email.json index 552d106..6e21374 100644 --- a/tests/draft7/optional/format/idn-email.json +++ b/tests/draft7/optional/format/idn-email.json @@ -1,8 +1,38 @@ [ { "description": "validation of an internationalized e-mail addresses", - "schema": {"format": "idn-email"}, + "schema": { "format": "idn-email" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid idn e-mail (example@example.test in Hangul)", "data": "실례@실례.테스트", diff --git a/tests/draft7/optional/format/idn-hostname.json b/tests/draft7/optional/format/idn-hostname.json index 7f10bd8..6c8f86a 100644 --- a/tests/draft7/optional/format/idn-hostname.json +++ b/tests/draft7/optional/format/idn-hostname.json @@ -1,8 +1,38 @@ [ { "description": "validation of internationalized host names", - "schema": {"format": "idn-hostname"}, + "schema": { "format": "idn-hostname" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid host name (example.test in Hangul)", "data": "실례.테스트", @@ -91,7 +121,7 @@ }, { "description": "Exceptions that are PVALID, right-to-left chars", - "comment": "https://tools.ietf.org/html/rfc/rfc5891#section-4.2.2 https://tools.ietf.org/html/rfc5892#section-2.6", + "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.2 https://tools.ietf.org/html/rfc5892#section-2.6", "data": "\u06fd\u06fe", "valid": true }, diff --git a/tests/draft7/optional/format/ipv4.json b/tests/draft7/optional/format/ipv4.json index 4d10927..6b166c7 100644 --- a/tests/draft7/optional/format/ipv4.json +++ b/tests/draft7/optional/format/ipv4.json @@ -1,8 +1,38 @@ [ { "description": "validation of IP addresses", - "schema": {"format": "ipv4"}, + "schema": { "format": "ipv4" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid IP address", "data": "192.168.0.1", diff --git a/tests/draft7/optional/format/ipv6.json b/tests/draft7/optional/format/ipv6.json index cf629c6..6379927 100644 --- a/tests/draft7/optional/format/ipv6.json +++ b/tests/draft7/optional/format/ipv6.json @@ -1,8 +1,38 @@ [ { "description": "validation of IPv6 addresses", - "schema": {"format": "ipv6"}, + "schema": { "format": "ipv6" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid IPv6 address", "data": "::1", @@ -13,6 +43,16 @@ "data": "12345::", "valid": false }, + { + "description": "trailing 4 hex symbols is valid", + "data": "::abef", + "valid": true + }, + { + "description": "trailing 5 hex symbols is invalid", + "data": "::abcef", + "valid": false + }, { "description": "an IPv6 address with too many components", "data": "1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1", @@ -53,6 +93,11 @@ "data": ":2:3:4::8", "valid": false }, + { + "description": "single set of double colons in the middle is valid", + "data": "1:d6::42", + "valid": true + }, { "description": "two sets of double colons is invalid", "data": "1::d6::42", diff --git a/tests/draft7/optional/format/iri-reference.json b/tests/draft7/optional/format/iri-reference.json index 1fd779c..c6b4c22 100644 --- a/tests/draft7/optional/format/iri-reference.json +++ b/tests/draft7/optional/format/iri-reference.json @@ -1,8 +1,38 @@ [ { "description": "validation of IRI References", - "schema": {"format": "iri-reference"}, + "schema": { "format": "iri-reference" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid IRI", "data": "http://ƒøø.ßår/?∂éœ=πîx#πîüx", diff --git a/tests/draft7/optional/format/iri.json b/tests/draft7/optional/format/iri.json index 1414f2e..a0d12ae 100644 --- a/tests/draft7/optional/format/iri.json +++ b/tests/draft7/optional/format/iri.json @@ -1,8 +1,38 @@ [ { "description": "validation of IRIs", - "schema": {"format": "iri"}, + "schema": { "format": "iri" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid IRI with anchor tag", "data": "http://ƒøø.ßår/?∂éœ=πîx#πîüx", diff --git a/tests/draft7/optional/format/json-pointer.json b/tests/draft7/optional/format/json-pointer.json index 65c2f06..a0346b5 100644 --- a/tests/draft7/optional/format/json-pointer.json +++ b/tests/draft7/optional/format/json-pointer.json @@ -1,8 +1,38 @@ [ { "description": "validation of JSON-pointers (JSON String Representation)", - "schema": {"format": "json-pointer"}, + "schema": { "format": "json-pointer" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid JSON-pointer", "data": "/foo/bar~0/baz~1/%a", diff --git a/tests/draft7/optional/format/regex.json b/tests/draft7/optional/format/regex.json index d99d021..3449177 100644 --- a/tests/draft7/optional/format/regex.json +++ b/tests/draft7/optional/format/regex.json @@ -1,8 +1,38 @@ [ { "description": "validation of regular expressions", - "schema": {"format": "regex"}, + "schema": { "format": "regex" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid regular expression", "data": "([abc])+\\s+$", diff --git a/tests/draft7/optional/format/relative-json-pointer.json b/tests/draft7/optional/format/relative-json-pointer.json index 22fb14e..9309986 100644 --- a/tests/draft7/optional/format/relative-json-pointer.json +++ b/tests/draft7/optional/format/relative-json-pointer.json @@ -1,8 +1,38 @@ [ { "description": "validation of Relative JSON Pointers (RJP)", - "schema": {"format": "relative-json-pointer"}, + "schema": { "format": "relative-json-pointer" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid upwards RJP", "data": "1", diff --git a/tests/draft7/optional/format/time.json b/tests/draft7/optional/format/time.json index 0a8da0e..5011d78 100644 --- a/tests/draft7/optional/format/time.json +++ b/tests/draft7/optional/format/time.json @@ -1,8 +1,38 @@ [ { "description": "validation of time strings", - "schema": {"format": "time"}, + "schema": { "format": "time" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid time string", "data": "08:30:06Z", diff --git a/tests/draft7/optional/format/uri-reference.json b/tests/draft7/optional/format/uri-reference.json index e4c9eef..7cdf228 100644 --- a/tests/draft7/optional/format/uri-reference.json +++ b/tests/draft7/optional/format/uri-reference.json @@ -1,8 +1,38 @@ [ { "description": "validation of URI References", - "schema": {"format": "uri-reference"}, + "schema": { "format": "uri-reference" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid URI", "data": "http://foo.bar/?baz=qux#quux", diff --git a/tests/draft7/optional/format/uri-template.json b/tests/draft7/optional/format/uri-template.json index 33ab76e..df355c5 100644 --- a/tests/draft7/optional/format/uri-template.json +++ b/tests/draft7/optional/format/uri-template.json @@ -1,8 +1,38 @@ [ { "description": "format: uri-template", - "schema": {"format": "uri-template"}, + "schema": { "format": "uri-template" }, "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, { "description": "a valid uri-template", "data": "http://example.com/dictionary/{term:1}/{term}", diff --git a/tests/draft7/optional/format/uri.json b/tests/draft7/optional/format/uri.json index 58d3085..792d71a 100644 --- a/tests/draft7/optional/format/uri.json +++ b/tests/draft7/optional/format/uri.json @@ -1,7 +1,7 @@ [ { "description": "validation of URIs", - "schema": {"format": "uri"}, + "schema": { "format": "uri" }, "tests": [ { "description": "a valid URL with anchor tag", diff --git a/tests/draft7/optional/unicode.json b/tests/draft7/optional/unicode.json deleted file mode 100644 index 1dc5940..0000000 --- a/tests/draft7/optional/unicode.json +++ /dev/null @@ -1,146 +0,0 @@ -[ - { - "description": "unicode semantics should be used for all pattern matching", - "schema": { "pattern": "\\wcole" }, - "tests": [ - { - "description": "literal unicode character in json string", - "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.", - "valid": true - }, - { - "description": "unicode character in hex format in string", - "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.", - "valid": true - }, - { - "description": "unicode matching is case-sensitive", - "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.", - "valid": false - } - ] - }, - { - "description": "unicode characters do not match ascii ranges", - "schema": { "pattern": "[a-z]cole" }, - "tests": [ - { - "description": "literal unicode character in json string", - "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.", - "valid": false - }, - { - "description": "unicode character in hex format in string", - "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.", - "valid": false - }, - { - "description": "ascii characters match", - "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.", - "valid": true - } - ] - }, - { - "description": "unicode digits are more than 0 through 9", - "schema": { "pattern": "^\\d+$" }, - "tests": [ - { - "description": "ascii digits", - "data": "42", - "valid": true - }, - { - "description": "ascii non-digits", - "data": "-%#", - "valid": false - }, - { - "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", - "data": "৪২", - "valid": true - } - ] - }, - { - "description": "unicode semantics should be used for all patternProperties matching", - "schema": { - "type": "object", - "patternProperties": { - "\\wcole": true - }, - "additionalProperties": false - }, - "tests": [ - { - "description": "literal unicode character in json string", - "data": { "l'école": "pas de vraie vie" }, - "valid": true - }, - { - "description": "unicode character in hex format in string", - "data": { "l'\u00e9cole": "pas de vraie vie" }, - "valid": true - }, - { - "description": "unicode matching is case-sensitive", - "data": { "L'ÉCOLE": "PAS DE VRAIE VIE" }, - "valid": false - } - ] - }, - { - "description": "unicode characters do not match ascii ranges", - "schema": { - "type": "object", - "patternProperties": { - "[a-z]cole": true - }, - "additionalProperties": false - }, - "tests": [ - { - "description": "literal unicode character in json string", - "data": { "l'école": "pas de vraie vie" }, - "valid": false - }, - { - "description": "unicode character in hex format in string", - "data": { "l'\u00e9cole": "pas de vraie vie" }, - "valid": false - }, - { - "description": "ascii characters match", - "data": { "l'ecole": "pas de vraie vie" }, - "valid": true - } - ] - }, - { - "description": "unicode digits are more than 0 through 9", - "schema": { - "type": "object", - "patternProperties": { - "^\\d+$": true - }, - "additionalProperties": false - }, - "tests": [ - { - "description": "ascii digits", - "data": { "42": "life, the universe, and everything" }, - "valid": true - }, - { - "description": "ascii non-digits", - "data": { "-%#": "spending the year dead for tax reasons" }, - "valid": false - }, - { - "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", - "data": { "৪২": "khajit has wares if you have coin" }, - "valid": true - } - ] - } -] diff --git a/tests/draft7/ref.json b/tests/draft7/ref.json index ff98d79..764d637 100644 --- a/tests/draft7/ref.json +++ b/tests/draft7/ref.json @@ -182,17 +182,17 @@ "definitions": { "foo": { "$id": "http://localhost:1234/sibling_id/foo.json", - "minimum": 2 + "type": "string" }, "base_foo": { "$comment": "this canonical uri is http://localhost:1234/sibling_id/base/foo.json", "$id": "foo.json", - "minimum": 5 + "type": "number" } }, "allOf": [ { - "$comment": "$ref resolves to http://localhost:1234/sibling_id/base/foo.json, not ttp://localhost:1234/sibling_id/foo.json", + "$comment": "$ref resolves to http://localhost:1234/sibling_id/base/foo.json, not http://localhost:1234/sibling_id/foo.json", "$id": "http://localhost:1234/sibling_id/", "$ref": "foo.json" } @@ -200,14 +200,14 @@ }, "tests": [ { - "description": "$ref resolves to /definitions/foo, data validates", - "data": 10, - "valid": true + "description": "$ref resolves to /definitions/base_foo, data does not validate", + "data": "a", + "valid": false }, { - "description": "$ref resolves to /definitions/foo, data does not validate", + "description": "$ref resolves to /definitions/base_foo, data validates", "data": 1, - "valid": false + "valid": true } ] }, @@ -608,5 +608,41 @@ "valid": true } ] + }, + { + "description": "$id must be resolved against nearest parent, not just immediate parent", + "schema": { + "$id": "http://example.com/a.json", + "definitions": { + "x": { + "$id": "http://example.com/b/c.json", + "not": { + "definitions": { + "y": { + "$id": "d.json", + "type": "number" + } + } + } + } + }, + "allOf": [ + { + "$ref": "http://example.com/b/d.json" + } + ] + }, + "tests": [ + { + "description": "number should pass", + "data": 1, + "valid": true + }, + { + "description": "non-number should fail", + "data": "a", + "valid": false + } + ] } ] diff --git a/tox.ini b/tox.ini index 72fd562..a6c860a 100644 --- a/tox.ini +++ b/tox.ini @@ -5,5 +5,5 @@ skipsdist = True [testenv:sanity] # used just for validating the structure of the test case files themselves -deps = jsonschema>=3.2.0 +deps = jsonschema==3.2.0 commands = {envpython} bin/jsonschema_suite check -- cgit v1.2.1