moonschema — JSON Schema validation for MoonBit: draft-04, draft-06, draft-07, 2019-09 and 2020-12, measured against every case of the official JSON-Schema-Test-Suite. It validates; it does not parse JSON — that is moonjson — and it opens no sockets.
let schema = @moonschema.Schema::new(document) // `document` is a Json tree
schema.valid(instance) // the flag output: yes or no
schema.faults(instance) // the basic output: every reason
// A reference to another document reaches what the caller hands it, and nothing
// else: this opens no sockets.
@moonschema.Schema::new(document, remotes={ "https://example.test/int": other })| Version | Cases | Passing |
|---|---|---|
| draft-04 | 618 | 618 |
| draft-06 | 841 | 841 |
| draft-07 | 929 | 929 |
| 2019-09 | 1261 | 1261 |
| 2020-12 | 1301 | 1301 |
| total | 4950 | 4950 |
| Value | Version | Why it is here |
|---|---|---|
| Draft4 | draft-04 (2013) | What OpenAPI 3.0 profiles, and what much Java and Python tooling still emits |
| Draft6 | draft-06 (2017) | $id replaces id; exclusiveMinimum becomes a number |
| Draft7 | draft-07 (2018) | The most widely deployed version |
| Draft2019 | 2019-09 | Vocabularies, $defs, $recursiveRef, unevaluatedProperties |
| Draft2020 | 2020-12 | $dynamicRef, prefixItems — and what OpenAPI 3.1 is |
git submodule update --init --recursive
cd gate && moon run . --target nativemoon add moonbitstack/moonschemapub struct Schema {
// private fields
}Install
Download zipmoonschema — JSON Schema validation for MoonBit: draft-04, draft-06, draft-07, 2019-09 and 2020-12, measured against every case of the official JSON-Schema-Test-Suite. It validates; it does not parse JSON — that is moonjson — and it opens no sockets.