Releases: OptimumCode/json-schema-validator
Releases · OptimumCode/json-schema-validator
Release 0.0.7
🚀 Features
- Provide ability to register custom assertion (PR: #53)
🐛 Fixes
🤔 No bugs at all?
🧰 CI/CD
- Update actions version to work on node 20 (PR: #52)
- Add Dependabot configuration to the project (PR: #55)
- Migrate to Gradle dependency submission (PR: #61)
Uncategorized
- Add benchmark sub-project (PR: #48)
- Add badges from bowtie report run (PR: #50)
- Pull latest updates from json schema test suite (PR: #51)
- Bump org.jlleitschuh.gradle.ktlint from 12.0.3 to 12.1.0 (PR: #60)
- Bump io.gitlab.arturbosch.detekt from 1.23.4 to 1.23.5 (PR: #58)
- Bump okio from 3.7.0 to 3.8.0 (PR: #59)
- Bump com.networknt:json-schema-validator from 1.3.1 to 1.3.2 (PR: #56)
- Add documentation and example for creating custom assertions (PR: #62)
Also merged but not included in notes
Release 0.0.6
Release 0.0.5
Release 0.0.4
🚀 Features
No new features today 😢
🐛 Fixes
- Correct companion object visibility (PR: #34)
Uncategorized
Also merged but not included in notes
Release 0.0.3
Release 0.0.2
🚀 Features
- Support $schema property to identify schema draft to use (PR: #16)
- The $id should be treated as a URI (PR: #17)
- Make library comply to official JSON schema repository test-suites (PR: #19)
🐛 Fixes
🤔 No bugs at all?
Uncategorized
Also merged but not included in notes
- Fix test suites running for ios target (PR: #21)
Release 0.0.1
This is the first release of the multiplatform JSON-schema-validator library.
🚀 Features
- Support for Draft 7
- All assertion keywords are supported
- Most of the schema keywords are supported
- $id works only for the root schema
- $schema value is not used
- $ref works only for relative references (like #/definitions/negativeInteger)
Usage
Add library to your dependencies
implementation("io.github.optimumcode:json-schema-validator:0.0.1")
Create a schema and validate the JSON element you need
import io.github.optimumcode.json.schema.JsonSchema
import io.github.optimumcode.json.schema.ValidationError
import kotlinx.serialization.json.JsonElement
val key = "\$" // to use $ in multiline string
val schema = JsonSchema.fromDefinition(
"""
{
"${key}schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"positiveInteger": {
"type": "integer",
"minimum": 0
}
},
"properties": {
"size": { "${key}ref": "#/definitions/positiveInteger" }
}
}
""".trimIndent(),
)
val errors = mutableListOf<ValidationError>()
val elementToValidate: JsonElement = loadJsonToValidate()
val valid = schema.validate(elementToValidate, errors::add)
Future
This library is in the early stage of development so more changes and features are on the way.
Some of them you can find in the README and opened issues.
If you have any questions/suggestions/problems, please, create an issue on GitHub and I will try to help you