{"id":13452232,"url":"https://github.com/worldturner/medeia-validator","last_synced_at":"2026-01-11T16:56:31.936Z","repository":{"id":37270822,"uuid":"171952948","full_name":"worldturner/medeia-validator","owner":"worldturner","description":"Medeia JSON-Schema Validator","archived":false,"fork":false,"pushed_at":"2022-06-20T22:41:17.000Z","size":393,"stargazers_count":57,"open_issues_count":23,"forks_count":11,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-01-25T08:13:43.952Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/worldturner.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-21T22:08:52.000Z","updated_at":"2023-08-22T11:56:03.000Z","dependencies_parsed_at":"2022-09-10T21:51:30.070Z","dependency_job_id":null,"html_url":"https://github.com/worldturner/medeia-validator","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/worldturner%2Fmedeia-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/worldturner%2Fmedeia-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/worldturner%2Fmedeia-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/worldturner%2Fmedeia-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/worldturner","download_url":"https://codeload.github.com/worldturner/medeia-validator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245159191,"owners_count":20570341,"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":[],"created_at":"2024-07-31T07:01:17.726Z","updated_at":"2026-01-11T16:56:31.917Z","avatar_url":"https://github.com/worldturner.png","language":"Kotlin","funding_links":[],"categories":["JSON Schema Validators","Kotlin"],"sub_categories":[],"readme":"Medeia Validator\n================\n\nMedeia validator is a streaming validator for json data using schema documents specified in \nthe [Json Schema format](https://json-schema.org/specification.html).\n\nLicense\n-------\nThis software is licensed under the Apache License, Version 2.0.\n\nSoftware is copyright \u0026copy; 2018-2019 by the authors.\n\nMaven dependency\n----------------\n\nFor the Jackson support\n\n    \u003cdependency\u003e\n        \u003cgroupId\u003ecom.worldturner.medeia\u003c/groupId\u003e\n        \u003cartifactId\u003emedeia-validator-jackson\u003c/artifactId\u003e\n        \u003cversion\u003e1.1.0\u003c/version\u003e\n    \u003c/dependency\u003e\n    \nFor the Gson support\n\n    \u003cdependency\u003e\n        \u003cgroupId\u003ecom.worldturner.medeia\u003c/groupId\u003e\n        \u003cartifactId\u003emedeia-validator-gson\u003c/artifactId\u003e\n        \u003cversion\u003e1.1.0\u003c/version\u003e\n    \u003c/dependency\u003e\n    \nJson Schema version support\n---------------------------\n\nMedeia supports the following versions of the [Json Schema specification](https://json-schema.org/):\n\n* Draft-04\n* Draft-06\n* Draft-07\n\nMedeia can validate Json data and can convert schema documents from draft-04 to draft-07.\n\nParser library support\n----------------------\n\nMedeia works with the following Json parser libraries:\n\n* [FasterXML Jackson](https://github.com/FasterXML/jackson) (only jackson-core is needed)\n* [Google Gson](https://github.com/google/gson)\n\nUse cases\n---------\n\nMedeia validator was written with the following use-cases in mind:\n\n1. Validate Json data as it is being read into a tree or into an object model using an object mapper\n2. Validate Json data as it is being serialized from a tree or object model\n3. Validate Json data in a message router or validator component on the network, which has no need to\n  load the Json data into a tree or object model\n  \nStreaming validation\n--------------------\n\nMedeia does not build a full internal tree of the Json data while it is validating; it only temporarily stores \nas much as is needed for processing the current validation rules.\n\nThis ensures a lower memory footprint and tha ability to parse very large documents, even documents that do\nnot fit into memory. This is beneficial for the use cases for which Medeia was written.\n\nAlthough memory versus speed (or CPU utilization) is often a trade-off, Medeia validator is very fast for\nits use-cases. Validation approaches that requires an in-memory model of the data first spent time building that model,\nand also spend extra time garbage collecting that model afterwards.\n\n### Caveats\n\n* Properties in objects do not have to be in any particular order; two objects are equal in Json even if the\n  properties are in different orders. As a result, many validation rules require the validator to wait until \n  all properties have been seen; in the meantime, property names have to be stored in memory.\n* The uniqueItems validator would seem to require in-memory trees. Medeia-validator does not in fact do that\n  by default; instead, Medeia builds cryptographic hashes for the list objects it sees so that\n  it does not have to store the entire contents of the object in memory. This is a CPU versus memory trade-off.\n* The dependencies and the if/then/else validators have validators that are only evaluated if another\n  validator matches. Medeia always evaluates the dependent validators (and the then/else) clauses, even when their\n  results need to be discarded because of the result of the condition. The alternative would require an in-memory \n  tree. This is a CPU versus memory trade-off.\n\n\nKotlin, Java and JVM languages support\n--------------------------------------\n\nSupports calling from Kotlin and Java, and other languages that support the JVM that can call Java APIs.\n\nAll accessible types are in the `com.worldturner.medeia.api.*` packages; classes in other packages are not guaranteed\nto remain stable across versions, they can change at any time witout notice.\n\nVersioning\n----------\n\nThe versioning scheme of this library is [Semantic Versioning](https://semver.org/) but only the public API.\nPublic API classes have package names that starts with `com.worldturner.medeia.api`.\nThe APIs of types in other packages can change at any time even between minor versions.\n\nSource Json format support\n--------------------------\n* Ordinary JSON\n* [Multi-line JSON](http://jsonlines.org/) for Jackson (not tested for Gson)\n\nHow to use\n----------\n\nExamples are provided in this git repository in the projects:\n\n* medeia-validator-examples-java\n* medeia-validator-examples-kotlin\n\nIt includes examples on how to read and write using Jackson and Gson while also loading or retrieving\nfrom Java/Kotlin objects.\n\nThe CustomFormatExample also doubles as a way to show how streaming validation can be done \nwithout loading the data into memory at all.\n\nThe allows medeia-validator to validate many Gigabytes of data. \n\n\nThe `MedeiaJacksonApi` and `MedeiaGsonApi` classes have various methods to load schemas and to create validating\nparsers/generators (or readers/writers in Gson parlance)\n\nThe interface `SchemaSource` has several implementations to load schemas from InputStreams, Readers, Paths, or memory.\n\nThe version of a schema is automatically detected, but if the schema file doesn't specify it using a `$schema` field,\nthe version can be provided through the SchemaSource.\n\nMixing different versions of schemas (draft4, 6 and 7) is allowed and schemas can refer to remote schemas in \ndifferent versions than their own.\n\nOptions are passed using a `ValidationOptions` object.\n\nCare has been taken that all methods in the API can be invoked from Java. The `JsonSchemaValidationOptions` has \n`with*` methods to allow option setting from Java.\n\nCloning and building medeia-validator\n-------------------------------------\n\nMedeia-validator pulls in the JSON-Schema-Test-Suite as a git submodule.\nWhen you have already cloned medeia-validator, perform this command:\n\n```bash\ngit submodule update --init --recursive\n```\n\nOr perform the initial clone with submodules:\n\n```bash\ngit clone --recurse-submodules git@github.com:worldturner/medeia-validator.git\n```\n\nBuilding is done with maven using `mvn clean install` and also executes git to retrieve the\nsubmodule.\n\nTest Suite Support\n------------------\n\nMedeia validator passes all 424 'required' tests of the JSON-Schema-Test-Suite testsuite.\nIt passes 138 out of the 143 optional tests. The 5 failing optional tests concern \"format\" keyword\nvalidation where the following formats that are not yet (fully) supported:\n\n\u003e uri-template, iri, iri-reference, email, idn-email, regex\n\nFormat keyword validation is optional (and can be turned off as mandated by the specification)\n\nThe following formats are supported and pass the 'optional' testsuite:\n\n\u003e json-pointer, relative-json-pointer, date, time, date-time, ipv4, ipv6, hostname, idn-hostname, uri, uri-reference\n\nPerformance\n-----------\n\nPerformance tests include the time to parse the data from a file and to validate it.\nThey do not include the time to load/build the validation schema itself.\n\nPerformed on mid-2015 MacBookPro, median values of at least 30 runs, see [medeia-validator-performance](https://github.com/worldturner/medeia-validator-performance).\n\n##### Draft04\n\nValidating the JSON schema draft 4 meta schema against itself using:\n\n* Medeia Validator Jackson \u0026 Gson 1.0.0\n* Everit Json Schema 1.11.1\n* Json schema validator 2.2.10\n* Justify not used, doesn't support draft 4\n\nResults in milliseconds per validation (fastest first):\n\n| MedeiaJackson | MedeiaGson | Everit | JsonValidator |\n|---------------|------------|--------|---------------|\n|    0.1062     |   0.1300   | 0.1982 |     0.8526    |\n\n![Performance Chart draft-04](documentation/img/performance-draft04.png)\n\n##### Draft07\n\nValidating the JSON schema version 4 meta schema against itself using:\n\n* Medeia Validator Jackson \u0026 Gson 1.0.0\n* Everit Json Schema 1.11.1\n* Json schema validator not used, doesn't support draft 7\n* Justify 0.13.0\n\nResults in milliseconds per validation (fastest first):\n\n| MedeiaJackson | MedeiaGson | Justify | Everit |\n|---------------|------------|---------|--------|\n|    0.0723     |   0.0742   |  0.0850 | 0.4836 |\n\t\t\t\n![Performance Chart draft-07](documentation/img/performance-draft07.png)\n\nLarge file validation\n---------------------\n\nGenerated lists of draft-04 and draft-07 schemas, validating against a list of the metaschema,\nhave been tested up to 10Gb files. Time taken scales linearly - the time taken is the number of concatenations\nof the schema times the time taken per schema instance above (0.10-0.13 milliseconds)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fworldturner%2Fmedeia-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fworldturner%2Fmedeia-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fworldturner%2Fmedeia-validator/lists"}