Compile-once JSON Schema 2020-12 validator for MoonBit: exact decimal arithmetic, precise pattern semantics, no silent schema errors, no hidden I/O.
Dependencies
///|
let document = @json-schema.parse(
"{\"type\":\"object\",\"required\":[\"amount\"],\"properties\":{\"amount\":{\"type\":\"number\",\"multipleOf\":0.1}},\"additionalProperties\":false}",
)
///|
let schema = @json-schema.Schema::compile(document)
///|
let instance = @json-schema.parse("{\"amount\":0.3}")
///|
let valid = schema.valid(instance)
///|
let failures = schema.faults(instance)moon check --target native --deny-warn --output-json
moon test --target native --deny-warn --output-json
moon check --target js --deny-warn --output-json
moon test --target js --deny-warn --output-json
moon check --target wasm --deny-warn --output-json
moonx benchmarks/run-campaign.mbtxpub(all) suberror CompileError {
InvalidKeyword(path~ : String, reason~ : String)
UnknownDialect(String)
UnsupportedKeyword(path~ : String, keyword~ : String)
UnsupportedPattern(path~ : String, pattern~ : String, reason~ : String)
DepthLimit(Int)
} derive(Debug)pub(all) suberror ParseError {
InvalidJson(position~ : Int, reason~ : String)
DepthLimit(Int)
} derive(Debug)pub struct CompiledPattern {
// private fields
}pub struct Schema {
// private fields
}Install
Download zipCompile-once JSON Schema 2020-12 validator for MoonBit: exact decimal arithmetic, precise pattern semantics, no silent schema errors, no hidden I/O.
Dependencies