├── .cursor └── golang-rules.mdc ├── .editorconfig ├── .golangci.version ├── .golangci.yml ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── additionalProperties.go ├── allOf.go ├── anyOf.go ├── compiler.go ├── compiler_test.go ├── conditional.go ├── const.go ├── constructor.go ├── constructor_test.go ├── contains.go ├── content.go ├── dependentRequired.go ├── dependentSchemas.go ├── docs ├── api.md ├── compilation.md ├── constructor.md ├── error-handling.md ├── unmarshal.md └── validation.md ├── enum.go ├── errors.go ├── examples ├── README.md ├── basic │ ├── README.md │ └── main.go ├── constructor ├── error-handling │ ├── README.md │ └── main.go ├── i18n │ ├── README.md │ └── main.go ├── multiple-input-types │ ├── README.md │ └── main.go ├── struct-validation │ ├── README.md │ └── main.go └── unmarshaling │ ├── README.md │ └── main.go ├── exclusiveMaximum.go ├── exclusiveMinimum.go ├── format.go ├── formats.go ├── go.mod ├── go.sum ├── i18n.go ├── id.go ├── items.go ├── keywords.go ├── keywords_test.go ├── locales ├── de-DE.json ├── en.json ├── es-ES.json ├── fr-FR.json ├── ja-JP.json ├── ko-KR.json ├── pt-BR.json ├── zh-Hans.json └── zh-Hant.json ├── maxItems.go ├── maxProperties.go ├── maximum.go ├── maxlength.go ├── minItems.go ├── minProperties.go ├── minimum.go ├── minlength.go ├── multipleOf.go ├── not.go ├── oneOf.go ├── pattern.go ├── patternProperties.go ├── prefixItems.go ├── properties.go ├── propertyNames.go ├── rat.go ├── readme.md ├── ref.go ├── required.go ├── result.go ├── result_test.go ├── schema.go ├── schema_test.go ├── struct_validation.go ├── struct_validation_test.go ├── testdata └── JSON-Schema-Test-Suite │ ├── .editorconfig │ ├── .github │ ├── CODEOWNERS │ └── workflows │ │ └── ci.yml │ ├── CONTRIBUTING.md │ ├── LICENSE │ ├── README.md │ ├── output-test-schema.json │ ├── output-tests │ ├── README.md │ ├── draft-next │ │ ├── content │ │ │ ├── general.json │ │ │ ├── readOnly.json │ │ │ └── type.json │ │ └── output-schema.json │ ├── draft2019-09 │ │ ├── content │ │ │ ├── escape.json │ │ │ ├── general.json │ │ │ ├── readOnly.json │ │ │ └── type.json │ │ └── output-schema.json │ └── draft2020-12 │ │ ├── content │ │ ├── escape.json │ │ ├── general.json │ │ ├── readOnly.json │ │ └── type.json │ │ └── output-schema.json │ ├── package.json │ ├── remotes │ ├── baseUriChange │ │ └── folderInteger.json │ ├── baseUriChangeFolder │ │ └── folderInteger.json │ ├── baseUriChangeFolderInSubschema │ │ └── folderInteger.json │ ├── different-id-ref-string.json │ ├── draft-next │ │ ├── baseUriChange │ │ │ └── folderInteger.json │ │ ├── baseUriChangeFolder │ │ │ └── folderInteger.json │ │ ├── baseUriChangeFolderInSubschema │ │ │ └── folderInteger.json │ │ ├── detached-dynamicref.json │ │ ├── detached-ref.json │ │ ├── extendible-dynamic-ref.json │ │ ├── format-assertion-false.json │ │ ├── format-assertion-true.json │ │ ├── integer.json │ │ ├── locationIndependentIdentifier.json │ │ ├── metaschema-no-validation.json │ │ ├── metaschema-optional-vocabulary.json │ │ ├── name-defs.json │ │ ├── nested │ │ │ ├── foo-ref-string.json │ │ │ └── string.json │ │ ├── ref-and-defs.json │ │ ├── subSchemas.json │ │ └── tree.json │ ├── draft2019-09 │ │ ├── baseUriChange │ │ │ └── folderInteger.json │ │ ├── baseUriChangeFolder │ │ │ └── folderInteger.json │ │ ├── baseUriChangeFolderInSubschema │ │ │ └── folderInteger.json │ │ ├── dependentRequired.json │ │ ├── detached-ref.json │ │ ├── extendible-dynamic-ref.json │ │ ├── ignore-prefixItems.json │ │ ├── integer.json │ │ ├── locationIndependentIdentifier.json │ │ ├── metaschema-no-validation.json │ │ ├── metaschema-optional-vocabulary.json │ │ ├── name-defs.json │ │ ├── nested │ │ │ ├── foo-ref-string.json │ │ │ └── string.json │ │ ├── ref-and-defs.json │ │ ├── subSchemas.json │ │ └── tree.json │ ├── draft2020-12 │ │ ├── baseUriChange │ │ │ └── folderInteger.json │ │ ├── baseUriChangeFolder │ │ │ └── folderInteger.json │ │ ├── baseUriChangeFolderInSubschema │ │ │ └── folderInteger.json │ │ ├── detached-dynamicref.json │ │ ├── detached-ref.json │ │ ├── extendible-dynamic-ref.json │ │ ├── format-assertion-false.json │ │ ├── format-assertion-true.json │ │ ├── integer.json │ │ ├── locationIndependentIdentifier.json │ │ ├── metaschema-no-validation.json │ │ ├── metaschema-optional-vocabulary.json │ │ ├── name-defs.json │ │ ├── nested │ │ │ ├── foo-ref-string.json │ │ │ └── string.json │ │ ├── prefixItems.json │ │ ├── ref-and-defs.json │ │ ├── subSchemas.json │ │ └── tree.json │ ├── draft6 │ │ └── detached-ref.json │ ├── draft7 │ │ ├── detached-ref.json │ │ └── ignore-dependentRequired.json │ ├── extendible-dynamic-ref.json │ ├── integer.json │ ├── locationIndependentIdentifier.json │ ├── locationIndependentIdentifierDraft4.json │ ├── locationIndependentIdentifierPre2019.json │ ├── name-defs.json │ ├── name.json │ ├── nested-absolute-ref-to-string.json │ ├── nested │ │ ├── foo-ref-string.json │ │ └── string.json │ ├── ref-and-definitions.json │ ├── ref-and-defs.json │ ├── subSchemas.json │ ├── tree.json │ └── urn-ref-string.json │ ├── test-schema.json │ ├── tests │ ├── draft-next │ │ ├── additionalProperties.json │ │ ├── allOf.json │ │ ├── anchor.json │ │ ├── anyOf.json │ │ ├── boolean_schema.json │ │ ├── const.json │ │ ├── contains.json │ │ ├── content.json │ │ ├── default.json │ │ ├── defs.json │ │ ├── dependentRequired.json │ │ ├── dependentSchemas.json │ │ ├── dynamicRef.json │ │ ├── enum.json │ │ ├── exclusiveMaximum.json │ │ ├── exclusiveMinimum.json │ │ ├── format.json │ │ ├── if-then-else.json │ │ ├── infinite-loop-detection.json │ │ ├── items.json │ │ ├── maxContains.json │ │ ├── maxItems.json │ │ ├── maxLength.json │ │ ├── maxProperties.json │ │ ├── maximum.json │ │ ├── minContains.json │ │ ├── minItems.json │ │ ├── minLength.json │ │ ├── minProperties.json │ │ ├── minimum.json │ │ ├── multipleOf.json │ │ ├── not.json │ │ ├── oneOf.json │ │ ├── optional │ │ │ ├── anchor.json │ │ │ ├── bignum.json │ │ │ ├── dependencies-compatibility.json │ │ │ ├── dynamicRef.json │ │ │ ├── ecmascript-regex.json │ │ │ ├── float-overflow.json │ │ │ ├── format-assertion.json │ │ │ ├── format │ │ │ │ ├── date-time.json │ │ │ │ ├── date.json │ │ │ │ ├── duration.json │ │ │ │ ├── email.json │ │ │ │ ├── hostname.json │ │ │ │ ├── idn-email.json │ │ │ │ ├── idn-hostname.json │ │ │ │ ├── ipv4.json │ │ │ │ ├── ipv6.json │ │ │ │ ├── iri-reference.json │ │ │ │ ├── iri.json │ │ │ │ ├── json-pointer.json │ │ │ │ ├── regex.json │ │ │ │ ├── relative-json-pointer.json │ │ │ │ ├── time.json │ │ │ │ ├── uri-reference.json │ │ │ │ ├── uri-template.json │ │ │ │ ├── uri.json │ │ │ │ └── uuid.json │ │ │ ├── id.json │ │ │ ├── non-bmp-regex.json │ │ │ ├── refOfUnknownKeyword.json │ │ │ └── unknownKeyword.json │ │ ├── pattern.json │ │ ├── patternProperties.json │ │ ├── prefixItems.json │ │ ├── properties.json │ │ ├── propertyDependencies.json │ │ ├── propertyNames.json │ │ ├── ref.json │ │ ├── refRemote.json │ │ ├── required.json │ │ ├── type.json │ │ ├── unevaluatedItems.json │ │ ├── unevaluatedProperties.json │ │ ├── uniqueItems.json │ │ └── vocabulary.json │ ├── draft2019-09 │ │ ├── additionalItems.json │ │ ├── additionalProperties.json │ │ ├── allOf.json │ │ ├── anchor.json │ │ ├── anyOf.json │ │ ├── boolean_schema.json │ │ ├── const.json │ │ ├── contains.json │ │ ├── content.json │ │ ├── default.json │ │ ├── defs.json │ │ ├── dependentRequired.json │ │ ├── dependentSchemas.json │ │ ├── enum.json │ │ ├── exclusiveMaximum.json │ │ ├── exclusiveMinimum.json │ │ ├── format.json │ │ ├── if-then-else.json │ │ ├── infinite-loop-detection.json │ │ ├── items.json │ │ ├── maxContains.json │ │ ├── maxItems.json │ │ ├── maxLength.json │ │ ├── maxProperties.json │ │ ├── maximum.json │ │ ├── minContains.json │ │ ├── minItems.json │ │ ├── minLength.json │ │ ├── minProperties.json │ │ ├── minimum.json │ │ ├── multipleOf.json │ │ ├── not.json │ │ ├── oneOf.json │ │ ├── optional │ │ │ ├── anchor.json │ │ │ ├── bignum.json │ │ │ ├── cross-draft.json │ │ │ ├── dependencies-compatibility.json │ │ │ ├── ecmascript-regex.json │ │ │ ├── float-overflow.json │ │ │ ├── format │ │ │ │ ├── date-time.json │ │ │ │ ├── date.json │ │ │ │ ├── duration.json │ │ │ │ ├── email.json │ │ │ │ ├── hostname.json │ │ │ │ ├── idn-email.json │ │ │ │ ├── idn-hostname.json │ │ │ │ ├── ipv4.json │ │ │ │ ├── ipv6.json │ │ │ │ ├── iri-reference.json │ │ │ │ ├── iri.json │ │ │ │ ├── json-pointer.json │ │ │ │ ├── regex.json │ │ │ │ ├── relative-json-pointer.json │ │ │ │ ├── time.json │ │ │ │ ├── unknown.json │ │ │ │ ├── uri-reference.json │ │ │ │ ├── uri-template.json │ │ │ │ ├── uri.json │ │ │ │ └── uuid.json │ │ │ ├── id.json │ │ │ ├── no-schema.json │ │ │ ├── non-bmp-regex.json │ │ │ ├── refOfUnknownKeyword.json │ │ │ └── unknownKeyword.json │ │ ├── pattern.json │ │ ├── patternProperties.json │ │ ├── properties.json │ │ ├── propertyNames.json │ │ ├── recursiveRef.json │ │ ├── ref.json │ │ ├── refRemote.json │ │ ├── required.json │ │ ├── type.json │ │ ├── unevaluatedItems.json │ │ ├── unevaluatedProperties.json │ │ ├── uniqueItems.json │ │ └── vocabulary.json │ ├── draft2020-12 │ │ ├── additionalProperties.json │ │ ├── allOf.json │ │ ├── anchor.json │ │ ├── anyOf.json │ │ ├── boolean_schema.json │ │ ├── const.json │ │ ├── contains.json │ │ ├── content.json │ │ ├── default.json │ │ ├── defs.json │ │ ├── dependentRequired.json │ │ ├── dependentSchemas.json │ │ ├── dynamicRef.json │ │ ├── enum.json │ │ ├── exclusiveMaximum.json │ │ ├── exclusiveMinimum.json │ │ ├── format.json │ │ ├── if-then-else.json │ │ ├── infinite-loop-detection.json │ │ ├── items.json │ │ ├── maxContains.json │ │ ├── maxItems.json │ │ ├── maxLength.json │ │ ├── maxProperties.json │ │ ├── maximum.json │ │ ├── minContains.json │ │ ├── minItems.json │ │ ├── minLength.json │ │ ├── minProperties.json │ │ ├── minimum.json │ │ ├── multipleOf.json │ │ ├── not.json │ │ ├── oneOf.json │ │ ├── optional │ │ │ ├── anchor.json │ │ │ ├── bignum.json │ │ │ ├── cross-draft.json │ │ │ ├── dependencies-compatibility.json │ │ │ ├── dynamicRef.json │ │ │ ├── ecmascript-regex.json │ │ │ ├── float-overflow.json │ │ │ ├── format-assertion.json │ │ │ ├── format │ │ │ │ ├── date-time.json │ │ │ │ ├── date.json │ │ │ │ ├── duration.json │ │ │ │ ├── email.json │ │ │ │ ├── hostname.json │ │ │ │ ├── idn-email.json │ │ │ │ ├── idn-hostname.json │ │ │ │ ├── ipv4.json │ │ │ │ ├── ipv6.json │ │ │ │ ├── iri-reference.json │ │ │ │ ├── iri.json │ │ │ │ ├── json-pointer.json │ │ │ │ ├── regex.json │ │ │ │ ├── relative-json-pointer.json │ │ │ │ ├── time.json │ │ │ │ ├── unknown.json │ │ │ │ ├── uri-reference.json │ │ │ │ ├── uri-template.json │ │ │ │ ├── uri.json │ │ │ │ └── uuid.json │ │ │ ├── id.json │ │ │ ├── no-schema.json │ │ │ ├── non-bmp-regex.json │ │ │ ├── refOfUnknownKeyword.json │ │ │ └── unknownKeyword.json │ │ ├── pattern.json │ │ ├── patternProperties.json │ │ ├── prefixItems.json │ │ ├── properties.json │ │ ├── propertyNames.json │ │ ├── ref.json │ │ ├── refRemote.json │ │ ├── required.json │ │ ├── type.json │ │ ├── unevaluatedItems.json │ │ ├── unevaluatedProperties.json │ │ ├── uniqueItems.json │ │ └── vocabulary.json │ ├── draft3 │ │ ├── additionalItems.json │ │ ├── additionalProperties.json │ │ ├── default.json │ │ ├── dependencies.json │ │ ├── disallow.json │ │ ├── divisibleBy.json │ │ ├── enum.json │ │ ├── extends.json │ │ ├── format.json │ │ ├── infinite-loop-detection.json │ │ ├── items.json │ │ ├── maxItems.json │ │ ├── maxLength.json │ │ ├── maximum.json │ │ ├── minItems.json │ │ ├── minLength.json │ │ ├── minimum.json │ │ ├── optional │ │ │ ├── bignum.json │ │ │ ├── ecmascript-regex.json │ │ │ ├── format │ │ │ │ ├── color.json │ │ │ │ ├── date-time.json │ │ │ │ ├── date.json │ │ │ │ ├── email.json │ │ │ │ ├── host-name.json │ │ │ │ ├── ip-address.json │ │ │ │ ├── ipv6.json │ │ │ │ ├── regex.json │ │ │ │ ├── time.json │ │ │ │ └── uri.json │ │ │ ├── non-bmp-regex.json │ │ │ └── zeroTerminatedFloats.json │ │ ├── pattern.json │ │ ├── patternProperties.json │ │ ├── properties.json │ │ ├── ref.json │ │ ├── refRemote.json │ │ ├── required.json │ │ ├── type.json │ │ └── uniqueItems.json │ ├── draft4 │ │ ├── additionalItems.json │ │ ├── additionalProperties.json │ │ ├── allOf.json │ │ ├── anyOf.json │ │ ├── default.json │ │ ├── definitions.json │ │ ├── dependencies.json │ │ ├── enum.json │ │ ├── format.json │ │ ├── infinite-loop-detection.json │ │ ├── items.json │ │ ├── maxItems.json │ │ ├── maxLength.json │ │ ├── maxProperties.json │ │ ├── maximum.json │ │ ├── minItems.json │ │ ├── minLength.json │ │ ├── minProperties.json │ │ ├── minimum.json │ │ ├── multipleOf.json │ │ ├── not.json │ │ ├── oneOf.json │ │ ├── optional │ │ │ ├── bignum.json │ │ │ ├── ecmascript-regex.json │ │ │ ├── float-overflow.json │ │ │ ├── format │ │ │ │ ├── date-time.json │ │ │ │ ├── email.json │ │ │ │ ├── hostname.json │ │ │ │ ├── ipv4.json │ │ │ │ ├── ipv6.json │ │ │ │ ├── unknown.json │ │ │ │ └── uri.json │ │ │ ├── id.json │ │ │ ├── non-bmp-regex.json │ │ │ └── zeroTerminatedFloats.json │ │ ├── pattern.json │ │ ├── patternProperties.json │ │ ├── properties.json │ │ ├── ref.json │ │ ├── refRemote.json │ │ ├── required.json │ │ ├── type.json │ │ └── uniqueItems.json │ ├── draft6 │ │ ├── additionalItems.json │ │ ├── additionalProperties.json │ │ ├── allOf.json │ │ ├── anyOf.json │ │ ├── boolean_schema.json │ │ ├── const.json │ │ ├── contains.json │ │ ├── default.json │ │ ├── definitions.json │ │ ├── dependencies.json │ │ ├── enum.json │ │ ├── exclusiveMaximum.json │ │ ├── exclusiveMinimum.json │ │ ├── format.json │ │ ├── infinite-loop-detection.json │ │ ├── items.json │ │ ├── maxItems.json │ │ ├── maxLength.json │ │ ├── maxProperties.json │ │ ├── maximum.json │ │ ├── minItems.json │ │ ├── minLength.json │ │ ├── minProperties.json │ │ ├── minimum.json │ │ ├── multipleOf.json │ │ ├── not.json │ │ ├── oneOf.json │ │ ├── optional │ │ │ ├── bignum.json │ │ │ ├── ecmascript-regex.json │ │ │ ├── float-overflow.json │ │ │ ├── format │ │ │ │ ├── date-time.json │ │ │ │ ├── email.json │ │ │ │ ├── hostname.json │ │ │ │ ├── ipv4.json │ │ │ │ ├── ipv6.json │ │ │ │ ├── json-pointer.json │ │ │ │ ├── unknown.json │ │ │ │ ├── uri-reference.json │ │ │ │ ├── uri-template.json │ │ │ │ └── uri.json │ │ │ ├── id.json │ │ │ ├── non-bmp-regex.json │ │ │ └── unknownKeyword.json │ │ ├── pattern.json │ │ ├── patternProperties.json │ │ ├── properties.json │ │ ├── propertyNames.json │ │ ├── ref.json │ │ ├── refRemote.json │ │ ├── required.json │ │ ├── type.json │ │ └── uniqueItems.json │ ├── draft7 │ │ ├── additionalItems.json │ │ ├── additionalProperties.json │ │ ├── allOf.json │ │ ├── anyOf.json │ │ ├── boolean_schema.json │ │ ├── const.json │ │ ├── contains.json │ │ ├── default.json │ │ ├── definitions.json │ │ ├── dependencies.json │ │ ├── enum.json │ │ ├── exclusiveMaximum.json │ │ ├── exclusiveMinimum.json │ │ ├── format.json │ │ ├── if-then-else.json │ │ ├── infinite-loop-detection.json │ │ ├── items.json │ │ ├── maxItems.json │ │ ├── maxLength.json │ │ ├── maxProperties.json │ │ ├── maximum.json │ │ ├── minItems.json │ │ ├── minLength.json │ │ ├── minProperties.json │ │ ├── minimum.json │ │ ├── multipleOf.json │ │ ├── not.json │ │ ├── oneOf.json │ │ ├── optional │ │ │ ├── bignum.json │ │ │ ├── content.json │ │ │ ├── cross-draft.json │ │ │ ├── ecmascript-regex.json │ │ │ ├── float-overflow.json │ │ │ ├── format │ │ │ │ ├── date-time.json │ │ │ │ ├── date.json │ │ │ │ ├── email.json │ │ │ │ ├── hostname.json │ │ │ │ ├── idn-email.json │ │ │ │ ├── idn-hostname.json │ │ │ │ ├── ipv4.json │ │ │ │ ├── ipv6.json │ │ │ │ ├── iri-reference.json │ │ │ │ ├── iri.json │ │ │ │ ├── json-pointer.json │ │ │ │ ├── regex.json │ │ │ │ ├── relative-json-pointer.json │ │ │ │ ├── time.json │ │ │ │ ├── unknown.json │ │ │ │ ├── uri-reference.json │ │ │ │ ├── uri-template.json │ │ │ │ └── uri.json │ │ │ ├── id.json │ │ │ ├── non-bmp-regex.json │ │ │ └── unknownKeyword.json │ │ ├── pattern.json │ │ ├── patternProperties.json │ │ ├── properties.json │ │ ├── propertyNames.json │ │ ├── ref.json │ │ ├── refRemote.json │ │ ├── required.json │ │ ├── type.json │ │ └── uniqueItems.json │ └── latest │ └── tox.ini ├── tests ├── additionalProperties_test.go ├── allOf_test.go ├── anchor_test.go ├── anyOf_test.go ├── bignum_test.go ├── boolean_schema_test.go ├── const_test.go ├── contains_test.go ├── content_test.go ├── default_test.go ├── defs_test.go ├── dependentRequired_test.go ├── dependentSchemas_test.go ├── dynamicRef_test.go ├── enum_test.go ├── exclusiveMaximum_test.go ├── exclusiveMinimum_test.go ├── format_test.go ├── id_test.go ├── if_then_else_test.go ├── items_test.go ├── maxContains_test.go ├── maxItems_test.go ├── maxLength_test.go ├── maxProperties_test.go ├── maximum_test.go ├── minContains_test.go ├── minItems_test.go ├── minLength_test.go ├── minProperties_test.go ├── minimum_test.go ├── multipleOf_test.go ├── not_test.go ├── oneOf_test.go ├── patternProperties_test.go ├── pattern_test.go ├── prefixItems_test.go ├── properties_test.go ├── propertyNames_test.go ├── ref_test.go ├── required_test.go ├── types_test.go ├── unevaluatedItems_test.go ├── unevaluatedProperties_test.go ├── uniqueItems_test.go ├── utils.go └── version_test.go ├── type.go ├── unevaluatedItems.go ├── unevaluatedProperties.go ├── uniqueItems.go ├── unmarshal.go ├── unmarshal_test.go ├── utils.go ├── utils_test.go ├── validate.go └── validate_test.go /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | trim_trailing_whitespace = true 8 | 9 | [{*.go,Makefile,.gitmodules,go.mod,go.sum}] 10 | indent_style = tab 11 | 12 | [*.md] 13 | indent_style = tab 14 | trim_trailing_whitespace = false 15 | 16 | [*.{yml,yaml,json}] 17 | indent_style = space 18 | indent_size = 2 -------------------------------------------------------------------------------- /.golangci.version: -------------------------------------------------------------------------------- 1 | 2.1.6 -------------------------------------------------------------------------------- /.golangci.yml: -------------------------------------------------------------------------------- 1 | version: "2" 2 | linters: 3 | enable: 4 | - copyloopvar 5 | - dogsled 6 | - err113 7 | - errorlint 8 | - exhaustive 9 | - gocritic 10 | - goprintffuncname 11 | - gosec 12 | - misspell 13 | - nakedret 14 | - nilerr 15 | - noctx 16 | - nolintlint 17 | - prealloc 18 | - promlinter 19 | - revive 20 | - unconvert 21 | - whitespace 22 | settings: 23 | revive: 24 | rules: 25 | - name: unused-parameter 26 | disabled: true 27 | exclusions: 28 | generated: lax 29 | rules: 30 | - linters: 31 | - funlen 32 | - gochecknoglobals 33 | - gosec 34 | - noctx 35 | - revive 36 | path: _test\.go 37 | paths: 38 | - third_party$ 39 | - builtin$ 40 | - examples$ 41 | issues: 42 | max-issues-per-linter: 0 43 | max-same-issues: 0 44 | formatters: 45 | enable: 46 | - gofmt 47 | - goimports 48 | exclusions: 49 | generated: lax 50 | paths: 51 | - third_party$ 52 | - builtin$ 53 | - examples$ 54 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 kaptinlin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # Examples 2 | 3 | Practical examples demonstrating JSON Schema validation and unmarshaling with the new separated workflow. 4 | 5 | ## Available Examples 6 | 7 | ### 🎯 [Basic](./basic/) 8 | Simple validation example showing valid and invalid data handling. 9 | 10 | ### 🏗️ [Struct Validation](./struct-validation/) 11 | Direct struct validation without JSON marshaling for optimal performance. 12 | 13 | ### 🔄 [Multiple Input Types](./multiple-input-types/) 14 | Handle different data types (JSON bytes, maps, structs) with type-specific methods. 15 | 16 | ### 📦 [Unmarshaling](./unmarshaling/) 17 | Validation + unmarshaling workflow with default value application. 18 | 19 | ### ⚠️ [Error Handling](./error-handling/) 20 | Comprehensive error handling patterns and validation failure management. 21 | 22 | ### 🌍 [Internationalization](./i18n/) 23 | Multilingual error messages using Chinese (zh-Hans) and English locales. 24 | 25 | ## Running Examples 26 | 27 | ```bash 28 | # Run any example 29 | cd 30 | go run main.go 31 | 32 | # Or run from project root 33 | go run examples//main.go 34 | ``` 35 | -------------------------------------------------------------------------------- /examples/basic/README.md: -------------------------------------------------------------------------------- 1 | # Basic Example 2 | 3 | Simple JSON Schema validation using maps. 4 | 5 | ## What it shows 6 | 7 | - Compile a schema 8 | - Validate data 9 | - Handle validation errors 10 | 11 | ## Run 12 | 13 | ```bash 14 | go run main.go 15 | ``` 16 | 17 | ## Output 18 | 19 | ``` 20 | ✅ Valid data passed 21 | ❌ Invalid data failed: 22 | - name: [Value should be at least 2 characters long] 23 | - age: [Value should be at least 0] 24 | ``` 25 | 26 | -------------------------------------------------------------------------------- /examples/basic/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | 7 | "github.com/kaptinlin/jsonschema" 8 | ) 9 | 10 | func main() { 11 | // Compile schema 12 | compiler := jsonschema.NewCompiler() 13 | schema, err := compiler.Compile([]byte(`{ 14 | "type": "object", 15 | "properties": { 16 | "name": {"type": "string", "minLength": 2}, 17 | "age": {"type": "integer", "minimum": 0} 18 | }, 19 | "required": ["name", "age"] 20 | }`)) 21 | if err != nil { 22 | log.Fatal(err) 23 | } 24 | 25 | // Valid data 26 | validData := map[string]interface{}{ 27 | "name": "John", 28 | "age": 30, 29 | } 30 | if schema.Validate(validData).IsValid() { 31 | fmt.Println("✅ Valid data passed") 32 | } 33 | 34 | // Invalid data 35 | invalidData := map[string]interface{}{ 36 | "name": "J", // too short 37 | "age": -1, // negative 38 | } 39 | result := schema.Validate(invalidData) 40 | if !result.IsValid() { 41 | fmt.Println("❌ Invalid data failed:") 42 | for field, errors := range result.Errors { 43 | fmt.Printf(" - %s: %v\n", field, errors) 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /examples/constructor/README.md: -------------------------------------------------------------------------------- 1 | # Constructor API Examples 2 | 3 | Simple examples demonstrating the JSON Schema Constructor API for programmatic schema building. 4 | 5 | ## Running the Example 6 | 7 | ```bash 8 | go run main.go 9 | ``` 10 | 11 | ## What's Demonstrated 12 | 13 | The example showcases the Constructor API's key capabilities: 14 | 15 | - **Basic Types**: String, integer, array, and object schemas with validation keywords 16 | - **Value Constraints**: Constant values and enumerations 17 | - **Schema Composition**: OneOf, AnyOf, AllOf, and conditional logic 18 | - **Convenience Functions**: Pre-built schemas for common formats (email, UUID, datetime) 19 | - **Immediate Validation**: Direct validation without compilation steps 20 | 21 | ## Documentation 22 | 23 | Complete API reference: [docs/constructor.md](../../docs/constructor.md) 24 | -------------------------------------------------------------------------------- /examples/error-handling/README.md: -------------------------------------------------------------------------------- 1 | # Error Handling Example 2 | 3 | Shows different ways to handle validation errors and parse failures. 4 | 5 | ## What it shows 6 | 7 | - Multiple validation errors in a single validation 8 | - Different error output formats 9 | - JSON parsing errors 10 | - Unmarshal validation errors 11 | - Error type checking 12 | 13 | ## Error Types 14 | 15 | - **Validation errors**: Field-specific constraint violations 16 | - **Parse errors**: Invalid JSON syntax 17 | - **Unmarshal errors**: Validation failures during unmarshaling 18 | 19 | ## Run 20 | 21 | ```bash 22 | go run main.go 23 | ``` 24 | 25 | ## Output 26 | 27 | ``` 28 | Error Handling Examples 29 | ======================= 30 | 1. Multiple validation errors: 31 | Errors: 32 | - name: Value should be at least 2 characters long 33 | - age: Value should be at least 18 34 | - email: Unsupported format 'email' 35 | - score: Value should be at most 100 36 | 37 | 2. Error list format: 38 | - name: Value should be at least 2 characters long 39 | - age: Value should be at least 18 40 | - email: Unsupported format 'email' 41 | - score: Value should be at most 100 42 | 43 | 3. JSON parse error: 44 | JSON parsing failed 45 | 46 | 4. Unmarshal error: 47 | Unmarshal failed: validation failed 48 | Error type: validation 49 | 50 | 5. Successful validation: 51 | ✅ Validation passed 52 | ``` 53 | -------------------------------------------------------------------------------- /examples/i18n/README.md: -------------------------------------------------------------------------------- 1 | # Internationalization Example 2 | 3 | Demonstrates multilingual error messages using Chinese (zh-Hans) and English locales. 4 | 5 | ## What it does 6 | 7 | - Shows validation errors in both Chinese and English 8 | - Demonstrates the separation of validation and unmarshaling 9 | - Shows production pattern with localized error handling 10 | 11 | ## Run 12 | 13 | ```bash 14 | go run main.go 15 | ``` 16 | 17 | ## Expected output 18 | 19 | - Invalid data with validation errors in both languages 20 | - Unmarshal still works despite validation failure 21 | - Production pattern with successful validation and processing 22 | -------------------------------------------------------------------------------- /examples/multiple-input-types/README.md: -------------------------------------------------------------------------------- 1 | # Multiple Input Types Example 2 | 3 | Shows how to validate different input types with the same schema. 4 | 5 | ## What it shows 6 | 7 | - Validate JSON bytes, structs, and maps 8 | - Auto-detection with `Validate()` method 9 | - Type-specific methods: `ValidateJSON()`, `ValidateStruct()`, `ValidateMap()` 10 | 11 | ## Run 12 | 13 | ```bash 14 | go run main.go 15 | ``` 16 | 17 | ## Output 18 | 19 | ``` 20 | Multiple Input Types Demo 21 | ======================== 22 | JSON bytes: ✅ Valid 23 | Go struct: ✅ Valid 24 | Map data: ✅ Valid 25 | 26 | Type-specific methods: 27 | ValidateJSON: ✅ Valid 28 | ValidateStruct: ✅ Valid 29 | ValidateMap: ✅ Valid 30 | ``` 31 | -------------------------------------------------------------------------------- /examples/struct-validation/README.md: -------------------------------------------------------------------------------- 1 | # Struct Validation Example 2 | 3 | Validate Go structs directly without map conversion. 4 | 5 | ## What it shows 6 | 7 | - `ValidateStruct()` method for direct struct validation 8 | - Auto-detection with `Validate()` method 9 | - JSON tags are automatically handled 10 | 11 | ## Benefits 12 | 13 | - Better performance than map-based validation 14 | - Type safety with Go structs 15 | - Automatic handling of `omitempty` and field renaming 16 | 17 | ## Run 18 | 19 | ```bash 20 | go run main.go 21 | ``` 22 | 23 | ## Output 24 | 25 | ``` 26 | ✅ Valid struct passed 27 | ❌ Invalid struct failed: 28 | - age: [Value should be at least 18] 29 | 30 | Using general Validate method: 31 | ✅ Auto-detected struct validation passed 32 | ``` 33 | -------------------------------------------------------------------------------- /examples/struct-validation/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | 7 | "github.com/kaptinlin/jsonschema" 8 | ) 9 | 10 | // User represents a user in our system 11 | type User struct { 12 | Name string `json:"name"` 13 | Age int `json:"age"` 14 | Email string `json:"email,omitempty"` 15 | } 16 | 17 | func main() { 18 | // Compile schema 19 | compiler := jsonschema.NewCompiler() 20 | schema, err := compiler.Compile([]byte(`{ 21 | "type": "object", 22 | "properties": { 23 | "name": {"type": "string", "minLength": 1}, 24 | "age": {"type": "integer", "minimum": 18}, 25 | "email": {"type": "string", "format": "email"} 26 | }, 27 | "required": ["name", "age"] 28 | }`)) 29 | if err != nil { 30 | log.Fatal(err) 31 | } 32 | 33 | // Valid struct 34 | validUser := User{ 35 | Name: "Alice", 36 | Age: 25, 37 | Email: "alice@example.com", 38 | } 39 | if schema.ValidateStruct(validUser).IsValid() { 40 | fmt.Println("✅ Valid struct passed") 41 | } 42 | 43 | // Invalid struct 44 | invalidUser := User{ 45 | Name: "Bob", 46 | Age: 16, // under 18 47 | } 48 | result := schema.ValidateStruct(invalidUser) 49 | if !result.IsValid() { 50 | fmt.Println("❌ Invalid struct failed:") 51 | for field, errors := range result.Errors { 52 | fmt.Printf(" - %s: %v\n", field, errors) 53 | } 54 | } 55 | 56 | // Alternative: use general Validate method 57 | fmt.Println("\nUsing general Validate method:") 58 | if schema.Validate(validUser).IsValid() { 59 | fmt.Println("✅ Auto-detected struct validation passed") 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /examples/unmarshaling/README.md: -------------------------------------------------------------------------------- 1 | # Unmarshaling Example 2 | 3 | Shows how to unmarshal data with validation and default value application. 4 | 5 | ## What it shows 6 | 7 | - `Unmarshal()` method validates and unmarshals data 8 | - Default values from schema are automatically applied 9 | - Validation errors during unmarshal 10 | - Unmarshal to structs or maps 11 | 12 | ## Key Features 13 | 14 | - Validates data before unmarshaling 15 | - Applies schema defaults to missing fields 16 | - Returns validation errors if data is invalid 17 | - Works with JSON, maps, and structs as input 18 | 19 | ## Run 20 | 21 | ```bash 22 | go run main.go 23 | ``` 24 | 25 | ## Output 26 | 27 | ``` 28 | Unmarshaling with Defaults 29 | ========================== 30 | 1. JSON with missing optional fields: 31 | Result: {Name:Alice Age:25 Country:US Active:true} 32 | 33 | 2. Map with some values provided: 34 | Result: {Name:Bob Age:30 Country:Canada Active:true} 35 | 36 | 3. Validation failure during unmarshal: 37 | Error: validation failed: name: [Value should be at least 1 characters long], age: [Value should be at least 0] 38 | 39 | 4. Unmarshal to map: 40 | Result: map[active:true age:35 country:US name:Charlie] 41 | ``` 42 | -------------------------------------------------------------------------------- /exclusiveMaximum.go: -------------------------------------------------------------------------------- 1 | package jsonschema 2 | 3 | // EvaluateExclusiveMaximum checks if a numeric instance is strictly less than the value specified by exclusiveMaximum. 4 | // According to the JSON Schema Draft 2020-12: 5 | // - The value of the "exclusiveMaximum" keyword must be a number. 6 | // - The instance is valid if it is strictly less than (not equal to) the value specified by "exclusiveMaximum". 7 | // 8 | // This method ensures that the numeric data instance does not exceed the exclusive maximum limit defined in the schema. 9 | // If the instance exceeds this limit, it returns a EvaluationError detailing the expected maximum value and the actual value. 10 | // 11 | // Reference: https://json-schema.org/draft/2020-12/json-schema-validation#name-exclusivemaximum 12 | func evaluateExclusiveMaximum(schema *Schema, value *Rat) *EvaluationError { 13 | if schema.ExclusiveMaximum != nil { 14 | if value.Cmp(schema.ExclusiveMaximum.Rat) >= 0 { 15 | // Data exceeds the exclusive maximum value. 16 | return NewEvaluationError("exclusiveMaximum", "exclusive_maximum_mismatch", "{value} should be less than {exclusive_maximum}", map[string]interface{}{ 17 | "exclusive_maximum": FormatRat(schema.ExclusiveMaximum), 18 | "value": FormatRat(value), 19 | }) 20 | } 21 | } 22 | return nil 23 | } 24 | -------------------------------------------------------------------------------- /exclusiveMinimum.go: -------------------------------------------------------------------------------- 1 | package jsonschema 2 | 3 | // EvaluateExclusiveMinimum checks if a numeric instance is strictly greater than the value specified by exclusiveMinimum. 4 | // According to the JSON Schema Draft 2020-12: 5 | // - The value of the "exclusiveMinimum" keyword must be a number. 6 | // - The instance is valid only if it is strictly greater than (not equal to) the value specified by "exclusiveMinimum". 7 | // 8 | // This method ensures that the numeric data instance meets the exclusive minimum limit defined in the schema. 9 | // If the instance does not meet this limit, it returns a EvaluationError detailing the expected minimum value and the actual value. 10 | // 11 | // Reference: https://json-schema.org/draft/2020-12/json-schema-validation#name-exclusiveminimum 12 | func evaluateExclusiveMinimum(schema *Schema, value *Rat) *EvaluationError { 13 | if schema.ExclusiveMinimum != nil { 14 | if value.Cmp(schema.ExclusiveMinimum.Rat) <= 0 { 15 | // Data does not meet the exclusive minimum value. 16 | return NewEvaluationError("exclusiveMinimum", "exclusive_minimum_mismatch", "{value} should be greater than {exclusive_minimum}", map[string]interface{}{ 17 | "exclusive_minimum": FormatRat(schema.ExclusiveMinimum), 18 | "value": FormatRat(value), 19 | }) 20 | } 21 | } 22 | return nil 23 | } 24 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/kaptinlin/jsonschema 2 | 3 | go 1.23.0 4 | 5 | require ( 6 | github.com/kaptinlin/go-i18n v0.1.4 7 | github.com/stretchr/testify v1.10.0 8 | ) 9 | 10 | require github.com/goccy/go-json v0.10.5 11 | 12 | require ( 13 | github.com/davecgh/go-spew v1.1.1 // indirect 14 | github.com/goccy/go-yaml v1.18.0 15 | github.com/gotnospirit/makeplural v0.0.0-20180622080156-a5f48d94d976 // indirect 16 | github.com/gotnospirit/messageformat v0.0.0-20221001023931-dfe49f1eb092 // indirect 17 | github.com/pmezard/go-difflib v1.0.0 // indirect 18 | golang.org/x/text v0.25.0 // indirect 19 | gopkg.in/yaml.v3 v3.0.1 // indirect 20 | ) 21 | -------------------------------------------------------------------------------- /i18n.go: -------------------------------------------------------------------------------- 1 | package jsonschema 2 | 3 | import ( 4 | "embed" 5 | 6 | "github.com/kaptinlin/go-i18n" 7 | ) 8 | 9 | //go:embed locales/*.json 10 | var localesFS embed.FS 11 | 12 | func GetI18n() (*i18n.I18n, error) { 13 | bundle := i18n.NewBundle( 14 | i18n.WithDefaultLocale("en"), 15 | i18n.WithLocales("en", "zh-Hans"), 16 | ) 17 | 18 | err := bundle.LoadFS(localesFS, "locales/*.json") 19 | 20 | return bundle, err 21 | } 22 | -------------------------------------------------------------------------------- /id.go: -------------------------------------------------------------------------------- 1 | package jsonschema 2 | 3 | // // validateID checks if the `$id` attribute in the schema conforms to URI standards and JSON Schema Draft 2020-12 specifications. 4 | // // According to the JSON Schema Draft 2020-12: 5 | // // - `$id` is a URI that uniquely identifies the schema. 6 | // // - It must be an absolute URI without a fragment. 7 | // // - This URI serves both as an identifier and as a base URI for resolving relative references. 8 | // // 9 | // // This function ensures that the `$id` value is a well-formed URI and adheres to these requirements. 10 | // // If the `$id` value does not conform, it returns a EvaluationError detailing the specific issues. 11 | // // 12 | // // Reference: https://json-schema.org/draft/2020-12/json-schema-core#name-the-id-keyword 13 | // func evaluateID(schema *Schema) *EvaluationError { 14 | // if schema.ID == "" { 15 | // return nil // No ID specified, nothing to validate 16 | // } 17 | 18 | // id := schema.ID 19 | // if !isValidURI(id) { 20 | // id = resolveRelativeURI(schema.baseURI, getCurrentPathSegment(id)) 21 | // } 22 | 23 | // uri, err := url.Parse(id) 24 | // if err != nil { 25 | // // Invalid URI format 26 | // return NewEvaluationError("$id", "id_invalid", "Invalid `$id` URI: {error}", map[string]interface{}{ 27 | // "error": err.Error(), 28 | // }) 29 | // } 30 | 31 | // if !uri.IsAbs() { 32 | // // `$id` must be an absolute URI 33 | // return NewEvaluationError("$id", "id_not_absolute", "`$id` must be an absolute URI without a fragment.") 34 | // } 35 | 36 | // if uri.Fragment != "" { 37 | // // `$id` should not contain a fragment 38 | // return NewEvaluationError("$id", "id_contains_fragment", "`$id` must not contain a fragment.") 39 | // } 40 | 41 | // return nil 42 | // } 43 | -------------------------------------------------------------------------------- /maxItems.go: -------------------------------------------------------------------------------- 1 | package jsonschema 2 | 3 | import "fmt" 4 | 5 | // EvaluateMaxItems checks if the array data contains no more items than the maximum specified in the "maxItems" schema attribute. 6 | // According to the JSON Schema Draft 2020-12: 7 | // - The value of "maxItems" must be a non-negative integer. 8 | // - An array instance is valid against "maxItems" if its size is less than, or equal to, the value of this keyword. 9 | // - If the data is not an array, the "maxItems" constraint does not apply and should be ignored. 10 | // 11 | // This method ensures that the array data instance conforms to the maximum items constraints defined in the schema. 12 | // If the instance violates this constraint, it returns a EvaluationError detailing the allowed maximum and the actual size. 13 | // If the data is not an array, it returns nil, indicating the data is valid for this constraint. 14 | // 15 | // Reference: https://json-schema.org/draft/2020-12/json-schema-validation#name-maxitems 16 | func evaluateMaxItems(schema *Schema, array []interface{}) *EvaluationError { 17 | if schema.MaxItems != nil { 18 | if float64(len(array)) > *schema.MaxItems { 19 | // If the array size exceeds the maximum allowed, construct and return an error. 20 | return NewEvaluationError("maxItems", "items_too_long", "Value should have at most {max_items} items", map[string]interface{}{ 21 | "max_items": fmt.Sprintf("%.0f", *schema.MaxItems), 22 | "count": len(array), 23 | }) 24 | } 25 | } 26 | return nil 27 | } 28 | -------------------------------------------------------------------------------- /maxProperties.go: -------------------------------------------------------------------------------- 1 | package jsonschema 2 | 3 | // EvaluateMaxProperties checks if the number of properties in the object does not exceed the specified maximum. 4 | // According to the JSON Schema Draft 2020-12: 5 | // - The "maxProperties" keyword must be a non-negative integer. 6 | // - An object instance is valid against "maxProperties" if its number of properties is less than, or equal to, the value of this keyword. 7 | // 8 | // This method ensures that the object instance conforms to the property count constraints defined in the schema. 9 | // If the instance exceeds the maximum number of properties, it returns a EvaluationError detailing the expected maximum and the actual count. 10 | // 11 | // Reference: https://json-schema.org/draft/2020-12/json-schema-validation#name-maxProperties 12 | func evaluateMaxProperties(schema *Schema, object map[string]interface{}) *EvaluationError { 13 | if schema.MaxProperties != nil { 14 | actualCount := float64(len(object)) 15 | if actualCount > *schema.MaxProperties { 16 | return NewEvaluationError("maxProperties", "too_many_properties", "Value should have at most {max_properties} properties", map[string]interface{}{ 17 | "max_properties": *schema.MaxProperties, 18 | }) 19 | } 20 | } 21 | 22 | return nil 23 | } 24 | -------------------------------------------------------------------------------- /maximum.go: -------------------------------------------------------------------------------- 1 | package jsonschema 2 | 3 | // EvaluateMaximum checks if the numeric data's value does not exceed the maximum value specified in the schema. 4 | // According to the JSON Schema Draft 2020-12: 5 | // - The value of the "maximum" keyword must be a number, representing an inclusive upper limit for a numeric instance. 6 | // - This keyword validates only if the instance is less than or exactly equal to "maximum". 7 | // 8 | // This method ensures that the numeric data instance conforms to the maximum constraints defined in the schema. 9 | // If the instance exceeds the maximum value, it returns a EvaluationError detailing the expected maximum and actual value. 10 | // 11 | // Reference: https://json-schema.org/draft/2020-12/json-schema-validation#name-maximum 12 | func evaluateMaximum(schema *Schema, value *Rat) *EvaluationError { 13 | if schema.Maximum.Rat != nil { 14 | if value.Cmp(schema.Maximum.Rat) > 0 { 15 | // If the data value exceeds the maximum value, construct and return an error. 16 | return NewEvaluationError("maximum", "value_above_maximum", "{value} should be at most {maximum}", map[string]interface{}{ 17 | "value": FormatRat(value), 18 | "maximum": FormatRat(schema.Maximum), 19 | }) 20 | } 21 | } 22 | return nil 23 | } 24 | -------------------------------------------------------------------------------- /maxlength.go: -------------------------------------------------------------------------------- 1 | package jsonschema 2 | 3 | import ( 4 | "fmt" 5 | "unicode/utf8" 6 | ) 7 | 8 | // EvaluateMaxLength checks if the length of a string instance does not exceed the maxLength specified in the schema. 9 | // According to the JSON Schema Draft 2020-12: 10 | // - The "maxLength" keyword must be a non-negative integer. 11 | // - A string instance is valid against this keyword if its length is less than or equal to the value of this keyword. 12 | // - The length of a string instance is defined as the number of its characters as defined by RFC 8259. 13 | // 14 | // This method ensures that the string data instance does not exceed the maximum length defined in the schema. 15 | // If the instance exceeds this length, it returns a EvaluationError detailing the maximum allowed length and the actual length. 16 | // 17 | // Reference: https://json-schema.org/draft/2020-12/json-schema-validation#name-maxlength 18 | func evaluateMaxLength(schema *Schema, value string) *EvaluationError { 19 | if schema.MaxLength != nil { 20 | // Use utf8.RuneCountInString to correctly count the number of graphemes in the string 21 | length := utf8.RuneCountInString(value) 22 | if length > int(*schema.MaxLength) { 23 | // String exceeds the maximum length. 24 | return NewEvaluationError("maxLength", "string_too_long", "Value should be at most {max_length} characters", map[string]interface{}{ 25 | "max_length": fmt.Sprintf("%.0f", *schema.MaxLength), 26 | "length": length, 27 | }) 28 | } 29 | } 30 | return nil 31 | } 32 | -------------------------------------------------------------------------------- /minItems.go: -------------------------------------------------------------------------------- 1 | package jsonschema 2 | 3 | // EvaluateMinItems checks if the array data contains at least the minimum number of items specified in the "minItems" schema attribute. 4 | // According to the JSON Schema Draft 2020-12: 5 | // - The value of "minItems" must be a non-negative integer. 6 | // - An array instance is valid against "minItems" if its size is greater than, or equal to, the value of this keyword. 7 | // - Omitting this keyword has the same behavior as a value of 0, which means no minimum size constraint unless explicitly specified. 8 | // 9 | // This method ensures that the array data instance conforms to the minimum items constraints defined in the schema. 10 | // If the instance violates this constraint, it returns a EvaluationError detailing the required minimum and the actual size. 11 | // 12 | // Reference: https://json-schema.org/draft/2020-12/json-schema-validation#name-minitems 13 | func evaluateMinItems(schema *Schema, array []interface{}) *EvaluationError { 14 | if schema.MinItems != nil { 15 | if float64(len(array)) < *schema.MinItems { 16 | // If the array size is less than the minimum required, construct and return an error. 17 | return NewEvaluationError("minItems", "items_too_short", "Value should have at least {min_items} items", map[string]interface{}{ 18 | "min_items": *schema.MinItems, 19 | "count": len(array), 20 | }) 21 | } 22 | } 23 | return nil 24 | } 25 | -------------------------------------------------------------------------------- /minProperties.go: -------------------------------------------------------------------------------- 1 | package jsonschema 2 | 3 | // EvaluateMinProperties checks if the number of properties in the object meets or exceeds the specified minimum. 4 | // According to the JSON Schema Draft 2020-12: 5 | // - The "minProperties" keyword must be a non-negative integer. 6 | // - An object instance is valid against "minProperties" if its number of properties is greater than or equal to the value of this keyword. 7 | // - Omitting this keyword has the same behavior as a value of 0. 8 | // 9 | // This method ensures that the object instance conforms to the property count constraints defined in the schema. 10 | // If the instance has fewer properties than the minimum required, it returns a EvaluationError detailing the expected minimum and the actual count. 11 | // 12 | // Reference: https://json-schema.org/draft/2020-12/json-schema-validation#name-minProperties 13 | func evaluateMinProperties(schema *Schema, object map[string]interface{}) *EvaluationError { 14 | minProperties := float64(0) // Default value if minProperties is omitted 15 | if schema.MinProperties != nil { 16 | minProperties = *schema.MinProperties 17 | } 18 | 19 | actualCount := float64(len(object)) 20 | if actualCount < minProperties { 21 | return NewEvaluationError("minProperties", "too_few_properties", "Value should have at least {min_properties} properties", map[string]interface{}{ 22 | "min_properties": minProperties, 23 | }) 24 | } 25 | 26 | return nil 27 | } 28 | -------------------------------------------------------------------------------- /minimum.go: -------------------------------------------------------------------------------- 1 | package jsonschema 2 | 3 | // EvaluateMinimum checks if the numeric data's value meets or exceeds the minimum value specified in the schema. 4 | // According to the JSON Schema Draft 2020-12: 5 | // - The value of the "minimum" keyword must be a number, representing an inclusive lower limit for a numeric instance. 6 | // - This keyword validates only if the instance is greater than or exactly equal to "minimum". 7 | // 8 | // This method ensures that the numeric data instance conforms to the minimum constraints defined in the schema. 9 | // If the instance is below the minimum value, it returns a EvaluationError detailing the expected minimum and actual value. 10 | // 11 | // Reference: https://json-schema.org/draft/2020-12/json-schema-validation#name-minimum 12 | func evaluateMinimum(schema *Schema, value *Rat) *EvaluationError { 13 | if schema.Minimum != nil { 14 | if value.Cmp(schema.Minimum.Rat) < 0 { 15 | // If the data value is below the minimum value, construct and return an error. 16 | return NewEvaluationError("minimum", "value_below_minimum", "{value} should be at least {minimum}", map[string]interface{}{ 17 | "value": FormatRat(value), 18 | "minimum": FormatRat(schema.Minimum), 19 | }) 20 | } 21 | } 22 | return nil 23 | } 24 | -------------------------------------------------------------------------------- /minlength.go: -------------------------------------------------------------------------------- 1 | package jsonschema 2 | 3 | import ( 4 | "unicode/utf8" 5 | ) 6 | 7 | // EvaluateMinLength checks if the length of a string instance meets or exceeds the minLength specified in the schema. 8 | // According to the JSON Schema Draft 2020-12: 9 | // - The "minLength" keyword must be a non-negative integer. 10 | // - A string instance is valid against this keyword if its length is greater than or equal to the value of this keyword. 11 | // - The length of a string instance is defined as the number of its characters as defined by RFC 8259. 12 | // - Omitting this keyword has the same behavior as a value of 0. 13 | // 14 | // This method ensures that the string data instance does not fall short of the minimum length defined in the schema. 15 | // If the instance is shorter than this length, it returns a EvaluationError detailing the minimum required length and the actual length. 16 | // 17 | // Reference: https://json-schema.org/draft/2020-12/json-schema-validation#name-minlength 18 | func evaluateMinLength(schema *Schema, value string) *EvaluationError { 19 | if schema.MinLength != nil { 20 | // Use utf8.RuneCountInString to correctly count the number of graphemes in the string 21 | length := utf8.RuneCountInString(value) 22 | if length < int(*schema.MinLength) { 23 | // String does not meet the minimum length. 24 | return NewEvaluationError("minLength", "string_too_short", "Value should be at least {min_length} characters", map[string]interface{}{ 25 | "min_length": *schema.MinLength, 26 | "length": length, 27 | }) 28 | } 29 | } 30 | return nil 31 | } 32 | -------------------------------------------------------------------------------- /multipleOf.go: -------------------------------------------------------------------------------- 1 | package jsonschema 2 | 3 | import "math/big" 4 | 5 | // EvaluateMultipleOf checks if the numeric data is a multiple of the value specified in the "multipleOf" schema attribute. 6 | // According to the JSON Schema Draft 2020-12: 7 | // - The value of "multipleOf" must be a number, strictly greater than 0. 8 | // - A numeric instance is valid only if division by this keyword's value results in an integer. 9 | // 10 | // This method ensures that the numeric data instance conforms to the divisibility constraints defined in the schema. 11 | // If the instance does not conform, it returns a EvaluationError detailing the expected divisor and the actual remainder. 12 | // 13 | // Reference: https://json-schema.org/draft/2020-12/json-schema-validation#name-multipleof 14 | func evaluateMultipleOf(schema *Schema, value *Rat) *EvaluationError { 15 | if schema.MultipleOf != nil { 16 | if schema.MultipleOf.Sign() == 0 || schema.MultipleOf.Sign() < 0 { 17 | // If the divisor is 0, return an error. 18 | return NewEvaluationError("multipleOf", "invalid_multiple_of", "Multiple of {multiple_of} should be greater than 0", map[string]interface{}{ 19 | "divisor": FormatRat(schema.MultipleOf), 20 | }) 21 | } 22 | 23 | // Calculate the division result to check if it's an integer. 24 | resultRat := new(big.Rat).Quo(value.Rat, schema.MultipleOf.Rat) 25 | if !resultRat.IsInt() { 26 | // If the division result is not an integer, construct and return an error. 27 | return NewEvaluationError("multipleOf", "not_multiple_of", "{value} should be a multiple of {multiple_of}", map[string]interface{}{ 28 | "divisor": FormatRat(schema.MultipleOf), 29 | "value": FormatRat(value), 30 | }) 31 | } 32 | } 33 | return nil 34 | } 35 | -------------------------------------------------------------------------------- /not.go: -------------------------------------------------------------------------------- 1 | package jsonschema 2 | 3 | // EvaluateNot checks if the data fails to conform to the schema or boolean specified in the not attribute. 4 | // According to the JSON Schema Draft 2020-12: 5 | // - The "not" keyword's value must be either a boolean or a valid JSON Schema. 6 | // - If "not" is a schema, an instance is valid against this keyword if it fails to validate successfully against the schema. 7 | // - If "not" is a boolean, the boolean value dictates the negation directly (true forbids validation, false allows any data). 8 | // 9 | // This function ensures that the data instance does not meet the constraints defined by the schema or respects the boolean in the not attribute. 10 | // If the instance fails to conform to the schema or the boolean logic dictates failure, it returns a EvaluationError. 11 | // 12 | // Reference: https://json-schema.org/draft/2020-12/json-schema-core#name-not 13 | func evaluateNot(schema *Schema, instance interface{}, _ map[string]bool, _ map[int]bool, dynamicScope *DynamicScope) (*EvaluationResult, *EvaluationError) { 14 | if schema.Not == nil { 15 | return nil, nil // No 'not' constraints to validate against 16 | } 17 | 18 | result, _, _ := schema.Not.evaluate(instance, dynamicScope) 19 | 20 | if result != nil { 21 | //nolint:errcheck 22 | result.SetEvaluationPath("/oneOf"). 23 | SetSchemaLocation(schema.GetSchemaLocation("/oneOf")). 24 | SetInstanceLocation("") 25 | 26 | if result.IsValid() { 27 | return result, NewEvaluationError("not", "not_schema_mismatch", "Value should not match the not schema") 28 | } 29 | } 30 | 31 | return result, nil 32 | } 33 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/.editorconfig: -------------------------------------------------------------------------------- 1 | insert_final_newline = true 2 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Ping the entire test suite team by default. 2 | * @json-schema-org/test-suite-team 3 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Test Suite Sanity Checking 2 | 3 | on: 4 | push: 5 | pull_request: 6 | release: 7 | types: [published] 8 | schedule: 9 | # Daily at 6:42, arbitrarily as a time that's possibly non-busy 10 | - cron: '42 6 * * *' 11 | 12 | jobs: 13 | ci: 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - uses: actions/checkout@v3 18 | - name: Set up Python 19 | uses: actions/setup-python@v4 20 | with: 21 | python-version: '3.x' 22 | - name: Install tox 23 | run: python -m pip install tox 24 | - name: Run the sanity checks 25 | run: python -m tox 26 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Julian Berman 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/output-tests/draft2019-09/content/general.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "failed validation produces no annotations", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "$id": "https://json-schema.org/tests/content/draft2019-09/general/0", 7 | "type": "string", 8 | "readOnly": true 9 | }, 10 | "tests": [ 11 | { 12 | "description": "readOnly annotation is dropped", 13 | "data": 1, 14 | "output": { 15 | "basic": { 16 | "$id": "https://json-schema.org/tests/content/draft2019-09/general/0/tests/0/basic", 17 | "$ref": "/draft/2019-09/output/schema", 18 | "properties": { 19 | "errors": { 20 | "items": { 21 | "properties": { 22 | "annotation": false 23 | } 24 | } 25 | }, 26 | "annotations": false 27 | }, 28 | "required": ["errors"] 29 | } 30 | } 31 | } 32 | ] 33 | } 34 | ] 35 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/output-tests/draft2019-09/content/type.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validating type", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "$id": "https://json-schema.org/tests/content/draft2019-09/type/0", 7 | "type": "string", 8 | "anyOf": [ true ] 9 | }, 10 | "tests": [ 11 | { 12 | "description": "incorrect type must be reported, but a message is not required", 13 | "data": 1, 14 | "output": { 15 | "basic": { 16 | "$id": "https://json-schema.org/tests/content/draft2019-09/type/0/tests/0/basic", 17 | "$ref": "/draft/2019-09/output/schema", 18 | "properties": { 19 | "errors": { 20 | "contains": { 21 | "properties": { 22 | "keywordLocation": {"const": "/type"}, 23 | "absoluteKeywordLocation": {"const": "https://json-schema.org/tests/content/draft2019-09/type/0#/type"}, 24 | "instanceLocation": {"const": ""}, 25 | "annotation": false 26 | }, 27 | "required": ["keywordLocation", "instanceLocation"] 28 | } 29 | } 30 | }, 31 | "required": ["errors"] 32 | } 33 | } 34 | } 35 | ] 36 | } 37 | ] 38 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/output-tests/draft2020-12/content/general.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "failed validation produces no annotations", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "$id": "https://json-schema.org/tests/content/draft2020-12/general/0", 7 | "type": "string", 8 | "readOnly": true 9 | }, 10 | "tests": [ 11 | { 12 | "description": "readOnly annotation is dropped", 13 | "data": 1, 14 | "output": { 15 | "basic": { 16 | "$id": "https://json-schema.org/tests/content/draft2020-12/general/0/tests/0/basic", 17 | "$ref": "/draft/2020-12/output/schema", 18 | "properties": { 19 | "errors": { 20 | "items": { 21 | "properties": { 22 | "annotation": false 23 | } 24 | } 25 | }, 26 | "annotations": false 27 | }, 28 | "required": ["errors"] 29 | } 30 | } 31 | } 32 | ] 33 | } 34 | ] 35 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/output-tests/draft2020-12/content/readOnly.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "readOnly generates its value as an annotation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "$id": "https://json-schema.org/tests/content/draft2020-12/readOnly/0", 7 | "readOnly": true 8 | }, 9 | "tests": [ 10 | { 11 | "description": "readOnly is true", 12 | "data": 1, 13 | "output": { 14 | "basic": { 15 | "$id": "https://json-schema.org/tests/content/draft2020-12/readOnly/0/tests/0/basic", 16 | "$ref": "/draft/2020-12/output/schema", 17 | "properties": { 18 | "annotations": { 19 | "contains": { 20 | "properties": { 21 | "keywordLocation": {"const": "/readOnly"}, 22 | "absoluteKeywordLocation": {"const": "https://json-schema.org/tests/content/draft2020-12/readOnly/0#/readOnly"}, 23 | "instanceLocation": {"const": ""}, 24 | "annotation": {"const": true} 25 | }, 26 | "required": ["keywordLocation", "instanceLocation", "annotation"] 27 | } 28 | }, 29 | "errors": false 30 | }, 31 | "required": ["annotations"] 32 | } 33 | } 34 | } 35 | ] 36 | } 37 | ] 38 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/output-tests/draft2020-12/content/type.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validating type", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "$id": "https://json-schema.org/tests/content/draft2020-12/type/0", 7 | "type": "string", 8 | "anyOf": [ true ] 9 | }, 10 | "tests": [ 11 | { 12 | "description": "incorrect type must be reported, but a message is not required", 13 | "data": 1, 14 | "output": { 15 | "basic": { 16 | "$id": "https://json-schema.org/tests/content/draft2020-12/type/0/tests/0/basic", 17 | "$ref": "/draft/2020-12/output/schema", 18 | "properties": { 19 | "errors": { 20 | "contains": { 21 | "properties": { 22 | "keywordLocation": {"const": "/type"}, 23 | "absoluteKeywordLocation": {"const": "https://json-schema.org/tests/content/draft2020-12/type/0#/type"}, 24 | "instanceLocation": {"const": ""}, 25 | "annotation": false 26 | }, 27 | "required": ["keywordLocation", "instanceLocation"] 28 | } 29 | } 30 | }, 31 | "required": ["errors"] 32 | } 33 | } 34 | } 35 | ] 36 | } 37 | ] 38 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "json-schema-test-suite", 3 | "version": "0.1.0", 4 | "description": "A language agnostic test suite for the JSON Schema specifications", 5 | "repository": "github:json-schema-org/JSON-Schema-Test-Suite", 6 | "keywords": [ 7 | "json-schema", 8 | "tests" 9 | ], 10 | "author": "http://json-schema.org", 11 | "license": "MIT" 12 | } 13 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/baseUriChange/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "integer" 3 | } 4 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/baseUriChangeFolder/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "integer" 3 | } 4 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/baseUriChangeFolderInSubschema/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "integer" 3 | } 4 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/different-id-ref-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/real-id-ref-string.json", 3 | "$defs": {"bar": {"type": "string"}}, 4 | "$ref": "#/$defs/bar" 5 | } 6 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft-next/baseUriChange/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft-next/baseUriChangeFolder/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft-next/baseUriChangeFolderInSubschema/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft-next/detached-dynamicref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft-next/detached-dynamicref.json", 3 | "$schema": "https://json-schema.org/draft/next/schema", 4 | "$defs": { 5 | "foo": { 6 | "$dynamicRef": "#detached" 7 | }, 8 | "detached": { 9 | "$dynamicAnchor": "detached", 10 | "type": "integer" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft-next/detached-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft-next/detached-ref.json", 3 | "$schema": "https://json-schema.org/draft/next/schema", 4 | "$defs": { 5 | "foo": { 6 | "$ref": "#detached" 7 | }, 8 | "detached": { 9 | "$anchor": "detached", 10 | "type": "integer" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft-next/extendible-dynamic-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "description": "extendible array", 4 | "$id": "http://localhost:1234/draft-next/extendible-dynamic-ref.json", 5 | "type": "object", 6 | "properties": { 7 | "elements": { 8 | "type": "array", 9 | "items": { 10 | "$dynamicRef": "#elements" 11 | } 12 | } 13 | }, 14 | "required": ["elements"], 15 | "additionalProperties": false, 16 | "$defs": { 17 | "elements": { 18 | "$dynamicAnchor": "elements" 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft-next/format-assertion-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft-next/format-assertion-false.json", 3 | "$schema": "https://json-schema.org/draft/next/schema", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/next/vocab/core": true, 6 | "https://json-schema.org/draft/next/vocab/format-assertion": false 7 | }, 8 | "$dynamicAnchor": "meta", 9 | "allOf": [ 10 | { "$ref": "https://json-schema.org/draft/next/meta/core" }, 11 | { "$ref": "https://json-schema.org/draft/next/meta/format-assertion" } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft-next/format-assertion-true.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft-next/format-assertion-true.json", 3 | "$schema": "https://json-schema.org/draft/next/schema", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/next/vocab/core": true, 6 | "https://json-schema.org/draft/next/vocab/format-assertion": true 7 | }, 8 | "$dynamicAnchor": "meta", 9 | "allOf": [ 10 | { "$ref": "https://json-schema.org/draft/next/meta/core" }, 11 | { "$ref": "https://json-schema.org/draft/next/meta/format-assertion" } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft-next/integer.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft-next/locationIndependentIdentifier.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "$defs": { 4 | "refToInteger": { 5 | "$ref": "#foo" 6 | }, 7 | "A": { 8 | "$anchor": "foo", 9 | "type": "integer" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft-next/metaschema-no-validation.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "$id": "http://localhost:1234/draft-next/metaschema-no-validation.json", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/next/vocab/applicator": true, 6 | "https://json-schema.org/draft/next/vocab/core": true 7 | }, 8 | "$dynamicAnchor": "meta", 9 | "allOf": [ 10 | { "$ref": "https://json-schema.org/draft/next/meta/applicator" }, 11 | { "$ref": "https://json-schema.org/draft/next/meta/core" } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft-next/metaschema-optional-vocabulary.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "$id": "http://localhost:1234/draft-next/metaschema-optional-vocabulary.json", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/next/vocab/validation": true, 6 | "https://json-schema.org/draft/next/vocab/core": true, 7 | "http://localhost:1234/draft/next/vocab/custom": false 8 | }, 9 | "$dynamicAnchor": "meta", 10 | "allOf": [ 11 | { "$ref": "https://json-schema.org/draft/next/meta/validation" }, 12 | { "$ref": "https://json-schema.org/draft/next/meta/core" } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft-next/name-defs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "$defs": { 4 | "orNull": { 5 | "anyOf": [ 6 | { 7 | "type": "null" 8 | }, 9 | { 10 | "$ref": "#" 11 | } 12 | ] 13 | } 14 | }, 15 | "type": "string" 16 | } 17 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft-next/nested/foo-ref-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "type": "object", 4 | "properties": { 5 | "foo": {"$ref": "string.json"} 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft-next/nested/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "type": "string" 4 | } 5 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft-next/ref-and-defs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "$id": "http://localhost:1234/draft-next/ref-and-defs.json", 4 | "$defs": { 5 | "inner": { 6 | "properties": { 7 | "bar": { "type": "string" } 8 | } 9 | } 10 | }, 11 | "$ref": "#/$defs/inner" 12 | } 13 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft-next/subSchemas.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "$defs": { 4 | "integer": { 5 | "type": "integer" 6 | }, 7 | "refToInteger": { 8 | "$ref": "#/$defs/integer" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft-next/tree.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "description": "tree schema, extensible", 4 | "$id": "http://localhost:1234/draft-next/tree.json", 5 | "$dynamicAnchor": "node", 6 | 7 | "type": "object", 8 | "properties": { 9 | "data": true, 10 | "children": { 11 | "type": "array", 12 | "items": { 13 | "$dynamicRef": "#node" 14 | } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2019-09/baseUriChange/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2019-09/baseUriChangeFolder/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2019-09/baseUriChangeFolderInSubschema/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2019-09/dependentRequired.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft2019-09/dependentRequired.json", 3 | "$schema": "https://json-schema.org/draft/2019-09/schema", 4 | "dependentRequired": { 5 | "foo": ["bar"] 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2019-09/detached-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft2019-09/detached-ref.json", 3 | "$schema": "https://json-schema.org/draft/2019-09/schema", 4 | "$defs": { 5 | "foo": { 6 | "$ref": "#detached" 7 | }, 8 | "detached": { 9 | "$anchor": "detached", 10 | "type": "integer" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2019-09/extendible-dynamic-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "extendible array", 3 | "$schema": "https://json-schema.org/draft/2019-09/schema", 4 | "$id": "http://localhost:1234/draft2019-09/extendible-dynamic-ref.json", 5 | "type": "object", 6 | "properties": { 7 | "elements": { 8 | "type": "array", 9 | "items": { 10 | "$dynamicRef": "#elements" 11 | } 12 | } 13 | }, 14 | "required": ["elements"], 15 | "additionalProperties": false, 16 | "$defs": { 17 | "elements": { 18 | "$dynamicAnchor": "elements" 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2019-09/ignore-prefixItems.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft2019-09/ignore-prefixItems.json", 3 | "$schema": "https://json-schema.org/draft/2019-09/schema", 4 | "prefixItems": [ 5 | {"type": "string"} 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2019-09/integer.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2019-09/locationIndependentIdentifier.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "$defs": { 4 | "refToInteger": { 5 | "$ref": "#foo" 6 | }, 7 | "A": { 8 | "$anchor": "foo", 9 | "type": "integer" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2019-09/metaschema-no-validation.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "$id": "http://localhost:1234/draft2019-09/metaschema-no-validation.json", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2019-09/vocab/applicator": true, 6 | "https://json-schema.org/draft/2019-09/vocab/core": true 7 | }, 8 | "$recursiveAnchor": true, 9 | "allOf": [ 10 | { "$ref": "https://json-schema.org/draft/2019-09/meta/applicator" }, 11 | { "$ref": "https://json-schema.org/draft/2019-09/meta/core" } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2019-09/metaschema-optional-vocabulary.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "$id": "http://localhost:1234/draft2019-09/metaschema-optional-vocabulary.json", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2019-09/vocab/validation": true, 6 | "https://json-schema.org/draft/2019-09/vocab/core": true, 7 | "http://localhost:1234/draft/2019-09/vocab/custom": false 8 | }, 9 | "$recursiveAnchor": true, 10 | "allOf": [ 11 | { "$ref": "https://json-schema.org/draft/2019-09/meta/validation" }, 12 | { "$ref": "https://json-schema.org/draft/2019-09/meta/core" } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2019-09/name-defs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "$defs": { 4 | "orNull": { 5 | "anyOf": [ 6 | { 7 | "type": "null" 8 | }, 9 | { 10 | "$ref": "#" 11 | } 12 | ] 13 | } 14 | }, 15 | "type": "string" 16 | } 17 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2019-09/nested/foo-ref-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "type": "object", 4 | "properties": { 5 | "foo": {"$ref": "string.json"} 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2019-09/nested/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "type": "string" 4 | } 5 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2019-09/ref-and-defs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "$id": "http://localhost:1234/draft2019-09/ref-and-defs.json", 4 | "$defs": { 5 | "inner": { 6 | "properties": { 7 | "bar": { "type": "string" } 8 | } 9 | } 10 | }, 11 | "$ref": "#/$defs/inner" 12 | } 13 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2019-09/subSchemas.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "$defs": { 4 | "integer": { 5 | "type": "integer" 6 | }, 7 | "refToInteger": { 8 | "$ref": "#/$defs/integer" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2019-09/tree.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "tree schema, extensible", 3 | "$schema": "https://json-schema.org/draft/2019-09/schema", 4 | "$id": "http://localhost:1234/draft2019-09/tree.json", 5 | "$dynamicAnchor": "node", 6 | 7 | "type": "object", 8 | "properties": { 9 | "data": true, 10 | "children": { 11 | "type": "array", 12 | "items": { 13 | "$dynamicRef": "#node" 14 | } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2020-12/baseUriChange/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2020-12/baseUriChangeFolder/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2020-12/baseUriChangeFolderInSubschema/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2020-12/detached-dynamicref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft2020-12/detached-dynamicref.json", 3 | "$schema": "https://json-schema.org/draft/2020-12/schema", 4 | "$defs": { 5 | "foo": { 6 | "$dynamicRef": "#detached" 7 | }, 8 | "detached": { 9 | "$dynamicAnchor": "detached", 10 | "type": "integer" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2020-12/detached-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft2020-12/detached-ref.json", 3 | "$schema": "https://json-schema.org/draft/2020-12/schema", 4 | "$defs": { 5 | "foo": { 6 | "$ref": "#detached" 7 | }, 8 | "detached": { 9 | "$anchor": "detached", 10 | "type": "integer" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2020-12/extendible-dynamic-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "extendible array", 3 | "$schema": "https://json-schema.org/draft/2020-12/schema", 4 | "$id": "http://localhost:1234/draft2020-12/extendible-dynamic-ref.json", 5 | "type": "object", 6 | "properties": { 7 | "elements": { 8 | "type": "array", 9 | "items": { 10 | "$dynamicRef": "#elements" 11 | } 12 | } 13 | }, 14 | "required": ["elements"], 15 | "additionalProperties": false, 16 | "$defs": { 17 | "elements": { 18 | "$dynamicAnchor": "elements" 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2020-12/format-assertion-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft2020-12/format-assertion-false.json", 3 | "$schema": "https://json-schema.org/draft/2020-12/schema", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2020-12/vocab/core": true, 6 | "https://json-schema.org/draft/2020-12/vocab/format-assertion": false 7 | }, 8 | "$dynamicAnchor": "meta", 9 | "allOf": [ 10 | { "$ref": "https://json-schema.org/draft/2020-12/meta/core" }, 11 | { "$ref": "https://json-schema.org/draft/2020-12/meta/format-assertion" } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2020-12/format-assertion-true.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft2020-12/format-assertion-true.json", 3 | "$schema": "https://json-schema.org/draft/2020-12/schema", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2020-12/vocab/core": true, 6 | "https://json-schema.org/draft/2020-12/vocab/format-assertion": true 7 | }, 8 | "$dynamicAnchor": "meta", 9 | "allOf": [ 10 | { "$ref": "https://json-schema.org/draft/2020-12/meta/core" }, 11 | { "$ref": "https://json-schema.org/draft/2020-12/meta/format-assertion" } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2020-12/integer.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2020-12/locationIndependentIdentifier.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "$defs": { 4 | "refToInteger": { 5 | "$ref": "#foo" 6 | }, 7 | "A": { 8 | "$anchor": "foo", 9 | "type": "integer" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2020-12/metaschema-no-validation.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "$id": "http://localhost:1234/draft2020-12/metaschema-no-validation.json", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2020-12/vocab/applicator": true, 6 | "https://json-schema.org/draft/2020-12/vocab/core": true 7 | }, 8 | "$dynamicAnchor": "meta", 9 | "allOf": [ 10 | { "$ref": "https://json-schema.org/draft/2020-12/meta/applicator" }, 11 | { "$ref": "https://json-schema.org/draft/2020-12/meta/core" } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2020-12/metaschema-optional-vocabulary.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "$id": "http://localhost:1234/draft2020-12/metaschema-optional-vocabulary.json", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2020-12/vocab/validation": true, 6 | "https://json-schema.org/draft/2020-12/vocab/core": true, 7 | "http://localhost:1234/draft/2020-12/vocab/custom": false 8 | }, 9 | "$dynamicAnchor": "meta", 10 | "allOf": [ 11 | { "$ref": "https://json-schema.org/draft/2020-12/meta/validation" }, 12 | { "$ref": "https://json-schema.org/draft/2020-12/meta/core" } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2020-12/name-defs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "$defs": { 4 | "orNull": { 5 | "anyOf": [ 6 | { 7 | "type": "null" 8 | }, 9 | { 10 | "$ref": "#" 11 | } 12 | ] 13 | } 14 | }, 15 | "type": "string" 16 | } 17 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2020-12/nested/foo-ref-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "type": "object", 4 | "properties": { 5 | "foo": {"$ref": "string.json"} 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2020-12/nested/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "type": "string" 4 | } 5 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2020-12/prefixItems.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft2020-12/prefixItems.json", 3 | "$schema": "https://json-schema.org/draft/2020-12/schema", 4 | "prefixItems": [ 5 | {"type": "string"} 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2020-12/ref-and-defs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "$id": "http://localhost:1234/draft2020-12/ref-and-defs.json", 4 | "$defs": { 5 | "inner": { 6 | "properties": { 7 | "bar": { "type": "string" } 8 | } 9 | } 10 | }, 11 | "$ref": "#/$defs/inner" 12 | } 13 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2020-12/subSchemas.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "$defs": { 4 | "integer": { 5 | "type": "integer" 6 | }, 7 | "refToInteger": { 8 | "$ref": "#/$defs/integer" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft2020-12/tree.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "tree schema, extensible", 3 | "$schema": "https://json-schema.org/draft/2020-12/schema", 4 | "$id": "http://localhost:1234/draft2020-12/tree.json", 5 | "$dynamicAnchor": "node", 6 | 7 | "type": "object", 8 | "properties": { 9 | "data": true, 10 | "children": { 11 | "type": "array", 12 | "items": { 13 | "$dynamicRef": "#node" 14 | } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft6/detached-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft6/detached-ref.json", 3 | "$schema": "http://json-schema.org/draft-06/schema#", 4 | "definitions": { 5 | "foo": { 6 | "$ref": "#detached" 7 | }, 8 | "detached": { 9 | "$id": "#detached", 10 | "type": "integer" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft7/detached-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft7/detached-ref.json", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "definitions": { 5 | "foo": { 6 | "$ref": "#detached" 7 | }, 8 | "detached": { 9 | "$id": "#detached", 10 | "type": "integer" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/draft7/ignore-dependentRequired.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft7/integer.json", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "dependentRequired": { 5 | "foo": ["bar"] 6 | } 7 | } -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/extendible-dynamic-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "extendible array", 3 | "$id": "http://localhost:1234/extendible-dynamic-ref.json", 4 | "type": "object", 5 | "properties": { 6 | "elements": { 7 | "type": "array", 8 | "items": { 9 | "$dynamicRef": "#elements" 10 | } 11 | } 12 | }, 13 | "required": ["elements"], 14 | "additionalProperties": false, 15 | "$defs": { 16 | "elements": { 17 | "$dynamicAnchor": "elements" 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/integer.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "integer" 3 | } 4 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/locationIndependentIdentifier.json: -------------------------------------------------------------------------------- 1 | { 2 | "$defs": { 3 | "refToInteger": { 4 | "$ref": "#foo" 5 | }, 6 | "A": { 7 | "$anchor": "foo", 8 | "type": "integer" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/locationIndependentIdentifierDraft4.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "refToInteger": { 4 | "$ref": "#foo" 5 | }, 6 | "A": { 7 | "id": "#foo", 8 | "type": "integer" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/locationIndependentIdentifierPre2019.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "refToInteger": { 4 | "$ref": "#foo" 5 | }, 6 | "A": { 7 | "$id": "#foo", 8 | "type": "integer" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/name-defs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$defs": { 3 | "orNull": { 4 | "anyOf": [ 5 | { 6 | "type": "null" 7 | }, 8 | { 9 | "$ref": "#" 10 | } 11 | ] 12 | } 13 | }, 14 | "type": "string" 15 | } 16 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/name.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "orNull": { 4 | "anyOf": [ 5 | { 6 | "type": "null" 7 | }, 8 | { 9 | "$ref": "#" 10 | } 11 | ] 12 | } 13 | }, 14 | "type": "string" 15 | } 16 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/nested-absolute-ref-to-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$defs": { 3 | "bar": { 4 | "$id": "http://localhost:1234/the-nested-id.json", 5 | "type": "string" 6 | } 7 | }, 8 | "$ref": "http://localhost:1234/the-nested-id.json" 9 | } 10 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/nested/foo-ref-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "foo": {"$ref": "string.json"} 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/nested/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "string" 3 | } 4 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/ref-and-definitions.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/ref-and-definitions.json", 3 | "definitions": { 4 | "inner": { 5 | "properties": { 6 | "bar": { "type": "string" } 7 | } 8 | } 9 | }, 10 | "allOf": [ { "$ref": "#/definitions/inner" } ] 11 | } 12 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/ref-and-defs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/ref-and-defs.json", 3 | "$defs": { 4 | "inner": { 5 | "properties": { 6 | "bar": { "type": "string" } 7 | } 8 | } 9 | }, 10 | "$ref": "#/$defs/inner" 11 | } 12 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/subSchemas.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "integer": { 4 | "type": "integer" 5 | }, 6 | "refToInteger": { 7 | "$ref": "#/definitions/integer" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/tree.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "tree schema, extensible", 3 | "$id": "http://localhost:1234/tree.json", 4 | "$dynamicAnchor": "node", 5 | 6 | "type": "object", 7 | "properties": { 8 | "data": true, 9 | "children": { 10 | "type": "array", 11 | "items": { 12 | "$dynamicRef": "#node" 13 | } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/remotes/urn-ref-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "urn:uuid:feebdaed-ffff-0000-ffff-0000deadbeef", 3 | "$defs": {"bar": {"type": "string"}}, 4 | "$ref": "#/$defs/bar" 5 | } 6 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft-next/defs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validate definition against metaschema", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/next/schema", 6 | "$ref": "https://json-schema.org/draft/next/schema" 7 | }, 8 | "tests": [ 9 | { 10 | "description": "valid definition schema", 11 | "data": {"$defs": {"foo": {"type": "integer"}}}, 12 | "valid": true 13 | }, 14 | { 15 | "description": "invalid definition schema", 16 | "data": {"$defs": {"foo": {"type": 1}}}, 17 | "valid": false 18 | } 19 | ] 20 | } 21 | ] 22 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft-next/exclusiveMaximum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMaximum validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/next/schema", 6 | "exclusiveMaximum": 3.0 7 | }, 8 | "tests": [ 9 | { 10 | "description": "below the exclusiveMaximum is valid", 11 | "data": 2.2, 12 | "valid": true 13 | }, 14 | { 15 | "description": "boundary point is invalid", 16 | "data": 3.0, 17 | "valid": false 18 | }, 19 | { 20 | "description": "above the exclusiveMaximum is invalid", 21 | "data": 3.5, 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-numbers", 26 | "data": "x", 27 | "valid": true 28 | } 29 | ] 30 | } 31 | ] 32 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft-next/exclusiveMinimum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMinimum validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/next/schema", 6 | "exclusiveMinimum": 1.1 7 | }, 8 | "tests": [ 9 | { 10 | "description": "above the exclusiveMinimum is valid", 11 | "data": 1.2, 12 | "valid": true 13 | }, 14 | { 15 | "description": "boundary point is invalid", 16 | "data": 1.1, 17 | "valid": false 18 | }, 19 | { 20 | "description": "below the exclusiveMinimum is invalid", 21 | "data": 0.6, 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-numbers", 26 | "data": "x", 27 | "valid": true 28 | } 29 | ] 30 | } 31 | ] 32 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft-next/infinite-loop-detection.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "evaluating the same schema location against the same data location twice is not a sign of an infinite loop", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/next/schema", 6 | "$defs": { 7 | "int": { "type": "integer" } 8 | }, 9 | "allOf": [ 10 | { 11 | "properties": { 12 | "foo": { 13 | "$ref": "#/$defs/int" 14 | } 15 | } 16 | }, 17 | { 18 | "additionalProperties": { 19 | "$ref": "#/$defs/int" 20 | } 21 | } 22 | ] 23 | }, 24 | "tests": [ 25 | { 26 | "description": "passing case", 27 | "data": { "foo": 1 }, 28 | "valid": true 29 | }, 30 | { 31 | "description": "failing case", 32 | "data": { "foo": "a string" }, 33 | "valid": false 34 | } 35 | ] 36 | } 37 | ] 38 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft-next/maxItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxItems validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/next/schema", 6 | "maxItems": 2 7 | }, 8 | "tests": [ 9 | { 10 | "description": "shorter is valid", 11 | "data": [1], 12 | "valid": true 13 | }, 14 | { 15 | "description": "exact length is valid", 16 | "data": [1, 2], 17 | "valid": true 18 | }, 19 | { 20 | "description": "too long is invalid", 21 | "data": [1, 2, 3], 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-arrays", 26 | "data": "foobar", 27 | "valid": true 28 | } 29 | ] 30 | }, 31 | { 32 | "description": "maxItems validation with a decimal", 33 | "schema": { 34 | "$schema": "https://json-schema.org/draft/next/schema", 35 | "maxItems": 2.0 36 | }, 37 | "tests": [ 38 | { 39 | "description": "shorter is valid", 40 | "data": [1], 41 | "valid": true 42 | }, 43 | { 44 | "description": "too long is invalid", 45 | "data": [1, 2, 3], 46 | "valid": false 47 | } 48 | ] 49 | } 50 | ] 51 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft-next/maxLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxLength validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/next/schema", 6 | "maxLength": 2 7 | }, 8 | "tests": [ 9 | { 10 | "description": "shorter is valid", 11 | "data": "f", 12 | "valid": true 13 | }, 14 | { 15 | "description": "exact length is valid", 16 | "data": "fo", 17 | "valid": true 18 | }, 19 | { 20 | "description": "too long is invalid", 21 | "data": "foo", 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-strings", 26 | "data": 100, 27 | "valid": true 28 | }, 29 | { 30 | "description": "two graphemes is long enough", 31 | "data": "\uD83D\uDCA9\uD83D\uDCA9", 32 | "valid": true 33 | } 34 | ] 35 | }, 36 | { 37 | "description": "maxLength validation with a decimal", 38 | "schema": { 39 | "$schema": "https://json-schema.org/draft/next/schema", 40 | "maxLength": 2.0 41 | }, 42 | "tests": [ 43 | { 44 | "description": "shorter is valid", 45 | "data": "f", 46 | "valid": true 47 | }, 48 | { 49 | "description": "too long is invalid", 50 | "data": "foo", 51 | "valid": false 52 | } 53 | ] 54 | } 55 | ] 56 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft-next/minItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minItems validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/next/schema", 6 | "minItems": 1 7 | }, 8 | "tests": [ 9 | { 10 | "description": "longer is valid", 11 | "data": [1, 2], 12 | "valid": true 13 | }, 14 | { 15 | "description": "exact length is valid", 16 | "data": [1], 17 | "valid": true 18 | }, 19 | { 20 | "description": "too short is invalid", 21 | "data": [], 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-arrays", 26 | "data": "", 27 | "valid": true 28 | } 29 | ] 30 | }, 31 | { 32 | "description": "minItems validation with a decimal", 33 | "schema": { 34 | "$schema": "https://json-schema.org/draft/next/schema", 35 | "minItems": 1.0 36 | }, 37 | "tests": [ 38 | { 39 | "description": "longer is valid", 40 | "data": [1, 2], 41 | "valid": true 42 | }, 43 | { 44 | "description": "too short is invalid", 45 | "data": [], 46 | "valid": false 47 | } 48 | ] 49 | } 50 | ] 51 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft-next/minLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minLength validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/next/schema", 6 | "minLength": 2 7 | }, 8 | "tests": [ 9 | { 10 | "description": "longer is valid", 11 | "data": "foo", 12 | "valid": true 13 | }, 14 | { 15 | "description": "exact length is valid", 16 | "data": "fo", 17 | "valid": true 18 | }, 19 | { 20 | "description": "too short is invalid", 21 | "data": "f", 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-strings", 26 | "data": 1, 27 | "valid": true 28 | }, 29 | { 30 | "description": "one grapheme is not long enough", 31 | "data": "\uD83D\uDCA9", 32 | "valid": false 33 | } 34 | ] 35 | }, 36 | { 37 | "description": "minLength validation with a decimal", 38 | "schema": { 39 | "$schema": "https://json-schema.org/draft/next/schema", 40 | "minLength": 2.0 41 | }, 42 | "tests": [ 43 | { 44 | "description": "longer is valid", 45 | "data": "foo", 46 | "valid": true 47 | }, 48 | { 49 | "description": "too short is invalid", 50 | "data": "f", 51 | "valid": false 52 | } 53 | ] 54 | } 55 | ] 56 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft-next/optional/float-overflow.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "all integers are multiples of 0.5, if overflow is handled", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/next/schema", 6 | "type": "integer", 7 | "multipleOf": 0.5 8 | }, 9 | "tests": [ 10 | { 11 | "description": "valid if optional overflow handling is implemented", 12 | "data": 1e308, 13 | "valid": true 14 | } 15 | ] 16 | } 17 | ] 18 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft-next/optional/format-assertion.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "schema that uses custom metaschema with format-assertion: false", 4 | "schema": { 5 | "$id": "https://schema/using/format-assertion/false", 6 | "$schema": "http://localhost:1234/draft-next/format-assertion-false.json", 7 | "format": "ipv4" 8 | }, 9 | "tests": [ 10 | { 11 | "description": "format-assertion: false: valid string", 12 | "data": "127.0.0.1", 13 | "valid": true 14 | }, 15 | { 16 | "description": "format-assertion: false: invalid string", 17 | "data": "not-an-ipv4", 18 | "valid": false 19 | } 20 | ] 21 | }, 22 | { 23 | "description": "schema that uses custom metaschema with format-assertion: true", 24 | "schema": { 25 | "$id": "https://schema/using/format-assertion/true", 26 | "$schema": "http://localhost:1234/draft-next/format-assertion-true.json", 27 | "format": "ipv4" 28 | }, 29 | "tests": [ 30 | { 31 | "description": "format-assertion: true: valid string", 32 | "data": "127.0.0.1", 33 | "valid": true 34 | }, 35 | { 36 | "description": "format-assertion: true: invalid string", 37 | "data": "not-an-ipv4", 38 | "valid": false 39 | } 40 | ] 41 | } 42 | ] 43 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft-next/optional/format/regex.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of regular expressions", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/next/schema", 6 | "format": "regex" 7 | }, 8 | "tests": [ 9 | { 10 | "description": "all string formats ignore integers", 11 | "data": 12, 12 | "valid": true 13 | }, 14 | { 15 | "description": "all string formats ignore floats", 16 | "data": 13.7, 17 | "valid": true 18 | }, 19 | { 20 | "description": "all string formats ignore objects", 21 | "data": {}, 22 | "valid": true 23 | }, 24 | { 25 | "description": "all string formats ignore arrays", 26 | "data": [], 27 | "valid": true 28 | }, 29 | { 30 | "description": "all string formats ignore booleans", 31 | "data": false, 32 | "valid": true 33 | }, 34 | { 35 | "description": "all string formats ignore nulls", 36 | "data": null, 37 | "valid": true 38 | }, 39 | { 40 | "description": "a valid regular expression", 41 | "data": "([abc])+\\s+$", 42 | "valid": true 43 | }, 44 | { 45 | "description": "a regular expression with unclosed parens is invalid", 46 | "data": "^(abc]", 47 | "valid": false 48 | } 49 | ] 50 | } 51 | ] 52 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft2019-09/defs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validate definition against metaschema", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "$ref": "https://json-schema.org/draft/2019-09/schema" 7 | }, 8 | "tests": [ 9 | { 10 | "description": "valid definition schema", 11 | "data": {"$defs": {"foo": {"type": "integer"}}}, 12 | "valid": true 13 | }, 14 | { 15 | "description": "invalid definition schema", 16 | "data": {"$defs": {"foo": {"type": 1}}}, 17 | "valid": false 18 | } 19 | ] 20 | } 21 | ] 22 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft2019-09/exclusiveMaximum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMaximum validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "exclusiveMaximum": 3.0 7 | }, 8 | "tests": [ 9 | { 10 | "description": "below the exclusiveMaximum is valid", 11 | "data": 2.2, 12 | "valid": true 13 | }, 14 | { 15 | "description": "boundary point is invalid", 16 | "data": 3.0, 17 | "valid": false 18 | }, 19 | { 20 | "description": "above the exclusiveMaximum is invalid", 21 | "data": 3.5, 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-numbers", 26 | "data": "x", 27 | "valid": true 28 | } 29 | ] 30 | } 31 | ] 32 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft2019-09/exclusiveMinimum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMinimum validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "exclusiveMinimum": 1.1 7 | }, 8 | "tests": [ 9 | { 10 | "description": "above the exclusiveMinimum is valid", 11 | "data": 1.2, 12 | "valid": true 13 | }, 14 | { 15 | "description": "boundary point is invalid", 16 | "data": 1.1, 17 | "valid": false 18 | }, 19 | { 20 | "description": "below the exclusiveMinimum is invalid", 21 | "data": 0.6, 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-numbers", 26 | "data": "x", 27 | "valid": true 28 | } 29 | ] 30 | } 31 | ] 32 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft2019-09/infinite-loop-detection.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "evaluating the same schema location against the same data location twice is not a sign of an infinite loop", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "$defs": { 7 | "int": { "type": "integer" } 8 | }, 9 | "allOf": [ 10 | { 11 | "properties": { 12 | "foo": { 13 | "$ref": "#/$defs/int" 14 | } 15 | } 16 | }, 17 | { 18 | "additionalProperties": { 19 | "$ref": "#/$defs/int" 20 | } 21 | } 22 | ] 23 | }, 24 | "tests": [ 25 | { 26 | "description": "passing case", 27 | "data": { "foo": 1 }, 28 | "valid": true 29 | }, 30 | { 31 | "description": "failing case", 32 | "data": { "foo": "a string" }, 33 | "valid": false 34 | } 35 | ] 36 | } 37 | ] 38 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft2019-09/maxItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxItems validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "maxItems": 2 7 | }, 8 | "tests": [ 9 | { 10 | "description": "shorter is valid", 11 | "data": [1], 12 | "valid": true 13 | }, 14 | { 15 | "description": "exact length is valid", 16 | "data": [1, 2], 17 | "valid": true 18 | }, 19 | { 20 | "description": "too long is invalid", 21 | "data": [1, 2, 3], 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-arrays", 26 | "data": "foobar", 27 | "valid": true 28 | } 29 | ] 30 | }, 31 | { 32 | "description": "maxItems validation with a decimal", 33 | "schema": { 34 | "$schema": "https://json-schema.org/draft/2019-09/schema", 35 | "maxItems": 2.0 36 | }, 37 | "tests": [ 38 | { 39 | "description": "shorter is valid", 40 | "data": [1], 41 | "valid": true 42 | }, 43 | { 44 | "description": "too long is invalid", 45 | "data": [1, 2, 3], 46 | "valid": false 47 | } 48 | ] 49 | } 50 | ] 51 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft2019-09/maxLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxLength validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "maxLength": 2 7 | }, 8 | "tests": [ 9 | { 10 | "description": "shorter is valid", 11 | "data": "f", 12 | "valid": true 13 | }, 14 | { 15 | "description": "exact length is valid", 16 | "data": "fo", 17 | "valid": true 18 | }, 19 | { 20 | "description": "too long is invalid", 21 | "data": "foo", 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-strings", 26 | "data": 100, 27 | "valid": true 28 | }, 29 | { 30 | "description": "two graphemes is long enough", 31 | "data": "\uD83D\uDCA9\uD83D\uDCA9", 32 | "valid": true 33 | } 34 | ] 35 | }, 36 | { 37 | "description": "maxLength validation with a decimal", 38 | "schema": { 39 | "$schema": "https://json-schema.org/draft/2019-09/schema", 40 | "maxLength": 2.0 41 | }, 42 | "tests": [ 43 | { 44 | "description": "shorter is valid", 45 | "data": "f", 46 | "valid": true 47 | }, 48 | { 49 | "description": "too long is invalid", 50 | "data": "foo", 51 | "valid": false 52 | } 53 | ] 54 | } 55 | ] 56 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft2019-09/minItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minItems validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "minItems": 1 7 | }, 8 | "tests": [ 9 | { 10 | "description": "longer is valid", 11 | "data": [1, 2], 12 | "valid": true 13 | }, 14 | { 15 | "description": "exact length is valid", 16 | "data": [1], 17 | "valid": true 18 | }, 19 | { 20 | "description": "too short is invalid", 21 | "data": [], 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-arrays", 26 | "data": "", 27 | "valid": true 28 | } 29 | ] 30 | }, 31 | { 32 | "description": "minItems validation with a decimal", 33 | "schema": { 34 | "$schema": "https://json-schema.org/draft/2019-09/schema", 35 | "minItems": 1.0 36 | }, 37 | "tests": [ 38 | { 39 | "description": "longer is valid", 40 | "data": [1, 2], 41 | "valid": true 42 | }, 43 | { 44 | "description": "too short is invalid", 45 | "data": [], 46 | "valid": false 47 | } 48 | ] 49 | } 50 | ] 51 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft2019-09/minLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minLength validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "minLength": 2 7 | }, 8 | "tests": [ 9 | { 10 | "description": "longer is valid", 11 | "data": "foo", 12 | "valid": true 13 | }, 14 | { 15 | "description": "exact length is valid", 16 | "data": "fo", 17 | "valid": true 18 | }, 19 | { 20 | "description": "too short is invalid", 21 | "data": "f", 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-strings", 26 | "data": 1, 27 | "valid": true 28 | }, 29 | { 30 | "description": "one grapheme is not long enough", 31 | "data": "\uD83D\uDCA9", 32 | "valid": false 33 | } 34 | ] 35 | }, 36 | { 37 | "description": "minLength validation with a decimal", 38 | "schema": { 39 | "$schema": "https://json-schema.org/draft/2019-09/schema", 40 | "minLength": 2.0 41 | }, 42 | "tests": [ 43 | { 44 | "description": "longer is valid", 45 | "data": "foo", 46 | "valid": true 47 | }, 48 | { 49 | "description": "too short is invalid", 50 | "data": "f", 51 | "valid": false 52 | } 53 | ] 54 | } 55 | ] 56 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft2019-09/optional/cross-draft.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "refs to future drafts are processed as future drafts", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "type": "array", 7 | "$ref": "http://localhost:1234/draft2020-12/prefixItems.json" 8 | }, 9 | "tests": [ 10 | { 11 | "description": "first item not a string is invalid", 12 | "comment": "if the implementation is not processing the $ref as a 2020-12 schema, this test will fail", 13 | "data": [1, 2, 3], 14 | "valid": false 15 | }, 16 | { 17 | "description": "first item is a string is valid", 18 | "data": ["a string", 1, 2, 3], 19 | "valid": true 20 | } 21 | ] 22 | }, 23 | { 24 | "description": "refs to historic drafts are processed as historic drafts", 25 | "schema": { 26 | "type": "object", 27 | "allOf": [ 28 | { "properties": { "foo": true } }, 29 | { "$ref": "http://localhost:1234/draft7/ignore-dependentRequired.json" } 30 | ] 31 | }, 32 | "tests": [ 33 | { 34 | "description": "missing bar is valid", 35 | "comment": "if the implementation is not processing the $ref as a draft 7 schema, this test will fail", 36 | "data": {"foo": "any value"}, 37 | "valid": true 38 | } 39 | ] 40 | } 41 | ] 42 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft2019-09/optional/float-overflow.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "all integers are multiples of 0.5, if overflow is handled", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "type": "integer", "multipleOf": 0.5 7 | }, 8 | "tests": [ 9 | { 10 | "description": "valid if optional overflow handling is implemented", 11 | "data": 1e308, 12 | "valid": true 13 | } 14 | ] 15 | } 16 | ] 17 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft2019-09/optional/format/regex.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of regular expressions", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "format": "regex" 7 | }, 8 | "tests": [ 9 | { 10 | "description": "all string formats ignore integers", 11 | "data": 12, 12 | "valid": true 13 | }, 14 | { 15 | "description": "all string formats ignore floats", 16 | "data": 13.7, 17 | "valid": true 18 | }, 19 | { 20 | "description": "all string formats ignore objects", 21 | "data": {}, 22 | "valid": true 23 | }, 24 | { 25 | "description": "all string formats ignore arrays", 26 | "data": [], 27 | "valid": true 28 | }, 29 | { 30 | "description": "all string formats ignore booleans", 31 | "data": false, 32 | "valid": true 33 | }, 34 | { 35 | "description": "all string formats ignore nulls", 36 | "data": null, 37 | "valid": true 38 | }, 39 | { 40 | "description": "a valid regular expression", 41 | "data": "([abc])+\\s+$", 42 | "valid": true 43 | }, 44 | { 45 | "description": "a regular expression with unclosed parens is invalid", 46 | "data": "^(abc]", 47 | "valid": false 48 | } 49 | ] 50 | } 51 | ] 52 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft2019-09/optional/format/unknown.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "unknown format", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "format": "unknown" 7 | }, 8 | "tests": [ 9 | { 10 | "description": "unknown formats ignore integers", 11 | "data": 12, 12 | "valid": true 13 | }, 14 | { 15 | "description": "unknown formats ignore floats", 16 | "data": 13.7, 17 | "valid": true 18 | }, 19 | { 20 | "description": "unknown formats ignore objects", 21 | "data": {}, 22 | "valid": true 23 | }, 24 | { 25 | "description": "unknown formats ignore arrays", 26 | "data": [], 27 | "valid": true 28 | }, 29 | { 30 | "description": "unknown formats ignore booleans", 31 | "data": false, 32 | "valid": true 33 | }, 34 | { 35 | "description": "unknown formats ignore nulls", 36 | "data": null, 37 | "valid": true 38 | }, 39 | { 40 | "description": "unknown formats ignore strings", 41 | "data": "string", 42 | "valid": true 43 | } 44 | ] 45 | } 46 | ] 47 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft2019-09/optional/no-schema.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation without $schema", 4 | "comment": "minLength is the same across all drafts", 5 | "schema": { 6 | "minLength": 2 7 | }, 8 | "tests": [ 9 | { 10 | "description": "a 3-character string is valid", 11 | "data": "foo", 12 | "valid": true 13 | }, 14 | { 15 | "description": "a 1-character string is not valid", 16 | "data": "a", 17 | "valid": false 18 | }, 19 | { 20 | "description": "a non-string is valid", 21 | "data": 5, 22 | "valid": true 23 | } 24 | ] 25 | } 26 | ] 27 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft2020-12/anchor.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "Location-independent identifier", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "$ref": "#foo", 7 | "$defs": { 8 | "A": { 9 | "$anchor": "foo", 10 | "type": "integer" 11 | } 12 | } 13 | }, 14 | "tests": [ 15 | { 16 | "data": "a", 17 | "description": "mismatch", 18 | "valid": false 19 | } 20 | ] 21 | } 22 | ] 23 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft2020-12/defs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validate definition against metaschema", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "$ref": "https://json-schema.org/draft/2020-12/schema" 7 | }, 8 | "tests": [ 9 | { 10 | "description": "valid definition schema", 11 | "data": {"$defs": {"foo": {"type": "integer"}}}, 12 | "valid": true 13 | }, 14 | { 15 | "description": "invalid definition schema", 16 | "data": {"$defs": {"foo": {"type": 1}}}, 17 | "valid": false 18 | } 19 | ] 20 | } 21 | ] 22 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft2020-12/exclusiveMaximum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMaximum validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "exclusiveMaximum": 3.0 7 | }, 8 | "tests": [ 9 | { 10 | "description": "below the exclusiveMaximum is valid", 11 | "data": 2.2, 12 | "valid": true 13 | }, 14 | { 15 | "description": "boundary point is invalid", 16 | "data": 3.0, 17 | "valid": false 18 | }, 19 | { 20 | "description": "above the exclusiveMaximum is invalid", 21 | "data": 3.5, 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-numbers", 26 | "data": "x", 27 | "valid": true 28 | } 29 | ] 30 | } 31 | ] 32 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft2020-12/exclusiveMinimum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMinimum validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "exclusiveMinimum": 1.1 7 | }, 8 | "tests": [ 9 | { 10 | "description": "above the exclusiveMinimum is valid", 11 | "data": 1.2, 12 | "valid": true 13 | }, 14 | { 15 | "description": "boundary point is invalid", 16 | "data": 1.1, 17 | "valid": false 18 | }, 19 | { 20 | "description": "below the exclusiveMinimum is invalid", 21 | "data": 0.6, 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-numbers", 26 | "data": "x", 27 | "valid": true 28 | } 29 | ] 30 | } 31 | ] 32 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft2020-12/infinite-loop-detection.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "evaluating the same schema location against the same data location twice is not a sign of an infinite loop", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "$defs": { 7 | "int": { "type": "integer" } 8 | }, 9 | "allOf": [ 10 | { 11 | "properties": { 12 | "foo": { 13 | "$ref": "#/$defs/int" 14 | } 15 | } 16 | }, 17 | { 18 | "additionalProperties": { 19 | "$ref": "#/$defs/int" 20 | } 21 | } 22 | ] 23 | }, 24 | "tests": [ 25 | { 26 | "description": "passing case", 27 | "data": { "foo": 1 }, 28 | "valid": true 29 | }, 30 | { 31 | "description": "failing case", 32 | "data": { "foo": "a string" }, 33 | "valid": false 34 | } 35 | ] 36 | } 37 | ] 38 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft2020-12/maxItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxItems validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "maxItems": 2 7 | }, 8 | "tests": [ 9 | { 10 | "description": "shorter is valid", 11 | "data": [1], 12 | "valid": true 13 | }, 14 | { 15 | "description": "exact length is valid", 16 | "data": [1, 2], 17 | "valid": true 18 | }, 19 | { 20 | "description": "too long is invalid", 21 | "data": [1, 2, 3], 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-arrays", 26 | "data": "foobar", 27 | "valid": true 28 | } 29 | ] 30 | }, 31 | { 32 | "description": "maxItems validation with a decimal", 33 | "schema": { 34 | "$schema": "https://json-schema.org/draft/2020-12/schema", 35 | "maxItems": 2.0 36 | }, 37 | "tests": [ 38 | { 39 | "description": "shorter is valid", 40 | "data": [1], 41 | "valid": true 42 | }, 43 | { 44 | "description": "too long is invalid", 45 | "data": [1, 2, 3], 46 | "valid": false 47 | } 48 | ] 49 | } 50 | ] 51 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft2020-12/maxLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxLength validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "maxLength": 2 7 | }, 8 | "tests": [ 9 | { 10 | "description": "shorter is valid", 11 | "data": "f", 12 | "valid": true 13 | }, 14 | { 15 | "description": "exact length is valid", 16 | "data": "fo", 17 | "valid": true 18 | }, 19 | { 20 | "description": "too long is invalid", 21 | "data": "foo", 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-strings", 26 | "data": 100, 27 | "valid": true 28 | }, 29 | { 30 | "description": "two graphemes is long enough", 31 | "data": "\uD83D\uDCA9\uD83D\uDCA9", 32 | "valid": true 33 | } 34 | ] 35 | }, 36 | { 37 | "description": "maxLength validation with a decimal", 38 | "schema": { 39 | "$schema": "https://json-schema.org/draft/2020-12/schema", 40 | "maxLength": 2.0 41 | }, 42 | "tests": [ 43 | { 44 | "description": "shorter is valid", 45 | "data": "f", 46 | "valid": true 47 | }, 48 | { 49 | "description": "too long is invalid", 50 | "data": "foo", 51 | "valid": false 52 | } 53 | ] 54 | } 55 | ] 56 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft2020-12/minItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minItems validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "minItems": 1 7 | }, 8 | "tests": [ 9 | { 10 | "description": "longer is valid", 11 | "data": [1, 2], 12 | "valid": true 13 | }, 14 | { 15 | "description": "exact length is valid", 16 | "data": [1], 17 | "valid": true 18 | }, 19 | { 20 | "description": "too short is invalid", 21 | "data": [], 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-arrays", 26 | "data": "", 27 | "valid": true 28 | } 29 | ] 30 | }, 31 | { 32 | "description": "minItems validation with a decimal", 33 | "schema": { 34 | "$schema": "https://json-schema.org/draft/2020-12/schema", 35 | "minItems": 1.0 36 | }, 37 | "tests": [ 38 | { 39 | "description": "longer is valid", 40 | "data": [1, 2], 41 | "valid": true 42 | }, 43 | { 44 | "description": "too short is invalid", 45 | "data": [], 46 | "valid": false 47 | } 48 | ] 49 | } 50 | ] 51 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft2020-12/minLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minLength validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "minLength": 2 7 | }, 8 | "tests": [ 9 | { 10 | "description": "longer is valid", 11 | "data": "foo", 12 | "valid": true 13 | }, 14 | { 15 | "description": "exact length is valid", 16 | "data": "fo", 17 | "valid": true 18 | }, 19 | { 20 | "description": "too short is invalid", 21 | "data": "f", 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-strings", 26 | "data": 1, 27 | "valid": true 28 | }, 29 | { 30 | "description": "one grapheme is not long enough", 31 | "data": "\uD83D\uDCA9", 32 | "valid": false 33 | } 34 | ] 35 | }, 36 | { 37 | "description": "minLength validation with a decimal", 38 | "schema": { 39 | "$schema": "https://json-schema.org/draft/2020-12/schema", 40 | "minLength": 2.0 41 | }, 42 | "tests": [ 43 | { 44 | "description": "longer is valid", 45 | "data": "foo", 46 | "valid": true 47 | }, 48 | { 49 | "description": "too short is invalid", 50 | "data": "f", 51 | "valid": false 52 | } 53 | ] 54 | } 55 | ] 56 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft2020-12/optional/cross-draft.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "refs to historic drafts are processed as historic drafts", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "type": "array", 7 | "$ref": "http://localhost:1234/draft2019-09/ignore-prefixItems.json" 8 | }, 9 | "tests": [ 10 | { 11 | "description": "first item not a string is valid", 12 | "comment": "if the implementation is not processing the $ref as a 2019-09 schema, this test will fail", 13 | "data": [1, 2, 3], 14 | "valid": true 15 | } 16 | ] 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft2020-12/optional/float-overflow.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "all integers are multiples of 0.5, if overflow is handled", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "type": "integer", 7 | "multipleOf": 0.5 8 | }, 9 | "tests": [ 10 | { 11 | "description": "valid if optional overflow handling is implemented", 12 | "data": 1e308, 13 | "valid": true 14 | } 15 | ] 16 | } 17 | ] 18 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft2020-12/optional/format-assertion.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "schema that uses custom metaschema with format-assertion: false", 4 | "schema": { 5 | "$id": "https://schema/using/format-assertion/false", 6 | "$schema": "http://localhost:1234/draft2020-12/format-assertion-false.json", 7 | "format": "ipv4" 8 | }, 9 | "tests": [ 10 | { 11 | "description": "format-assertion: false: valid string", 12 | "data": "127.0.0.1", 13 | "valid": true 14 | }, 15 | { 16 | "description": "format-assertion: false: invalid string", 17 | "data": "not-an-ipv4", 18 | "valid": false 19 | } 20 | ] 21 | }, 22 | { 23 | "description": "schema that uses custom metaschema with format-assertion: true", 24 | "schema": { 25 | "$id": "https://schema/using/format-assertion/true", 26 | "$schema": "http://localhost:1234/draft2020-12/format-assertion-true.json", 27 | "format": "ipv4" 28 | }, 29 | "tests": [ 30 | { 31 | "description": "format-assertion: true: valid string", 32 | "data": "127.0.0.1", 33 | "valid": true 34 | }, 35 | { 36 | "description": "format-assertion: true: invalid string", 37 | "data": "not-an-ipv4", 38 | "valid": false 39 | } 40 | ] 41 | } 42 | ] 43 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft2020-12/optional/format/regex.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of regular expressions", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "format": "regex" 7 | }, 8 | "tests": [ 9 | { 10 | "description": "all string formats ignore integers", 11 | "data": 12, 12 | "valid": true 13 | }, 14 | { 15 | "description": "all string formats ignore floats", 16 | "data": 13.7, 17 | "valid": true 18 | }, 19 | { 20 | "description": "all string formats ignore objects", 21 | "data": {}, 22 | "valid": true 23 | }, 24 | { 25 | "description": "all string formats ignore arrays", 26 | "data": [], 27 | "valid": true 28 | }, 29 | { 30 | "description": "all string formats ignore booleans", 31 | "data": false, 32 | "valid": true 33 | }, 34 | { 35 | "description": "all string formats ignore nulls", 36 | "data": null, 37 | "valid": true 38 | }, 39 | { 40 | "description": "a valid regular expression", 41 | "data": "([abc])+\\s+$", 42 | "valid": true 43 | }, 44 | { 45 | "description": "a regular expression with unclosed parens is invalid", 46 | "data": "^(abc]", 47 | "valid": false 48 | } 49 | ] 50 | } 51 | ] 52 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft2020-12/optional/format/unknown.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "unknown format", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "format": "unknown" 7 | }, 8 | "tests": [ 9 | { 10 | "description": "unknown formats ignore integers", 11 | "data": 12, 12 | "valid": true 13 | }, 14 | { 15 | "description": "unknown formats ignore floats", 16 | "data": 13.7, 17 | "valid": true 18 | }, 19 | { 20 | "description": "unknown formats ignore objects", 21 | "data": {}, 22 | "valid": true 23 | }, 24 | { 25 | "description": "unknown formats ignore arrays", 26 | "data": [], 27 | "valid": true 28 | }, 29 | { 30 | "description": "unknown formats ignore booleans", 31 | "data": false, 32 | "valid": true 33 | }, 34 | { 35 | "description": "unknown formats ignore nulls", 36 | "data": null, 37 | "valid": true 38 | }, 39 | { 40 | "description": "unknown formats ignore strings", 41 | "data": "string", 42 | "valid": true 43 | } 44 | ] 45 | } 46 | ] 47 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft2020-12/optional/no-schema.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation without $schema", 4 | "comment": "minLength is the same across all drafts", 5 | "schema": { 6 | "minLength": 2 7 | }, 8 | "tests": [ 9 | { 10 | "description": "a 3-character string is valid", 11 | "data": "foo", 12 | "valid": true 13 | }, 14 | { 15 | "description": "a 1-character string is not valid", 16 | "data": "a", 17 | "valid": false 18 | }, 19 | { 20 | "description": "a non-string is valid", 21 | "data": 5, 22 | "valid": true 23 | } 24 | ] 25 | } 26 | ] 27 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft3/divisibleBy.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "by int", 4 | "schema": {"divisibleBy": 2}, 5 | "tests": [ 6 | { 7 | "description": "int by int", 8 | "data": 10, 9 | "valid": true 10 | }, 11 | { 12 | "description": "int by int fail", 13 | "data": 7, 14 | "valid": false 15 | }, 16 | { 17 | "description": "ignores non-numbers", 18 | "data": "foo", 19 | "valid": true 20 | } 21 | ] 22 | }, 23 | { 24 | "description": "by number", 25 | "schema": {"divisibleBy": 1.5}, 26 | "tests": [ 27 | { 28 | "description": "zero is divisible by anything (except 0)", 29 | "data": 0, 30 | "valid": true 31 | }, 32 | { 33 | "description": "4.5 is divisible by 1.5", 34 | "data": 4.5, 35 | "valid": true 36 | }, 37 | { 38 | "description": "35 is not divisible by 1.5", 39 | "data": 35, 40 | "valid": false 41 | } 42 | ] 43 | }, 44 | { 45 | "description": "by small number", 46 | "schema": {"divisibleBy": 0.0001}, 47 | "tests": [ 48 | { 49 | "description": "0.0075 is divisible by 0.0001", 50 | "data": 0.0075, 51 | "valid": true 52 | }, 53 | { 54 | "description": "0.00751 is not divisible by 0.0001", 55 | "data": 0.00751, 56 | "valid": false 57 | } 58 | ] 59 | } 60 | ] 61 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft3/infinite-loop-detection.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "evaluating the same schema location against the same data location twice is not a sign of an infinite loop", 4 | "schema": { 5 | "definitions": { 6 | "int": { "type": "integer" } 7 | }, 8 | "properties": { 9 | "foo": { 10 | "$ref": "#/definitions/int" 11 | } 12 | }, 13 | "extends": { 14 | "additionalProperties": { 15 | "$ref": "#/definitions/int" 16 | } 17 | } 18 | }, 19 | "tests": [ 20 | { 21 | "description": "passing case", 22 | "data": { "foo": 1 }, 23 | "valid": true 24 | }, 25 | { 26 | "description": "failing case", 27 | "data": { "foo": "a string" }, 28 | "valid": false 29 | } 30 | ] 31 | } 32 | ] 33 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft3/maxItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxItems validation", 4 | "schema": {"maxItems": 2}, 5 | "tests": [ 6 | { 7 | "description": "shorter is valid", 8 | "data": [1], 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": [1, 2], 14 | "valid": true 15 | }, 16 | { 17 | "description": "too long is invalid", 18 | "data": [1, 2, 3], 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-arrays", 23 | "data": "foobar", 24 | "valid": true 25 | } 26 | ] 27 | } 28 | ] 29 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft3/maxLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxLength validation", 4 | "schema": {"maxLength": 2}, 5 | "tests": [ 6 | { 7 | "description": "shorter is valid", 8 | "data": "f", 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": "fo", 14 | "valid": true 15 | }, 16 | { 17 | "description": "too long is invalid", 18 | "data": "foo", 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-strings", 23 | "data": 10, 24 | "valid": true 25 | }, 26 | { 27 | "description": "two graphemes is long enough", 28 | "data": "\uD83D\uDCA9\uD83D\uDCA9", 29 | "valid": true 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft3/minItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minItems validation", 4 | "schema": {"minItems": 1}, 5 | "tests": [ 6 | { 7 | "description": "longer is valid", 8 | "data": [1, 2], 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": [1], 14 | "valid": true 15 | }, 16 | { 17 | "description": "too short is invalid", 18 | "data": [], 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-arrays", 23 | "data": "", 24 | "valid": true 25 | } 26 | ] 27 | } 28 | ] 29 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft3/minLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minLength validation", 4 | "schema": {"minLength": 2}, 5 | "tests": [ 6 | { 7 | "description": "longer is valid", 8 | "data": "foo", 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": "fo", 14 | "valid": true 15 | }, 16 | { 17 | "description": "too short is invalid", 18 | "data": "f", 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-strings", 23 | "data": 1, 24 | "valid": true 25 | }, 26 | { 27 | "description": "one grapheme is not long enough", 28 | "data": "\uD83D\uDCA9", 29 | "valid": false 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft3/optional/ecmascript-regex.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "ECMA 262 regex dialect recognition", 4 | "schema": { "format": "regex" }, 5 | "tests": [ 6 | { 7 | "description": "[^] is a valid regex", 8 | "data": "[^]", 9 | "valid": true 10 | }, 11 | { 12 | "description": "ECMA 262 has no support for lookbehind", 13 | "data": "(?<=foo)bar", 14 | "valid": false 15 | } 16 | ] 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft3/optional/format/color.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of CSS colors", 4 | "schema": { "format": "color" }, 5 | "tests": [ 6 | { 7 | "description": "a valid CSS color name", 8 | "data": "fuchsia", 9 | "valid": true 10 | }, 11 | { 12 | "description": "a valid six-digit CSS color code", 13 | "data": "#CC8899", 14 | "valid": true 15 | }, 16 | { 17 | "description": "a valid three-digit CSS color code", 18 | "data": "#C89", 19 | "valid": true 20 | }, 21 | { 22 | "description": "an invalid CSS color code", 23 | "data": "#00332520", 24 | "valid": false 25 | }, 26 | { 27 | "description": "an invalid CSS color name", 28 | "data": "puce", 29 | "valid": false 30 | }, 31 | { 32 | "description": "a CSS color name containing invalid characters", 33 | "data": "light_grayish_red-violet", 34 | "valid": false 35 | } 36 | ] 37 | } 38 | ] 39 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft3/optional/format/date-time.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of date-time strings", 4 | "schema": { "format": "date-time" }, 5 | "tests": [ 6 | { 7 | "description": "a valid date-time string", 8 | "data": "1963-06-19T08:30:06.283185Z", 9 | "valid": true 10 | }, 11 | { 12 | "description": "an invalid date-time string", 13 | "data": "06/19/1963 08:30:06 PST", 14 | "valid": false 15 | }, 16 | { 17 | "description": "case-insensitive T and Z", 18 | "data": "1963-06-19t08:30:06.283185z", 19 | "valid": true 20 | }, 21 | { 22 | "description": "only RFC3339 not all of ISO 8601 are valid", 23 | "data": "2013-350T01:01:01", 24 | "valid": false 25 | }, 26 | { 27 | "description": "invalid non-padded month dates", 28 | "data": "1963-6-19T08:30:06.283185Z", 29 | "valid": false 30 | }, 31 | { 32 | "description": "invalid non-padded day dates", 33 | "data": "1963-06-1T08:30:06.283185Z", 34 | "valid": false 35 | } 36 | ] 37 | } 38 | ] 39 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft3/optional/format/ip-address.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of IP addresses", 4 | "schema": { "format": "ip-address" }, 5 | "tests": [ 6 | { 7 | "description": "a valid IP address", 8 | "data": "192.168.0.1", 9 | "valid": true 10 | }, 11 | { 12 | "description": "an IP address with too many components", 13 | "data": "127.0.0.0.1", 14 | "valid": false 15 | }, 16 | { 17 | "description": "an IP address with out-of-range values", 18 | "data": "256.256.256.256", 19 | "valid": false 20 | } 21 | ] 22 | } 23 | ] 24 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft3/optional/format/regex.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of regular expressions", 4 | "schema": { "format": "regex" }, 5 | "tests": [ 6 | { 7 | "description": "a valid regular expression", 8 | "data": "([abc])+\\s+$", 9 | "valid": true 10 | }, 11 | { 12 | "description": "a regular expression with unclosed parens is invalid", 13 | "data": "^(abc]", 14 | "valid": false 15 | } 16 | ] 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft3/optional/format/time.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of time strings", 4 | "schema": { "format": "time" }, 5 | "tests": [ 6 | { 7 | "description": "a valid time string", 8 | "data": "08:30:06", 9 | "valid": true 10 | }, 11 | { 12 | "description": "an invalid time string", 13 | "data": "8:30 AM", 14 | "valid": false 15 | } 16 | ] 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft3/optional/format/uri.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of URIs", 4 | "schema": { "format": "uri" }, 5 | "tests": [ 6 | { 7 | "description": "a valid URI", 8 | "data": "http://foo.bar/?baz=qux#quux", 9 | "valid": true 10 | }, 11 | { 12 | "description": "an invalid protocol-relative URI Reference", 13 | "data": "//foo.bar/?baz=qux#quux", 14 | "valid": false 15 | }, 16 | { 17 | "description": "an invalid URI", 18 | "data": "\\\\WINDOWS\\fileshare", 19 | "valid": false 20 | }, 21 | { 22 | "description": "an invalid URI though valid URI reference", 23 | "data": "abc", 24 | "valid": false 25 | } 26 | ] 27 | } 28 | ] 29 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft3/optional/zeroTerminatedFloats.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "some languages do not distinguish between different types of numeric value", 4 | "schema": { 5 | "type": "integer" 6 | }, 7 | "tests": [ 8 | { 9 | "description": "a float is not an integer even without fractional part", 10 | "data": 1.0, 11 | "valid": false 12 | } 13 | ] 14 | } 15 | ] 16 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft3/pattern.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "pattern validation", 4 | "schema": {"pattern": "^a*$"}, 5 | "tests": [ 6 | { 7 | "description": "a matching pattern is valid", 8 | "data": "aaa", 9 | "valid": true 10 | }, 11 | { 12 | "description": "a non-matching pattern is invalid", 13 | "data": "abc", 14 | "valid": false 15 | }, 16 | { 17 | "description": "ignores booleans", 18 | "data": true, 19 | "valid": true 20 | }, 21 | { 22 | "description": "ignores integers", 23 | "data": 123, 24 | "valid": true 25 | }, 26 | { 27 | "description": "ignores floats", 28 | "data": 1.0, 29 | "valid": true 30 | }, 31 | { 32 | "description": "ignores objects", 33 | "data": {}, 34 | "valid": true 35 | }, 36 | { 37 | "description": "ignores arrays", 38 | "data": [], 39 | "valid": true 40 | }, 41 | { 42 | "description": "ignores null", 43 | "data": null, 44 | "valid": true 45 | } 46 | ] 47 | }, 48 | { 49 | "description": "pattern is not anchored", 50 | "schema": {"pattern": "a+"}, 51 | "tests": [ 52 | { 53 | "description": "matches a substring", 54 | "data": "xxaayy", 55 | "valid": true 56 | } 57 | ] 58 | } 59 | ] 60 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft3/required.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "required validation", 4 | "schema": { 5 | "properties": { 6 | "foo": {"required" : true}, 7 | "bar": {} 8 | } 9 | }, 10 | "tests": [ 11 | { 12 | "description": "present required property is valid", 13 | "data": {"foo": 1}, 14 | "valid": true 15 | }, 16 | { 17 | "description": "non-present required property is invalid", 18 | "data": {"bar": 1}, 19 | "valid": false 20 | } 21 | ] 22 | }, 23 | { 24 | "description": "required default validation", 25 | "schema": { 26 | "properties": { 27 | "foo": {} 28 | } 29 | }, 30 | "tests": [ 31 | { 32 | "description": "not required by default", 33 | "data": {}, 34 | "valid": true 35 | } 36 | ] 37 | }, 38 | { 39 | "description": "required explicitly false validation", 40 | "schema": { 41 | "properties": { 42 | "foo": {"required": false} 43 | } 44 | }, 45 | "tests": [ 46 | { 47 | "description": "not required if required is false", 48 | "data": {}, 49 | "valid": true 50 | } 51 | ] 52 | } 53 | ] 54 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft4/definitions.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validate definition against metaschema", 4 | "schema": {"$ref": "http://json-schema.org/draft-04/schema#"}, 5 | "tests": [ 6 | { 7 | "description": "valid definition schema", 8 | "data": { 9 | "definitions": { 10 | "foo": {"type": "integer"} 11 | } 12 | }, 13 | "valid": true 14 | }, 15 | { 16 | "description": "invalid definition schema", 17 | "data": { 18 | "definitions": { 19 | "foo": {"type": 1} 20 | } 21 | }, 22 | "valid": false 23 | } 24 | ] 25 | } 26 | ] 27 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft4/infinite-loop-detection.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "evaluating the same schema location against the same data location twice is not a sign of an infinite loop", 4 | "schema": { 5 | "definitions": { 6 | "int": { "type": "integer" } 7 | }, 8 | "allOf": [ 9 | { 10 | "properties": { 11 | "foo": { 12 | "$ref": "#/definitions/int" 13 | } 14 | } 15 | }, 16 | { 17 | "additionalProperties": { 18 | "$ref": "#/definitions/int" 19 | } 20 | } 21 | ] 22 | }, 23 | "tests": [ 24 | { 25 | "description": "passing case", 26 | "data": { "foo": 1 }, 27 | "valid": true 28 | }, 29 | { 30 | "description": "failing case", 31 | "data": { "foo": "a string" }, 32 | "valid": false 33 | } 34 | ] 35 | } 36 | ] 37 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft4/maxItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxItems validation", 4 | "schema": {"maxItems": 2}, 5 | "tests": [ 6 | { 7 | "description": "shorter is valid", 8 | "data": [1], 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": [1, 2], 14 | "valid": true 15 | }, 16 | { 17 | "description": "too long is invalid", 18 | "data": [1, 2, 3], 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-arrays", 23 | "data": "foobar", 24 | "valid": true 25 | } 26 | ] 27 | } 28 | ] 29 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft4/maxLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxLength validation", 4 | "schema": {"maxLength": 2}, 5 | "tests": [ 6 | { 7 | "description": "shorter is valid", 8 | "data": "f", 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": "fo", 14 | "valid": true 15 | }, 16 | { 17 | "description": "too long is invalid", 18 | "data": "foo", 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-strings", 23 | "data": 100, 24 | "valid": true 25 | }, 26 | { 27 | "description": "two graphemes is long enough", 28 | "data": "\uD83D\uDCA9\uD83D\uDCA9", 29 | "valid": true 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft4/maxProperties.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxProperties validation", 4 | "schema": {"maxProperties": 2}, 5 | "tests": [ 6 | { 7 | "description": "shorter is valid", 8 | "data": {"foo": 1}, 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": {"foo": 1, "bar": 2}, 14 | "valid": true 15 | }, 16 | { 17 | "description": "too long is invalid", 18 | "data": {"foo": 1, "bar": 2, "baz": 3}, 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores arrays", 23 | "data": [1, 2, 3], 24 | "valid": true 25 | }, 26 | { 27 | "description": "ignores strings", 28 | "data": "foobar", 29 | "valid": true 30 | }, 31 | { 32 | "description": "ignores other non-objects", 33 | "data": 12, 34 | "valid": true 35 | } 36 | ] 37 | }, 38 | { 39 | "description": "maxProperties = 0 means the object is empty", 40 | "schema": { "maxProperties": 0 }, 41 | "tests": [ 42 | { 43 | "description": "no properties is valid", 44 | "data": {}, 45 | "valid": true 46 | }, 47 | { 48 | "description": "one property is invalid", 49 | "data": { "foo": 1 }, 50 | "valid": false 51 | } 52 | ] 53 | } 54 | ] 55 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft4/minItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minItems validation", 4 | "schema": {"minItems": 1}, 5 | "tests": [ 6 | { 7 | "description": "longer is valid", 8 | "data": [1, 2], 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": [1], 14 | "valid": true 15 | }, 16 | { 17 | "description": "too short is invalid", 18 | "data": [], 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-arrays", 23 | "data": "", 24 | "valid": true 25 | } 26 | ] 27 | } 28 | ] 29 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft4/minLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minLength validation", 4 | "schema": {"minLength": 2}, 5 | "tests": [ 6 | { 7 | "description": "longer is valid", 8 | "data": "foo", 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": "fo", 14 | "valid": true 15 | }, 16 | { 17 | "description": "too short is invalid", 18 | "data": "f", 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-strings", 23 | "data": 1, 24 | "valid": true 25 | }, 26 | { 27 | "description": "one grapheme is not long enough", 28 | "data": "\uD83D\uDCA9", 29 | "valid": false 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft4/minProperties.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minProperties validation", 4 | "schema": {"minProperties": 1}, 5 | "tests": [ 6 | { 7 | "description": "longer is valid", 8 | "data": {"foo": 1, "bar": 2}, 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": {"foo": 1}, 14 | "valid": true 15 | }, 16 | { 17 | "description": "too short is invalid", 18 | "data": {}, 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores arrays", 23 | "data": [], 24 | "valid": true 25 | }, 26 | { 27 | "description": "ignores strings", 28 | "data": "", 29 | "valid": true 30 | }, 31 | { 32 | "description": "ignores other non-objects", 33 | "data": 12, 34 | "valid": true 35 | } 36 | ] 37 | } 38 | ] 39 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft4/optional/float-overflow.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "all integers are multiples of 0.5, if overflow is handled", 4 | "schema": {"type": "number", "multipleOf": 0.5}, 5 | "tests": [ 6 | { 7 | "description": "valid if optional overflow handling is implemented", 8 | "data": 1e308, 9 | "valid": true 10 | } 11 | ] 12 | } 13 | ] 14 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft4/optional/format/unknown.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "unknown format", 4 | "schema": { "format": "unknown" }, 5 | "tests": [ 6 | { 7 | "description": "unknown formats ignore integers", 8 | "data": 12, 9 | "valid": true 10 | }, 11 | { 12 | "description": "unknown formats ignore floats", 13 | "data": 13.7, 14 | "valid": true 15 | }, 16 | { 17 | "description": "unknown formats ignore objects", 18 | "data": {}, 19 | "valid": true 20 | }, 21 | { 22 | "description": "unknown formats ignore arrays", 23 | "data": [], 24 | "valid": true 25 | }, 26 | { 27 | "description": "unknown formats ignore booleans", 28 | "data": false, 29 | "valid": true 30 | }, 31 | { 32 | "description": "unknown formats ignore nulls", 33 | "data": null, 34 | "valid": true 35 | }, 36 | { 37 | "description": "unknown formats ignore strings", 38 | "data": "string", 39 | "valid": true 40 | } 41 | ] 42 | } 43 | ] 44 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft4/optional/zeroTerminatedFloats.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "some languages do not distinguish between different types of numeric value", 4 | "schema": { 5 | "type": "integer" 6 | }, 7 | "tests": [ 8 | { 9 | "description": "a float is not an integer even without fractional part", 10 | "data": 1.0, 11 | "valid": false 12 | } 13 | ] 14 | } 15 | ] 16 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft4/pattern.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "pattern validation", 4 | "schema": {"pattern": "^a*$"}, 5 | "tests": [ 6 | { 7 | "description": "a matching pattern is valid", 8 | "data": "aaa", 9 | "valid": true 10 | }, 11 | { 12 | "description": "a non-matching pattern is invalid", 13 | "data": "abc", 14 | "valid": false 15 | }, 16 | { 17 | "description": "ignores booleans", 18 | "data": true, 19 | "valid": true 20 | }, 21 | { 22 | "description": "ignores integers", 23 | "data": 123, 24 | "valid": true 25 | }, 26 | { 27 | "description": "ignores floats", 28 | "data": 1.0, 29 | "valid": true 30 | }, 31 | { 32 | "description": "ignores objects", 33 | "data": {}, 34 | "valid": true 35 | }, 36 | { 37 | "description": "ignores arrays", 38 | "data": [], 39 | "valid": true 40 | }, 41 | { 42 | "description": "ignores null", 43 | "data": null, 44 | "valid": true 45 | } 46 | ] 47 | }, 48 | { 49 | "description": "pattern is not anchored", 50 | "schema": {"pattern": "a+"}, 51 | "tests": [ 52 | { 53 | "description": "matches a substring", 54 | "data": "xxaayy", 55 | "valid": true 56 | } 57 | ] 58 | } 59 | ] 60 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft6/definitions.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validate definition against metaschema", 4 | "schema": {"$ref": "http://json-schema.org/draft-06/schema#"}, 5 | "tests": [ 6 | { 7 | "description": "valid definition schema", 8 | "data": { 9 | "definitions": { 10 | "foo": {"type": "integer"} 11 | } 12 | }, 13 | "valid": true 14 | }, 15 | { 16 | "description": "invalid definition schema", 17 | "data": { 18 | "definitions": { 19 | "foo": {"type": 1} 20 | } 21 | }, 22 | "valid": false 23 | } 24 | ] 25 | } 26 | ] 27 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft6/exclusiveMaximum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMaximum validation", 4 | "schema": { 5 | "exclusiveMaximum": 3.0 6 | }, 7 | "tests": [ 8 | { 9 | "description": "below the exclusiveMaximum is valid", 10 | "data": 2.2, 11 | "valid": true 12 | }, 13 | { 14 | "description": "boundary point is invalid", 15 | "data": 3.0, 16 | "valid": false 17 | }, 18 | { 19 | "description": "above the exclusiveMaximum is invalid", 20 | "data": 3.5, 21 | "valid": false 22 | }, 23 | { 24 | "description": "ignores non-numbers", 25 | "data": "x", 26 | "valid": true 27 | } 28 | ] 29 | } 30 | ] 31 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft6/exclusiveMinimum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMinimum validation", 4 | "schema": { 5 | "exclusiveMinimum": 1.1 6 | }, 7 | "tests": [ 8 | { 9 | "description": "above the exclusiveMinimum is valid", 10 | "data": 1.2, 11 | "valid": true 12 | }, 13 | { 14 | "description": "boundary point is invalid", 15 | "data": 1.1, 16 | "valid": false 17 | }, 18 | { 19 | "description": "below the exclusiveMinimum is invalid", 20 | "data": 0.6, 21 | "valid": false 22 | }, 23 | { 24 | "description": "ignores non-numbers", 25 | "data": "x", 26 | "valid": true 27 | } 28 | ] 29 | } 30 | ] 31 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft6/infinite-loop-detection.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "evaluating the same schema location against the same data location twice is not a sign of an infinite loop", 4 | "schema": { 5 | "definitions": { 6 | "int": { "type": "integer" } 7 | }, 8 | "allOf": [ 9 | { 10 | "properties": { 11 | "foo": { 12 | "$ref": "#/definitions/int" 13 | } 14 | } 15 | }, 16 | { 17 | "additionalProperties": { 18 | "$ref": "#/definitions/int" 19 | } 20 | } 21 | ] 22 | }, 23 | "tests": [ 24 | { 25 | "description": "passing case", 26 | "data": { "foo": 1 }, 27 | "valid": true 28 | }, 29 | { 30 | "description": "failing case", 31 | "data": { "foo": "a string" }, 32 | "valid": false 33 | } 34 | ] 35 | } 36 | ] 37 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft6/maxItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxItems validation", 4 | "schema": {"maxItems": 2}, 5 | "tests": [ 6 | { 7 | "description": "shorter is valid", 8 | "data": [1], 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": [1, 2], 14 | "valid": true 15 | }, 16 | { 17 | "description": "too long is invalid", 18 | "data": [1, 2, 3], 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-arrays", 23 | "data": "foobar", 24 | "valid": true 25 | } 26 | ] 27 | }, 28 | { 29 | "description": "maxItems validation with a decimal", 30 | "schema": {"maxItems": 2.0}, 31 | "tests": [ 32 | { 33 | "description": "shorter is valid", 34 | "data": [1], 35 | "valid": true 36 | }, 37 | { 38 | "description": "too long is invalid", 39 | "data": [1, 2, 3], 40 | "valid": false 41 | } 42 | ] 43 | } 44 | ] 45 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft6/maxLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxLength validation", 4 | "schema": {"maxLength": 2}, 5 | "tests": [ 6 | { 7 | "description": "shorter is valid", 8 | "data": "f", 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": "fo", 14 | "valid": true 15 | }, 16 | { 17 | "description": "too long is invalid", 18 | "data": "foo", 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-strings", 23 | "data": 100, 24 | "valid": true 25 | }, 26 | { 27 | "description": "two graphemes is long enough", 28 | "data": "\uD83D\uDCA9\uD83D\uDCA9", 29 | "valid": true 30 | } 31 | ] 32 | }, 33 | { 34 | "description": "maxLength validation with a decimal", 35 | "schema": {"maxLength": 2.0}, 36 | "tests": [ 37 | { 38 | "description": "shorter is valid", 39 | "data": "f", 40 | "valid": true 41 | }, 42 | { 43 | "description": "too long is invalid", 44 | "data": "foo", 45 | "valid": false 46 | } 47 | ] 48 | } 49 | ] 50 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft6/maximum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maximum validation", 4 | "schema": {"maximum": 3.0}, 5 | "tests": [ 6 | { 7 | "description": "below the maximum is valid", 8 | "data": 2.6, 9 | "valid": true 10 | }, 11 | { 12 | "description": "boundary point is valid", 13 | "data": 3.0, 14 | "valid": true 15 | }, 16 | { 17 | "description": "above the maximum is invalid", 18 | "data": 3.5, 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-numbers", 23 | "data": "x", 24 | "valid": true 25 | } 26 | ] 27 | }, 28 | { 29 | "description": "maximum validation with unsigned integer", 30 | "schema": {"maximum": 300}, 31 | "tests": [ 32 | { 33 | "description": "below the maximum is invalid", 34 | "data": 299.97, 35 | "valid": true 36 | }, 37 | { 38 | "description": "boundary point integer is valid", 39 | "data": 300, 40 | "valid": true 41 | }, 42 | { 43 | "description": "boundary point float is valid", 44 | "data": 300.00, 45 | "valid": true 46 | }, 47 | { 48 | "description": "above the maximum is invalid", 49 | "data": 300.5, 50 | "valid": false 51 | } 52 | ] 53 | } 54 | ] 55 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft6/minItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minItems validation", 4 | "schema": {"minItems": 1}, 5 | "tests": [ 6 | { 7 | "description": "longer is valid", 8 | "data": [1, 2], 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": [1], 14 | "valid": true 15 | }, 16 | { 17 | "description": "too short is invalid", 18 | "data": [], 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-arrays", 23 | "data": "", 24 | "valid": true 25 | } 26 | ] 27 | }, 28 | { 29 | "description": "minItems validation with a decimal", 30 | "schema": {"minItems": 1.0}, 31 | "tests": [ 32 | { 33 | "description": "longer is valid", 34 | "data": [1, 2], 35 | "valid": true 36 | }, 37 | { 38 | "description": "too short is invalid", 39 | "data": [], 40 | "valid": false 41 | } 42 | ] 43 | } 44 | ] 45 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft6/minLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minLength validation", 4 | "schema": {"minLength": 2}, 5 | "tests": [ 6 | { 7 | "description": "longer is valid", 8 | "data": "foo", 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": "fo", 14 | "valid": true 15 | }, 16 | { 17 | "description": "too short is invalid", 18 | "data": "f", 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-strings", 23 | "data": 1, 24 | "valid": true 25 | }, 26 | { 27 | "description": "one grapheme is not long enough", 28 | "data": "\uD83D\uDCA9", 29 | "valid": false 30 | } 31 | ] 32 | }, 33 | { 34 | "description": "minLength validation with a decimal", 35 | "schema": {"minLength": 2.0}, 36 | "tests": [ 37 | { 38 | "description": "longer is valid", 39 | "data": "foo", 40 | "valid": true 41 | }, 42 | { 43 | "description": "too short is invalid", 44 | "data": "f", 45 | "valid": false 46 | } 47 | ] 48 | } 49 | ] 50 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft6/minProperties.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minProperties validation", 4 | "schema": {"minProperties": 1}, 5 | "tests": [ 6 | { 7 | "description": "longer is valid", 8 | "data": {"foo": 1, "bar": 2}, 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": {"foo": 1}, 14 | "valid": true 15 | }, 16 | { 17 | "description": "too short is invalid", 18 | "data": {}, 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores arrays", 23 | "data": [], 24 | "valid": true 25 | }, 26 | { 27 | "description": "ignores strings", 28 | "data": "", 29 | "valid": true 30 | }, 31 | { 32 | "description": "ignores other non-objects", 33 | "data": 12, 34 | "valid": true 35 | } 36 | ] 37 | }, 38 | { 39 | "description": "minProperties validation with a decimal", 40 | "schema": {"minProperties": 1.0}, 41 | "tests": [ 42 | { 43 | "description": "longer is valid", 44 | "data": {"foo": 1, "bar": 2}, 45 | "valid": true 46 | }, 47 | { 48 | "description": "too short is invalid", 49 | "data": {}, 50 | "valid": false 51 | } 52 | ] 53 | } 54 | ] 55 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft6/optional/float-overflow.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "all integers are multiples of 0.5, if overflow is handled", 4 | "schema": {"type": "integer", "multipleOf": 0.5}, 5 | "tests": [ 6 | { 7 | "description": "valid if optional overflow handling is implemented", 8 | "data": 1e308, 9 | "valid": true 10 | } 11 | ] 12 | } 13 | ] 14 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft6/optional/format/unknown.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "unknown format", 4 | "schema": { "format": "unknown" }, 5 | "tests": [ 6 | { 7 | "description": "unknown formats ignore integers", 8 | "data": 12, 9 | "valid": true 10 | }, 11 | { 12 | "description": "unknown formats ignore floats", 13 | "data": 13.7, 14 | "valid": true 15 | }, 16 | { 17 | "description": "unknown formats ignore objects", 18 | "data": {}, 19 | "valid": true 20 | }, 21 | { 22 | "description": "unknown formats ignore arrays", 23 | "data": [], 24 | "valid": true 25 | }, 26 | { 27 | "description": "unknown formats ignore booleans", 28 | "data": false, 29 | "valid": true 30 | }, 31 | { 32 | "description": "unknown formats ignore nulls", 33 | "data": null, 34 | "valid": true 35 | }, 36 | { 37 | "description": "unknown formats ignore strings", 38 | "data": "string", 39 | "valid": true 40 | } 41 | ] 42 | } 43 | ] 44 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft6/pattern.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "pattern validation", 4 | "schema": {"pattern": "^a*$"}, 5 | "tests": [ 6 | { 7 | "description": "a matching pattern is valid", 8 | "data": "aaa", 9 | "valid": true 10 | }, 11 | { 12 | "description": "a non-matching pattern is invalid", 13 | "data": "abc", 14 | "valid": false 15 | }, 16 | { 17 | "description": "ignores booleans", 18 | "data": true, 19 | "valid": true 20 | }, 21 | { 22 | "description": "ignores integers", 23 | "data": 123, 24 | "valid": true 25 | }, 26 | { 27 | "description": "ignores floats", 28 | "data": 1.0, 29 | "valid": true 30 | }, 31 | { 32 | "description": "ignores objects", 33 | "data": {}, 34 | "valid": true 35 | }, 36 | { 37 | "description": "ignores arrays", 38 | "data": [], 39 | "valid": true 40 | }, 41 | { 42 | "description": "ignores null", 43 | "data": null, 44 | "valid": true 45 | } 46 | ] 47 | }, 48 | { 49 | "description": "pattern is not anchored", 50 | "schema": {"pattern": "a+"}, 51 | "tests": [ 52 | { 53 | "description": "matches a substring", 54 | "data": "xxaayy", 55 | "valid": true 56 | } 57 | ] 58 | } 59 | ] 60 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft7/definitions.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validate definition against metaschema", 4 | "schema": {"$ref": "http://json-schema.org/draft-07/schema#"}, 5 | "tests": [ 6 | { 7 | "description": "valid definition schema", 8 | "data": { 9 | "definitions": { 10 | "foo": {"type": "integer"} 11 | } 12 | }, 13 | "valid": true 14 | }, 15 | { 16 | "description": "invalid definition schema", 17 | "data": { 18 | "definitions": { 19 | "foo": {"type": 1} 20 | } 21 | }, 22 | "valid": false 23 | } 24 | ] 25 | } 26 | ] 27 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft7/exclusiveMaximum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMaximum validation", 4 | "schema": { 5 | "exclusiveMaximum": 3.0 6 | }, 7 | "tests": [ 8 | { 9 | "description": "below the exclusiveMaximum is valid", 10 | "data": 2.2, 11 | "valid": true 12 | }, 13 | { 14 | "description": "boundary point is invalid", 15 | "data": 3.0, 16 | "valid": false 17 | }, 18 | { 19 | "description": "above the exclusiveMaximum is invalid", 20 | "data": 3.5, 21 | "valid": false 22 | }, 23 | { 24 | "description": "ignores non-numbers", 25 | "data": "x", 26 | "valid": true 27 | } 28 | ] 29 | } 30 | ] 31 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft7/exclusiveMinimum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMinimum validation", 4 | "schema": { 5 | "exclusiveMinimum": 1.1 6 | }, 7 | "tests": [ 8 | { 9 | "description": "above the exclusiveMinimum is valid", 10 | "data": 1.2, 11 | "valid": true 12 | }, 13 | { 14 | "description": "boundary point is invalid", 15 | "data": 1.1, 16 | "valid": false 17 | }, 18 | { 19 | "description": "below the exclusiveMinimum is invalid", 20 | "data": 0.6, 21 | "valid": false 22 | }, 23 | { 24 | "description": "ignores non-numbers", 25 | "data": "x", 26 | "valid": true 27 | } 28 | ] 29 | } 30 | ] 31 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft7/infinite-loop-detection.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "evaluating the same schema location against the same data location twice is not a sign of an infinite loop", 4 | "schema": { 5 | "definitions": { 6 | "int": { "type": "integer" } 7 | }, 8 | "allOf": [ 9 | { 10 | "properties": { 11 | "foo": { 12 | "$ref": "#/definitions/int" 13 | } 14 | } 15 | }, 16 | { 17 | "additionalProperties": { 18 | "$ref": "#/definitions/int" 19 | } 20 | } 21 | ] 22 | }, 23 | "tests": [ 24 | { 25 | "description": "passing case", 26 | "data": { "foo": 1 }, 27 | "valid": true 28 | }, 29 | { 30 | "description": "failing case", 31 | "data": { "foo": "a string" }, 32 | "valid": false 33 | } 34 | ] 35 | } 36 | ] 37 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft7/maxItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxItems validation", 4 | "schema": {"maxItems": 2}, 5 | "tests": [ 6 | { 7 | "description": "shorter is valid", 8 | "data": [1], 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": [1, 2], 14 | "valid": true 15 | }, 16 | { 17 | "description": "too long is invalid", 18 | "data": [1, 2, 3], 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-arrays", 23 | "data": "foobar", 24 | "valid": true 25 | } 26 | ] 27 | }, 28 | { 29 | "description": "maxItems validation with a decimal", 30 | "schema": {"maxItems": 2.0}, 31 | "tests": [ 32 | { 33 | "description": "shorter is valid", 34 | "data": [1], 35 | "valid": true 36 | }, 37 | { 38 | "description": "too long is invalid", 39 | "data": [1, 2, 3], 40 | "valid": false 41 | } 42 | ] 43 | } 44 | ] 45 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft7/maxLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxLength validation", 4 | "schema": {"maxLength": 2}, 5 | "tests": [ 6 | { 7 | "description": "shorter is valid", 8 | "data": "f", 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": "fo", 14 | "valid": true 15 | }, 16 | { 17 | "description": "too long is invalid", 18 | "data": "foo", 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-strings", 23 | "data": 100, 24 | "valid": true 25 | }, 26 | { 27 | "description": "two graphemes is long enough", 28 | "data": "\uD83D\uDCA9\uD83D\uDCA9", 29 | "valid": true 30 | } 31 | ] 32 | }, 33 | { 34 | "description": "maxLength validation with a decimal", 35 | "schema": {"maxLength": 2.0}, 36 | "tests": [ 37 | { 38 | "description": "shorter is valid", 39 | "data": "f", 40 | "valid": true 41 | }, 42 | { 43 | "description": "too long is invalid", 44 | "data": "foo", 45 | "valid": false 46 | } 47 | ] 48 | } 49 | ] 50 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft7/maximum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maximum validation", 4 | "schema": {"maximum": 3.0}, 5 | "tests": [ 6 | { 7 | "description": "below the maximum is valid", 8 | "data": 2.6, 9 | "valid": true 10 | }, 11 | { 12 | "description": "boundary point is valid", 13 | "data": 3.0, 14 | "valid": true 15 | }, 16 | { 17 | "description": "above the maximum is invalid", 18 | "data": 3.5, 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-numbers", 23 | "data": "x", 24 | "valid": true 25 | } 26 | ] 27 | }, 28 | { 29 | "description": "maximum validation with unsigned integer", 30 | "schema": {"maximum": 300}, 31 | "tests": [ 32 | { 33 | "description": "below the maximum is invalid", 34 | "data": 299.97, 35 | "valid": true 36 | }, 37 | { 38 | "description": "boundary point integer is valid", 39 | "data": 300, 40 | "valid": true 41 | }, 42 | { 43 | "description": "boundary point float is valid", 44 | "data": 300.00, 45 | "valid": true 46 | }, 47 | { 48 | "description": "above the maximum is invalid", 49 | "data": 300.5, 50 | "valid": false 51 | } 52 | ] 53 | } 54 | ] 55 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft7/minItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minItems validation", 4 | "schema": {"minItems": 1}, 5 | "tests": [ 6 | { 7 | "description": "longer is valid", 8 | "data": [1, 2], 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": [1], 14 | "valid": true 15 | }, 16 | { 17 | "description": "too short is invalid", 18 | "data": [], 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-arrays", 23 | "data": "", 24 | "valid": true 25 | } 26 | ] 27 | }, 28 | { 29 | "description": "minItems validation with a decimal", 30 | "schema": {"minItems": 1.0}, 31 | "tests": [ 32 | { 33 | "description": "longer is valid", 34 | "data": [1, 2], 35 | "valid": true 36 | }, 37 | { 38 | "description": "too short is invalid", 39 | "data": [], 40 | "valid": false 41 | } 42 | ] 43 | } 44 | ] 45 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft7/minLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minLength validation", 4 | "schema": {"minLength": 2}, 5 | "tests": [ 6 | { 7 | "description": "longer is valid", 8 | "data": "foo", 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": "fo", 14 | "valid": true 15 | }, 16 | { 17 | "description": "too short is invalid", 18 | "data": "f", 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-strings", 23 | "data": 1, 24 | "valid": true 25 | }, 26 | { 27 | "description": "one grapheme is not long enough", 28 | "data": "\uD83D\uDCA9", 29 | "valid": false 30 | } 31 | ] 32 | }, 33 | { 34 | "description": "minLength validation with a decimal", 35 | "schema": {"minLength": 2.0}, 36 | "tests": [ 37 | { 38 | "description": "longer is valid", 39 | "data": "foo", 40 | "valid": true 41 | }, 42 | { 43 | "description": "too short is invalid", 44 | "data": "f", 45 | "valid": false 46 | } 47 | ] 48 | } 49 | ] 50 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft7/minProperties.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minProperties validation", 4 | "schema": {"minProperties": 1}, 5 | "tests": [ 6 | { 7 | "description": "longer is valid", 8 | "data": {"foo": 1, "bar": 2}, 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": {"foo": 1}, 14 | "valid": true 15 | }, 16 | { 17 | "description": "too short is invalid", 18 | "data": {}, 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores arrays", 23 | "data": [], 24 | "valid": true 25 | }, 26 | { 27 | "description": "ignores strings", 28 | "data": "", 29 | "valid": true 30 | }, 31 | { 32 | "description": "ignores other non-objects", 33 | "data": 12, 34 | "valid": true 35 | } 36 | ] 37 | }, 38 | { 39 | "description": "minProperties validation with a decimal", 40 | "schema": {"minProperties": 1.0}, 41 | "tests": [ 42 | { 43 | "description": "longer is valid", 44 | "data": {"foo": 1, "bar": 2}, 45 | "valid": true 46 | }, 47 | { 48 | "description": "too short is invalid", 49 | "data": {}, 50 | "valid": false 51 | } 52 | ] 53 | } 54 | ] 55 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft7/optional/cross-draft.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "refs to future drafts are processed as future drafts", 4 | "schema": { 5 | "type": "object", 6 | "allOf": [ 7 | { "properties": { "foo": true } }, 8 | { "$ref": "http://localhost:1234/draft2019-09/dependentRequired.json" } 9 | ] 10 | }, 11 | "tests": [ 12 | { 13 | "description": "missing bar is invalid", 14 | "comment": "if the implementation is not processing the $ref as a 2019-09 schema, this test will fail", 15 | "data": {"foo": "any value"}, 16 | "valid": false 17 | }, 18 | { 19 | "description": "present bar is valid", 20 | "data": {"foo": "any value", "bar": "also any value"}, 21 | "valid": true 22 | } 23 | ] 24 | } 25 | ] 26 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft7/optional/float-overflow.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "all integers are multiples of 0.5, if overflow is handled", 4 | "schema": {"type": "integer", "multipleOf": 0.5}, 5 | "tests": [ 6 | { 7 | "description": "valid if optional overflow handling is implemented", 8 | "data": 1e308, 9 | "valid": true 10 | } 11 | ] 12 | } 13 | ] 14 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft7/optional/format/regex.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of regular expressions", 4 | "schema": { "format": "regex" }, 5 | "tests": [ 6 | { 7 | "description": "all string formats ignore integers", 8 | "data": 12, 9 | "valid": true 10 | }, 11 | { 12 | "description": "all string formats ignore floats", 13 | "data": 13.7, 14 | "valid": true 15 | }, 16 | { 17 | "description": "all string formats ignore objects", 18 | "data": {}, 19 | "valid": true 20 | }, 21 | { 22 | "description": "all string formats ignore arrays", 23 | "data": [], 24 | "valid": true 25 | }, 26 | { 27 | "description": "all string formats ignore booleans", 28 | "data": false, 29 | "valid": true 30 | }, 31 | { 32 | "description": "all string formats ignore nulls", 33 | "data": null, 34 | "valid": true 35 | }, 36 | { 37 | "description": "a valid regular expression", 38 | "data": "([abc])+\\s+$", 39 | "valid": true 40 | }, 41 | { 42 | "description": "a regular expression with unclosed parens is invalid", 43 | "data": "^(abc]", 44 | "valid": false 45 | } 46 | ] 47 | } 48 | ] 49 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft7/optional/format/unknown.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "unknown format", 4 | "schema": { "format": "unknown" }, 5 | "tests": [ 6 | { 7 | "description": "unknown formats ignore integers", 8 | "data": 12, 9 | "valid": true 10 | }, 11 | { 12 | "description": "unknown formats ignore floats", 13 | "data": 13.7, 14 | "valid": true 15 | }, 16 | { 17 | "description": "unknown formats ignore objects", 18 | "data": {}, 19 | "valid": true 20 | }, 21 | { 22 | "description": "unknown formats ignore arrays", 23 | "data": [], 24 | "valid": true 25 | }, 26 | { 27 | "description": "unknown formats ignore booleans", 28 | "data": false, 29 | "valid": true 30 | }, 31 | { 32 | "description": "unknown formats ignore nulls", 33 | "data": null, 34 | "valid": true 35 | }, 36 | { 37 | "description": "unknown formats ignore strings", 38 | "data": "string", 39 | "valid": true 40 | } 41 | ] 42 | } 43 | ] 44 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/draft7/pattern.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "pattern validation", 4 | "schema": {"pattern": "^a*$"}, 5 | "tests": [ 6 | { 7 | "description": "a matching pattern is valid", 8 | "data": "aaa", 9 | "valid": true 10 | }, 11 | { 12 | "description": "a non-matching pattern is invalid", 13 | "data": "abc", 14 | "valid": false 15 | }, 16 | { 17 | "description": "ignores booleans", 18 | "data": true, 19 | "valid": true 20 | }, 21 | { 22 | "description": "ignores integers", 23 | "data": 123, 24 | "valid": true 25 | }, 26 | { 27 | "description": "ignores floats", 28 | "data": 1.0, 29 | "valid": true 30 | }, 31 | { 32 | "description": "ignores objects", 33 | "data": {}, 34 | "valid": true 35 | }, 36 | { 37 | "description": "ignores arrays", 38 | "data": [], 39 | "valid": true 40 | }, 41 | { 42 | "description": "ignores null", 43 | "data": null, 44 | "valid": true 45 | } 46 | ] 47 | }, 48 | { 49 | "description": "pattern is not anchored", 50 | "schema": {"pattern": "a+"}, 51 | "tests": [ 52 | { 53 | "description": "matches a substring", 54 | "data": "xxaayy", 55 | "valid": true 56 | } 57 | ] 58 | } 59 | ] 60 | -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tests/latest: -------------------------------------------------------------------------------- 1 | draft2020-12 -------------------------------------------------------------------------------- /testdata/JSON-Schema-Test-Suite/tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | minversion = 1.6 3 | envlist = sanity 4 | skipsdist = True 5 | 6 | [testenv:sanity] 7 | # used just for validating the structure of the test case files themselves 8 | deps = jsonschema==4.19.0 9 | commands = {envpython} bin/jsonschema_suite check 10 | -------------------------------------------------------------------------------- /tests/additionalProperties_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | // TestAdditionalPropertiesForTestSuite executes the additionalProperties validation tests for Schema Test Suite. 8 | func TestAdditionalPropertiesForTestSuite(t *testing.T) { 9 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/additionalProperties.json") 10 | } 11 | -------------------------------------------------------------------------------- /tests/allOf_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import "testing" 4 | 5 | // TestAllOfForTestSuite executes the allOf validation tests for Schema Test Suite. 6 | func TestAllOfForTestSuite(t *testing.T) { 7 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/allOf.json") 8 | } 9 | -------------------------------------------------------------------------------- /tests/anchor_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | // TestAnchorForTestSuite executes the anchor validation tests for Schema Test Suite. 8 | func TestAnchorForTestSuite(t *testing.T) { 9 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/anchor.json") 10 | } 11 | -------------------------------------------------------------------------------- /tests/anyOf_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import "testing" 4 | 5 | // TestAnyOfForTestSuite executes the anyOf validation tests for Schema Test Suite. 6 | func TestAnyOfForTestSuite(t *testing.T) { 7 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/anyOf.json") 8 | } 9 | -------------------------------------------------------------------------------- /tests/bignum_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import "testing" 4 | 5 | // TestBigNumForTestSuite executes the bignum validation tests for Schema Test Suite. 6 | func TestBigNumForTestSuite(t *testing.T) { 7 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/optional/bignum.json") 8 | } 9 | -------------------------------------------------------------------------------- /tests/boolean_schema_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | // TestBooleanSchemaForTestSuite executes the boolean_schema validation tests for Schema Test Suite. 8 | func TestBooleanSchemaForTestSuite(t *testing.T) { 9 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/boolean_schema.json") 10 | } 11 | -------------------------------------------------------------------------------- /tests/contains_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import "testing" 4 | 5 | // TestContainsForTestSuite executes the contains validation tests for Schema Test Suite. 6 | func TestContainsForTestSuite(t *testing.T) { 7 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/contains.json") 8 | } 9 | -------------------------------------------------------------------------------- /tests/content_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import "testing" 4 | 5 | // TestContentForTestSuite executes the content validation tests for Schema Test Suite. 6 | func TestContentForTestSuite(t *testing.T) { 7 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/content.json", 8 | "validation of string-encoded content based on media type/an invalid JSON document; validates true", 9 | "validation of binary string-encoding/an invalid base64 string (% is not a valid character); validates true", 10 | "validation of binary-encoded media type documents/a validly-encoded invalid JSON document; validates true", 11 | "validation of binary-encoded media type documents/an invalid base64 string that is valid JSON; validates true", 12 | "validation of binary-encoded media type documents with schema/an invalid base64-encoded JSON document; validates true", 13 | "validation of binary-encoded media type documents with schema/an empty object as a base64-encoded JSON document; validates true", 14 | "validation of binary-encoded media type documents with schema/an empty array as a base64-encoded JSON document", 15 | "validation of binary-encoded media type documents with schema/a validly-encoded invalid JSON document; validates true", 16 | "validation of binary-encoded media type documents with schema/an invalid base64 string that is valid JSON; validates true", 17 | ) 18 | } 19 | -------------------------------------------------------------------------------- /tests/default_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import "testing" 4 | 5 | // TestDefaultForTestSuite executes the default validation tests for Schema Test Suite. 6 | func TestDefaultForTestSuite(t *testing.T) { 7 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/default.json") 8 | } 9 | -------------------------------------------------------------------------------- /tests/defs_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | // TestDefsForTestSuite executes the defs validation tests for Schema Test Suite. 8 | func TestDefsForTestSuite(t *testing.T) { 9 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/defs.json") 10 | } 11 | -------------------------------------------------------------------------------- /tests/dependentRequired_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import "testing" 4 | 5 | // TestDependentRequiredForTestSuite executes the dependentRequired validation tests for Schema Test Suite. 6 | func TestDependentRequiredForTestSuite(t *testing.T) { 7 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/dependentRequired.json") 8 | } 9 | -------------------------------------------------------------------------------- /tests/dependentSchemas_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import "testing" 4 | 5 | // TestDependentSchemasForTestSuite executes the dependentSchemas validation tests for Schema Test Suite. 6 | func TestDependentSchemasForTestSuite(t *testing.T) { 7 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/dependentSchemas.json") 8 | } 9 | -------------------------------------------------------------------------------- /tests/dynamicRef_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import "testing" 4 | 5 | // TestDynamicRefForTestSuite executes the dynamicRef validation tests for Schema Test Suite. 6 | func TestDynamicRefForTestSuite(t *testing.T) { 7 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/dynamicRef.json") 8 | } 9 | -------------------------------------------------------------------------------- /tests/if_then_else_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import "testing" 4 | 5 | // TestIfThenElseForTestSuite executes the if-then-else validation tests for Schema Test Suite. 6 | func TestIfThenElseForTestSuite(t *testing.T) { 7 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/if-then-else.json") 8 | } 9 | -------------------------------------------------------------------------------- /tests/items_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import "testing" 4 | 5 | // TestItemsForTestSuite executes the items validation tests for Schema Test Suite. 6 | func TestItemsForTestSuite(t *testing.T) { 7 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/items.json") 8 | } 9 | -------------------------------------------------------------------------------- /tests/maxContains_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import "testing" 4 | 5 | // TestMaxContainsForTestSuite executes the maxContains validation tests for Schema Test Suite. 6 | func TestMaxContainsForTestSuite(t *testing.T) { 7 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/maxContains.json") 8 | } 9 | -------------------------------------------------------------------------------- /tests/maxItems_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | // TestMaxItemsForTestSuite executes the maxItems validation tests for Schema Test Suite. 8 | func TestMaxItemsForTestSuite(t *testing.T) { 9 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/maxItems.json") 10 | } 11 | -------------------------------------------------------------------------------- /tests/maxProperties_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import "testing" 4 | 5 | // TestMaxPropertiesForTestSuite executes the maxProperties validation tests for Schema Test Suite. 6 | func TestMaxPropertiesForTestSuite(t *testing.T) { 7 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/maxProperties.json") 8 | } 9 | -------------------------------------------------------------------------------- /tests/minContains_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import "testing" 4 | 5 | // TestMinContainsForTestSuite executes the minContains validation tests for Schema Test Suite. 6 | func TestMinContainsForTestSuite(t *testing.T) { 7 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/minContains.json") 8 | } 9 | -------------------------------------------------------------------------------- /tests/minItems_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import "testing" 4 | 5 | // TestMinItemsForTestSuite executes the minItems validation tests for Schema Test Suite. 6 | func TestMinItemsForTestSuite(t *testing.T) { 7 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/minItems.json") 8 | } 9 | -------------------------------------------------------------------------------- /tests/minProperties_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import "testing" 4 | 5 | // TestMinPropertiesForTestSuite executes the minProperties validation tests for Schema Test Suite. 6 | func TestMinPropertiesForTestSuite(t *testing.T) { 7 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/minProperties.json") 8 | } 9 | -------------------------------------------------------------------------------- /tests/not_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import "testing" 4 | 5 | // TestNotForTestSuite executes the not validation tests for Schema Test Suite. 6 | func TestNotForTestSuite(t *testing.T) { 7 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/not.json") 8 | } 9 | -------------------------------------------------------------------------------- /tests/oneOf_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import "testing" 4 | 5 | // TestOneOfForTestSuite executes the oneOf validation tests for Schema Test Suite. 6 | func TestOneOfForTestSuite(t *testing.T) { 7 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/oneOf.json") 8 | } 9 | -------------------------------------------------------------------------------- /tests/patternProperties_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | // TestPatternPropertiesForTestSuite executes the patternProperties validation tests for Schema Test Suite. 8 | func TestPatternPropertiesForTestSuite(t *testing.T) { 9 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/patternProperties.json") 10 | } 11 | -------------------------------------------------------------------------------- /tests/prefixItems_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import "testing" 4 | 5 | // TestPrefixItemsForTestSuite executes the prefixItems validation tests for Schema Test Suite. 6 | func TestPrefixItemsForTestSuite(t *testing.T) { 7 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/prefixItems.json") 8 | } 9 | -------------------------------------------------------------------------------- /tests/propertyNames_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import "testing" 4 | 5 | // TestPropertyNamesForTestSuite executes the propertyNames validation tests for Schema Test Suite. 6 | func TestPropertyNamesForTestSuite(t *testing.T) { 7 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/propertyNames.json") 8 | } 9 | -------------------------------------------------------------------------------- /tests/ref_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import "testing" 4 | 5 | // TestRefForTestSuite executes the ref validation tests for Schema Test Suite. 6 | func TestRefForTestSuite(t *testing.T) { 7 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/ref.json") 8 | } 9 | 10 | // TestRefRemoteForTestSuite executes the refRemote validation tests for Schema Test Suite. 11 | func TestRefRemoteForTestSuite(t *testing.T) { 12 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/refRemote.json") 13 | } 14 | 15 | // TestInfiniteLoopDetectionForTestSuite executes the infinite loop detection validation tests for Schema Test Suite. 16 | func TestInfiniteLoopDetectionForTestSuite(t *testing.T) { 17 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/infinite-loop-detection.json") 18 | } 19 | -------------------------------------------------------------------------------- /tests/required_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import "testing" 4 | 5 | // TestRequiredForTestSuite executes the required validation tests for Schema Test Suite. 6 | func TestRequiredForTestSuite(t *testing.T) { 7 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/required.json") 8 | } 9 | -------------------------------------------------------------------------------- /tests/unevaluatedItems_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | // TestUnevaluatedItemsForTestSuite executes the unevaluatedItems validation tests for Schema Test Suite. 8 | func TestUnevaluatedItemsForTestSuite(t *testing.T) { 9 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json") 10 | } 11 | -------------------------------------------------------------------------------- /tests/unevaluatedProperties_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import "testing" 4 | 5 | // TestUnevaluatedPropertiesForTestSuite executes the unevaluatedProperties validation tests for Schema Test Suite. 6 | func TestUnevaluatedPropertiesForTestSuite(t *testing.T) { 7 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedProperties.json") 8 | } 9 | -------------------------------------------------------------------------------- /tests/uniqueItems_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | // TestUniqueItemsForTestSuite executes the uniqueItems validation tests for Schema Test Suite. 8 | func TestUniqueItemsForTestSuite(t *testing.T) { 9 | testJSONSchemaTestSuiteWithFilePath(t, "../testdata/JSON-Schema-Test-Suite/tests/draft2020-12/uniqueItems.json") 10 | } 11 | --------------------------------------------------------------------------------