{"id":15493466,"url":"https://github.com/optimumcode/json-schema-validator","last_synced_at":"2025-04-16T01:16:36.348Z","repository":{"id":180956611,"uuid":"665024908","full_name":"OptimumCode/json-schema-validator","owner":"OptimumCode","description":"The JSON schema validation library that works with https://github.com/Kotlin/kotlinx.serialization","archived":false,"fork":false,"pushed_at":"2025-04-10T15:23:57.000Z","size":2452,"stargazers_count":46,"open_issues_count":8,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-16T01:16:28.545Z","etag":null,"topics":["json-schema-validator","kotlin","kotlin-library","multiplatform"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OptimumCode.png","metadata":{"files":{"readme":"README.md","changelog":"changelog_config.json","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-11T09:16:42.000Z","updated_at":"2025-04-15T06:24:48.000Z","dependencies_parsed_at":"2024-01-01T14:45:12.978Z","dependency_job_id":"b3e1bce7-a3aa-4532-980a-97277918c169","html_url":"https://github.com/OptimumCode/json-schema-validator","commit_stats":{"total_commits":343,"total_committers":8,"mean_commits":42.875,"dds":"0.49562682215743437","last_synced_commit":"20ad6e2e642ad7c98554c1788392bbbfc423c068"},"previous_names":["optimumcode/json-schema-validator"],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OptimumCode%2Fjson-schema-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OptimumCode%2Fjson-schema-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OptimumCode%2Fjson-schema-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OptimumCode%2Fjson-schema-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OptimumCode","download_url":"https://codeload.github.com/OptimumCode/json-schema-validator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249178224,"owners_count":21225350,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json-schema-validator","kotlin","kotlin-library","multiplatform"],"created_at":"2024-10-02T08:06:51.270Z","updated_at":"2025-04-16T01:16:36.338Z","avatar_url":"https://github.com/OptimumCode.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# json-schema-validator\n\n[![Licence](https://img.shields.io/github/license/OptimumCode/json-schema-validator)](https://opensource.org/license/mit/)\n[![Supported-drafts](https://img.shields.io/endpoint?url=https://bowtie-json-schema.github.io/bowtie/badges/kotlin-kmp-json-schema-validator/supported_versions.json)](https://json-schema.org/specification)\n![Codecov](https://img.shields.io/codecov/c/github/optimumcode/json-schema-validator)\n[![FOSSA Status](https://app.fossa.com/api/projects/custom%2B46664%2Fgithub.com%2FOptimumCode%2Fjson-schema-validator.svg?type=shield\u0026issueType=license)](https://app.fossa.com/projects/custom%2B46664%2Fgithub.com%2FOptimumCode%2Fjson-schema-validator?ref=badge_shield\u0026issueType=license)\n\n![Maven Central Version](https://img.shields.io/maven-central/v/io.github.optimumcode/json-schema-validator)\n![Sonatype Nexus (Releases)](https://img.shields.io/nexus/r/io.github.optimumcode/json-schema-validator?server=https%3A%2F%2Fs01.oss.sonatype.org)\n![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/io.github.optimumcode/json-schema-validator?server=https%3A%2F%2Fs01.oss.sonatype.org)\n\n\nThis multiplatform library is an implementation of JSON schema that can validate\n[JsonElement](https://github.com/Kotlin/kotlinx.serialization/blob/master/formats/json/commonMain/src/kotlinx/serialization/json/JsonElement.kt)\nfrom [kotlinx.serialization-json](https://github.com/Kotlin/kotlinx.serialization/tree/master/formats/json) library.\n\n[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/OptimumCode/json-schema-validator)\n[![Open in DevPod!](https://devpod.sh/assets/open-in-devpod.svg)](https://devpod.sh/open#https://github.com/OptimumCode/json-schema-validator)\n\n## Usage\n\n### Supported targets\n\n| Target            |\n|-------------------|\n| jvm               |\n| js                |\n| wasmJs            |\n| macosX64          |\n| macosArm64        |\n| iosArm64          |\n| iosSimulatorArm64 |\n| linuxX64          |\n| linuxArm64        |\n| mingwX64          |\n\n### Dependencies\n\n#### Releases\n\nIn order to use releases add Maven Central repository to the list of repositories.\n\n##### Gradle\n\n###### Kotlin\n\n```kotlin\nrepositories {\n  mavenCentral()\n}\n\nimplementation(\"io.github.optimumcode:json-schema-validator:0.5.1\")\n```\n\n###### Groovy\n\n```groovy\nrepositories {\n  mavenCentral()\n}\n\nimplementation 'io.github.optimumcode:json-schema-validator:0.5.1'\n\n// or with BOM\n\nimplementation(platform(\"io.github.optimumcode:json-schema-validator-bom:0.5.1\"))\nimplementation(\"io.github.optimumcode:json-schema-validator\")\n```\n\n_Release are published to Sonatype repository. The synchronization with Maven Central takes time._\n_If you want to use the release right after the publication you should add Sonatype Release repository to your build script._\n\n###### Kotlin\n\n```kotlin\nrepositories {\n  maven(url = \"https://s01.oss.sonatype.org/content/repositories/releases/\")\n}\n```\n\n###### Groovy\n\n```groovy\nrepositories {\n  maven { url 'https://s01.oss.sonatype.org/content/repositories/releases/' }\n}\n```\n\n##### Maven\n\nYou can also use `json-schema-validator` as a dependency in your maven project.\nBut Maven cannot use Gradle's metadata so you need to depend on a JVM-specific artifact in your project:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003eio.github.optimumcode\u003c/groupId\u003e\n  \u003cartifactId\u003ejson-schema-validator-jvm\u003c/artifactId\u003e\n  \u003cversion\u003e0.5.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nAnd you can also add a sonatype repository to your POM file\n\n```xml\n\u003crepositories\u003e\n  \u003crepository\u003e\n    \u003cid\u003esonatype-release\u003c/id\u003e\n    \u003cname\u003esonatype-release\u003c/name\u003e\n    \u003curl\u003ehttps://s01.oss.sonatype.org/content/repositories/releases/\u003c/url\u003e\n    \u003csnapshots\u003e\n      \u003cenabled\u003efalse\u003c/enabled\u003e\n    \u003c/snapshots\u003e\n    \u003creleases\u003e\n      \u003cenabled\u003etrue\u003c/enabled\u003e\n    \u003c/releases\u003e\n  \u003c/repository\u003e\n\u003c/repositories\u003e\n```\n\n#### Snapshots\n\n_If you want to use SNAPSHOT version you should add Sonatype Snapshot repository to your build script._\n\n##### Gradle\n\n###### Kotlin\n\n```kotlin\nrepositories {\n  maven(url = \"https://s01.oss.sonatype.org/content/repositories/snapshots\")\n}\n\nimplementation(\"io.github.optimumcode:json-schema-validator:0.5.2-SNAPSHOT\")\n\n// or with BOM\n\nimplementation(platform(\"io.github.optimumcode:json-schema-validator-bom:0.5.2-SNAPSHOT\"))\nimplementation(\"io.github.optimumcode:json-schema-validator\")\n```\n\n###### Groovy\n\n```groovy\nrepositories {\n  maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots' }\n}\n\nimplementation 'io.github.optimumcode:json-schema-validator:0.5.2-SNAPSHOT'\n```\n\n##### Maven\n\nFor the Maven you need to add a snapshot repository to your POM file\n\n```xml\n\u003crepositories\u003e\n  \u003crepository\u003e\n    \u003cid\u003esonatype\u003c/id\u003e\n    \u003cname\u003esonatype-snapshot\u003c/name\u003e\n    \u003curl\u003ehttps://s01.oss.sonatype.org/content/repositories/snapshots/\u003c/url\u003e\n    \u003csnapshots\u003e\n      \u003cenabled\u003etrue\u003c/enabled\u003e\n    \u003c/snapshots\u003e\n    \u003creleases\u003e\n      \u003cenabled\u003efalse\u003c/enabled\u003e\n    \u003c/releases\u003e\n  \u003c/repository\u003e\n\u003c/repositories\u003e\n```\n\nAnd then you can add a dependency to a SNAPSHOT version\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003eio.github.optimumcode\u003c/groupId\u003e\n  \u003cartifactId\u003ejson-schema-validator-jvm\u003c/artifactId\u003e\n  \u003cversion\u003e0.5.2-SNAPSHOT\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### Example\n\nIf you have just one JSON schema or many independent schemes\nyou can create it using factory methods defined on `JsonSchema` class.\n\n```kotlin\nimport io.github.optimumcode.json.schema.JsonSchema\nimport io.github.optimumcode.json.schema.ValidationError\nimport kotlinx.serialization.json.JsonElement\n\nval key = \"\\$\" // to use $ in multiline string\nval schema = JsonSchema.fromDefinition(\n  \"\"\"\n  {\n    \"${key}schema\": \"http://json-schema.org/draft-07/schema#\",\n    \"definitions\": {\n      \"positiveInteger\": {\n        \"type\": \"integer\",\n        \"minimum\": 0\n      }\n    },\n    \"properties\": {\n      \"size\": { \"${key}ref\": \"#/definitions/positiveInteger\" }\n    }\n  }\n  \"\"\".trimIndent(),\n)\nval errors = mutableListOf\u003cValidationError\u003e()\nval elementToValidate: JsonElement = loadJsonToValidate()\n\nval valid = schema.validate(elementToValidate, errors::add)\n```\n\nYou can also use predefined `ValidationOutput`s to collect the results.\nOutput formats are defined in [draft 2020-12](https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-01#section-12.4).\nThe most performance can be achieved by using either `flag` or `basic` collectors.\nThe `detailed` and `verbose` provide more structured information but this adds additional cost to the validation process\n(because they collect hierarchical output).\n\n```kotlin\nimport io.github.optimumcode.json.schema.JsonSchema\nimport io.github.optimumcode.json.schema.OutputCollector\nimport io.github.optimumcode.json.schema.ValidationOutput.Flag\nimport io.github.optimumcode.json.schema.ValidationOutput.Basic\nimport io.github.optimumcode.json.schema.ValidationOutput.OutputUnit\n\nval flag: Flag = schema.validate(elementToValidate, OutputCollector.flag())\nval basic: Basic = schema.validate(elementToValidate, OutputCollector.basic())\nval detailed: OutputUnit = schema.validate(elementToValidate, OutputCollector.detailed())\nval verbose: OutputUnit = schema.validate(elementToValidate, OutputCollector.verbose())\n```\n\nIf you need to use more than one schema, and they have references to other schemas you should use `JsonSchemaLoader` class.\n\n```kotlin\nimport io.github.optimumcode.json.schema.JsonSchemaLoader\nimport io.github.optimumcode.json.schema.JsonSchema\nimport io.github.optimumcode.json.schema.ValidationError\nimport kotlinx.serialization.json.JsonElement\n\nval schema: JsonSchema = JsonSchemaLoader.create()\n  .register(\n    \"\"\"\n    {\n      \"${KEY}id\": \"https://test.com\",\n      \"properties\": {\n        \"name\": {\n          \"type\": \"string\"\n        }\n      }\n    }\n    \"\"\".trimIndent(),\n  ).fromDefinition(\n    \"\"\"\n    {\n      \"properties\": {\n        \"anotherName\": {\n          \"${KEY}ref\": \"https://test.com#/properties/name\"\n        }\n      }\n    }\n    \"\"\".trimIndent(),\n  )\n\nval errors = mutableListOf\u003cValidationError\u003e()\nval elementToValidate: JsonElement = loadJsonToValidate()\n\nval valid = schema.validate(elementToValidate, errors::add)\n```\n\n## Supported JSON schema drafts:\n\n- [Draft 7](https://json-schema.org/specification-links.html#draft-7)\n  \u003cdetails\u003e\n  \u003csummary\u003eSupported keywords\u003c/summary\u003e\n\n  - Core\n\n  | Keyword     | Status                                                                                              |\n  |:------------|:----------------------------------------------------------------------------------------------------|\n  | $id         | Supported. $id in sub-schemas are collected as well and can be used in $ref                         |\n  | $schema     | Supported. Validates if schema is one of the supported schemas. The last supported is used if empty |\n  | $ref        | Supported                                                                                           |\n  | definitions | Supported. Definitions are loaded and can be referenced                                             |\n\n  - Assertions\n\n  | Category      | Assertion            | Status                                                                                                                                          |\n  |:--------------|:---------------------|:------------------------------------------------------------------------------------------------------------------------------------------------|\n  | General       | type                 | Supported all type [defined in the specification](https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-6.1.1) |\n  |               | enum                 | Supported                                                                                                                                       |\n  |               | const                | Supported                                                                                                                                       |\n  | Numbers       | multipleOf           | Supported                                                                                                                                       |\n  |               | maximum              | Supported                                                                                                                                       |\n  |               | exclusiveMaximum     | Supported                                                                                                                                       |\n  |               | minimum              | Supported                                                                                                                                       |\n  |               | exclusiveMinimum     | Supported                                                                                                                                       |\n  | Strings       | maxLength            | Supported                                                                                                                                       |\n  |               | minLength            | Supported                                                                                                                                       |\n  |               | pattern              | Supported (kotlin.text.Regex is used)                                                                                                           |\n  | Arrays        | items                | Supported                                                                                                                                       |\n  |               | additionalItems      | Supported                                                                                                                                       |\n  |               | maxItems             | Supported                                                                                                                                       |\n  |               | uniqueItems          | Supported                                                                                                                                       |\n  |               | contains             | Supported                                                                                                                                       |\n  | Objects       | maxProperties        | Supported                                                                                                                                       |\n  |               | minProperties        | Supported                                                                                                                                       |\n  |               | required             | Supported                                                                                                                                       |\n  |               | properties           | Supported                                                                                                                                       |\n  |               | patternProperties    | Supported (kotlin.text.Regex is used)                                                                                                           |\n  |               | additionalProperties | Supported                                                                                                                                       |\n  |               | dependencies         | Supported                                                                                                                                       |\n  |               | propertyNames        | Supported                                                                                                                                       |\n  | Conditions    | if/then/else         | Supported                                                                                                                                       |\n  | Boolean logic | allOf                | Supported                                                                                                                                       |\n  |               | anyOf                | Supported (all validation will be executed even if the element matches the first one)                                                           |\n  |               | oneOf                | Supported                                                                                                                                       |\n  |               | not                  | Supported                                                                                                                                       |\n  \u003c/details\u003e\n- [Draft 2019-09](https://json-schema.org/specification-links#draft-2019-09-(formerly-known-as-draft-8))\n  \u003cdetails\u003e\n  \u003csummary\u003eSupported keywords\u003c/summary\u003e\n\n  - Core\n\n  | Keyword           | Status                                                                                              |\n  |:------------------|:----------------------------------------------------------------------------------------------------|\n  | $id               | Supported. $id in sub-schemas are collected as well and can be used in $ref                         |\n  | $schema           | Supported. Validates if schema is one of the supported schemas. The last supported is used if empty |\n  | $ref              | Supported                                                                                           |\n  | $recursiveRef     | Supported                                                                                           |\n  | $defs/definitions | Supported. Definitions are loaded and can be referenced                                             |\n  | $vocabulary       | Supported. You can disable and enable vocabularies through custom meta-schemes                      |\n\n  - Assertions\n\n  | Category      | Assertion             | Status                                                                                                                                          |\n  |:--------------|:----------------------|:------------------------------------------------------------------------------------------------------------------------------------------------|\n  | General       | type                  | Supported all type [defined in the specification](https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-6.1.1) |\n  |               | enum                  | Supported                                                                                                                                       |\n  |               | const                 | Supported                                                                                                                                       |\n  | Numbers       | multipleOf            | Supported                                                                                                                                       |\n  |               | maximum               | Supported                                                                                                                                       |\n  |               | exclusiveMaximum      | Supported                                                                                                                                       |\n  |               | minimum               | Supported                                                                                                                                       |\n  |               | exclusiveMinimum      | Supported                                                                                                                                       |\n  | Strings       | maxLength             | Supported                                                                                                                                       |\n  |               | minLength             | Supported                                                                                                                                       |\n  |               | pattern               | Supported (kotlin.text.Regex is used)                                                                                                           |\n  | Arrays        | items                 | Supported                                                                                                                                       |\n  |               | additionalItems       | Supported                                                                                                                                       |\n  |               | unevaluatedItems      | Supported                                                                                                                                       |\n  |               | maxItems              | Supported                                                                                                                                       |\n  |               | uniqueItems           | Supported                                                                                                                                       |\n  |               | contains              | Supported                                                                                                                                       |\n  |               | minContains           | Supported (does not affect the work of contains assertion anyhow even if minContains=0)                                                         |\n  |               | maxContains           | Supported                                                                                                                                       |\n  | Objects       | maxProperties         | Supported                                                                                                                                       |\n  |               | minProperties         | Supported                                                                                                                                       |\n  |               | required              | Supported                                                                                                                                       |\n  |               | properties            | Supported                                                                                                                                       |\n  |               | patternProperties     | Supported (kotlin.text.Regex is used)                                                                                                           |\n  |               | additionalProperties  | Supported                                                                                                                                       |\n  |               | unevaluatedProperties | Supported                                                                                                                                       |\n  |               | dependentRequired     | Supported                                                                                                                                       |\n  |               | dependentSchemas      | Supported                                                                                                                                       |\n  |               | propertyNames         | Supported                                                                                                                                       |\n  | Conditions    | if/then/else          | Supported                                                                                                                                       |\n  | Boolean logic | allOf                 | Supported                                                                                                                                       |\n  |               | anyOf                 | Supported (all validation will be executed even if the element matches the first one)                                                           |\n  |               | oneOf                 | Supported                                                                                                                                       |\n  |               | not                   | Supported                                                                                                                                       |\n  \u003c/details\u003e\n- [Draft 2020-12](https://json-schema.org/specification-links#2020-12)\n  \u003cdetails\u003e\n  \u003csummary\u003eSupported keywords\u003c/summary\u003e\n\n  - Core\n\n  | Keyword                    | Status                                                                                              |\n  |:---------------------------|:----------------------------------------------------------------------------------------------------|\n  | $id                        | Supported. $id in sub-schemas are collected as well and can be used in $ref                         |\n  | $schema                    | Supported. Validates if schema is one of the supported schemas. The last supported is used if empty |\n  | $ref                       | Supported                                                                                           |\n  | $dynamicRef/$dynamicAnchor | Supported                                                                                           |\n  | $defs/definitions          | Supported. Definitions are loaded and can be referenced                                             |\n  | $vocabulary                | Supported. You can disable and enable vocabularies through custom meta-schemes                      |\n\n  - Assertions\n\n  | Category      | Assertion             | Status                                                                                                                                          |\n  |:--------------|:----------------------|:------------------------------------------------------------------------------------------------------------------------------------------------|\n  | General       | type                  | Supported all type [defined in the specification](https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-6.1.1) |\n  |               | enum                  | Supported                                                                                                                                       |\n  |               | const                 | Supported                                                                                                                                       |\n  | Numbers       | multipleOf            | Supported                                                                                                                                       |\n  |               | maximum               | Supported                                                                                                                                       |\n  |               | exclusiveMaximum      | Supported                                                                                                                                       |\n  |               | minimum               | Supported                                                                                                                                       |\n  |               | exclusiveMinimum      | Supported                                                                                                                                       |\n  | Strings       | maxLength             | Supported                                                                                                                                       |\n  |               | minLength             | Supported                                                                                                                                       |\n  |               | pattern               | Supported (kotlin.text.Regex is used)                                                                                                           |\n  | Arrays        | prefixItems           | Supported                                                                                                                                       |\n  |               | items                 | Supported                                                                                                                                       |\n  |               | unevaluatedItems      | Supported                                                                                                                                       |\n  |               | maxItems              | Supported                                                                                                                                       |\n  |               | uniqueItems           | Supported                                                                                                                                       |\n  |               | contains              | Supported                                                                                                                                       |\n  |               | minContains           | Supported                                                                                                                                       |\n  |               | maxContains           | Supported                                                                                                                                       |\n  | Objects       | maxProperties         | Supported                                                                                                                                       |\n  |               | minProperties         | Supported                                                                                                                                       |\n  |               | required              | Supported                                                                                                                                       |\n  |               | properties            | Supported                                                                                                                                       |\n  |               | patternProperties     | Supported (kotlin.text.Regex is used)                                                                                                           |\n  |               | additionalProperties  | Supported                                                                                                                                       |\n  |               | unevaluatedProperties | Supported                                                                                                                                       |\n  |               | dependentRequired     | Supported                                                                                                                                       |\n  |               | dependentSchemas      | Supported                                                                                                                                       |\n  |               | propertyNames         | Supported                                                                                                                                       |\n  | Conditions    | if/then/else          | Supported                                                                                                                                       |\n  | Boolean logic | allOf                 | Supported                                                                                                                                       |\n  |               | anyOf                 | Supported (all validation will be executed even if the element matches the first one)                                                           |\n  |               | oneOf                 | Supported                                                                                                                                       |\n  |               | not                   | Supported                                                                                                                                       |\n  \u003c/details\u003e\n\n## Thread safety\n\nAll public API is thread-safe unless stated otherwise.\nPlease, read the documentation for each class/interface carefully before using an instance from different threads.\n\n## Format assertion\n\nThe library supports `format` assertion.\nAll formats from [JSON schema draft 2020-12](https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-7.3) are supported.\n\nAccording to JSON schema specification the `format` keyword produces **assertion by default** for all drafts **before draft 2019-09**.\nStarting **from draft 2019-09** the `format` keyword produces only **annotation by default**.\n\nYou can change the default behaviour by specifying the corresponding option in `JsonSchemaLoader`.\n```kotlin\nimport io.github.optimumcode.json.schema.FormatBehavior.ANNOTATION_AND_ASSERTION\nimport io.github.optimumcode.json.schema.JsonSchemaLoader\nimport io.github.optimumcode.json.schema.SchemaOption\n\nval schema = JsonSchemaLoader.create()\n       // option to change the default behavior\n      .withSchemaOption(SchemaOption.FORMAT_BEHAVIOR_OPTION, ANNOTATION_AND_ASSERTION)\n      // or\n      .withSchemaOption(SchemaOption.FORMAT_BEHAVIOR_OPTION, ANNOTATION_ONLY)\n      .fromDefinition(schemaDefinition)\n```\n\nAlternatively, for drafts starting from the draft 2019-09 you can either use a custom meta-schema with format-assertion vocabulary enabled\nand use this meta-schema in `$schema` property or define `$vocabulary` block with enabled format assertion in your schema.\n\n**_Implementation details:_**\n\n+ **regex** - to implement regex format Kotlin `Regex` class is used.\n  Because of that, result might vary depending on the platform where validation is executed\n  ([KT-49557](https://youtrack.jetbrains.com/issue/KT-49557)).\n  Please, be aware of it when using this library.\u003c/p\u003e\n  If you know a KMM library that provides support for ECMA-262 Regex format\n  I would appreciate it if you could find some time to create [an issue](https://github.com/OptimumCode/json-schema-validator/issues/new/choose) with information about that library.\n\nThere is also an API to implement the user's defined format validation.\nThe [FormatValidator](src/commonMain/kotlin/io/github/optimumcode/json/schema/ValidationError.kt) interface can be user for that.\nThe custom format validators can be register in [JsonSchemaLoader](src/commonMain/kotlin/io/github/optimumcode/json/schema/JsonSchemaLoader.kt).\n\n_**Please note, that the format validation API is marked as experimental and will require `OptIn` declaration in your code.**_\n\n## Custom assertions\n\nYou can implement custom assertions and use them. Read more [here](docs/custom_assertions.md).\n\n## Compliance to JSON schema test suites\n\nThis library uses official [JSON schema test suites](https://github.com/json-schema-org/JSON-Schema-Test-Suite)\nas a part of the CI to make sure the validation meet the expected behavior.\nNot everything is supported right now but the missing functionality might be added in the future.\nThe tests are located [here](test-suites).\n\n\n**NOTE:** _Python 3.* is required to run test-suites._\n_It is used to generate list of remote schemas using [this script](test-suites/schema-test-suite/bin/jsonschema_suite)_\n\nThis library is also integrated into [bowtie](https://github.com/bowtie-json-schema/bowtie)\nand runs against the official test suite along with other libraries.\nYou can find the report [here](https://bowtie.report/).\n\n[![draft-04](https://img.shields.io/endpoint?url=https://bowtie-json-schema.github.io/bowtie/badges/kotlin-kmp-json-schema-validator/compliance/draft4.json)](https://bowtie.report/#/dialects/draft4?language=kotlin)\n[![draft-06](https://img.shields.io/endpoint?url=https://bowtie-json-schema.github.io/bowtie/badges/kotlin-kmp-json-schema-validator/compliance/draft6.json)](https://bowtie.report/#/dialects/draft6?language=kotlin)\n[![draft-07](https://img.shields.io/endpoint?url=https://bowtie-json-schema.github.io/bowtie/badges/kotlin-kmp-json-schema-validator/compliance/draft7.json)](https://bowtie.report/#/dialects/draft7?language=kotlin)\n[![draft/2019-09](https://img.shields.io/endpoint?url=https://bowtie-json-schema.github.io/bowtie/badges/kotlin-kmp-json-schema-validator/compliance/draft2019-09.json)](https://bowtie.report/#/dialects/draft2019-09?language=kotlin)\n[![draft/2020-12](https://img.shields.io/endpoint?url=https://bowtie-json-schema.github.io/bowtie/badges/kotlin-kmp-json-schema-validator/compliance/draft2020-12.json)](https://bowtie.report/#/dialects/draft2020-12?language=kotlin)\n\n## Benchmarking\n\nThere is a benchmark project that compares this library with some other ones:\n\n+ [OpenAPI schema validator](https://github.com/openapi-processor/openapi-parser/tree/master/json-schema-validator)\n+ [Networknt Schema Validator](https://github.com/networknt/json-schema-validator)\n\nThe benchmark is scheduled to run every night on Monday.\nYou can see the results in the latest workflow execution.\n\nAlso, benchmark results are available [here](https://optimumcode.github.io/json-schema-validator/dev/bench/) in nice charts.\nMany thanks to maintainers of [github-action-benchmark](https://github.com/benchmark-action/github-action-benchmark) repo.\n\n## Developer notes\n\n### Build process\n\nThe update to Kotlin 1.9.22 came with an issue for JS incremental compilation.\nIn case you see an error about main function that already bind please execute `clean` task.\n\nWhen you build project for **linux** target you might get an error about missing native library.\nThis is because `com.doist.x:normalize` requires this library to perform string normalization.\nThis is needed to support `idn-hostname` format. Install this library with the following command:\n\n```bash\nsudo apt-get install -y libunistring-dev\n```\n\n### Devcontainer\n\nDevcontainers is a cool feature. However, by default in Codespaces and DevPod you will use [VS Code](https://code.visualstudio.com/).\nThis is a good IDE but not for Kotlin, unfortunately.\nThe extension that is available for VS Code to support Kotlin works quite slow (when workspace is just started)\nand sometimes does not work correctly with multiplatform definitions.\nBecause of that I higly recoment using JetBrains Gateway\n(but it looks like the GitHub Codespace provider is not currently compatible with latest Gateway version).\nHowever, there is a way to connect to Codespace and work with project using JetBrains IDE.\nPlease, read details [here](docs/codespaces_for_jetbrains.md).\n\n## Future plans\n\n- [x] Add `$schema` property validation (if not set the latest supported will be used)\n- [x] Add proper `$id` support (for nested schemas and for referencing)\n- [x] Add support for newer drafts\n  - [x] [Draft 2019-09 (Draft 8)](https://json-schema.org/specification-links.html#draft-2019-09-formerly-known-as-draft-8)\n  - [x] [2020-12](https://json-schema.org/specification-links.html#2020-12)\n- [x] Add support for schemas from external documents\n  - [x] Load schemas from local sources\n  - [ ] Load schemas from remote sources\n- [x] Formalize error output as it is defined in the latest drafts\n\n## License\n\n[![FOSSA Status](https://app.fossa.com/api/projects/custom%2B46664%2Fgithub.com%2FOptimumCode%2Fjson-schema-validator.svg?type=large\u0026issueType=license)](https://app.fossa.com/projects/custom%2B46664%2Fgithub.com%2FOptimumCode%2Fjson-schema-validator?ref=badge_large\u0026issueType=license)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foptimumcode%2Fjson-schema-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foptimumcode%2Fjson-schema-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foptimumcode%2Fjson-schema-validator/lists"}