Schema library provides APIs to parse Schema and to validate Json by parsed Schema.
What is JSON Schema?
Use @lib.parse
to parse a JSON Schema.
You can use @lib.validate
to validate a JSON object by a parsed Schema.
- Support for references is being done.
- Using options to control some validation behavior is in planning.
- Add documentation.
let schema = @lib.parse!({
"$id": "example",
"type": "object",
"properties": {
"limited_number": {
"type": "number",
"minimum": 0,
"maximum": 42
}
}
})
println(schema.validate({ "limited_number": 23 }).is_ok()) // output: true
println(schema.validate({ "limited_number": 42.1 }).is_ok()) // output: false
Note
The library is WIP! The APIs are unstable and the functionality is not complete.