Repository navigation
schema-calc v0.1.1
A compatibility release. The compiled schemas now load with default options in ten of the twelve Draft 2020-12 validators tested in five languages, up from six. The input language is unchanged, and no validator gave a wrong answer on any record. The invoice schema grows by 132 bytes. Try it in any browser; nothing is sent to a server.
Validator compatibility
The flat corpus (31 schemas, 24,472 records) and the shipped examples were run through every validator with its default options (full table):
| Validator | v0.1.0 schemas | v0.1.1 schemas |
|---|---|---|
| santhosh-tekuri/jsonschema, kaptinlin/jsonschema (Go) | refuses all 31 | loads all, all records agree |
| JsonSchema.Net (C#) | refuses 3 | loads all, all records agree |
| networknt json-schema-validator (Java) | times out on the invoice | loads all, all records agree |
| @cfworker/json-schema (JS) | refuses 23 | refuses 23; loads all with --defs |
| jsonschema-rs (Python) | exceeds 2 GB on 11 | exceeds 2 GB on 10 (8 with --defs) |
| Ajv, hyperjump, schemasafe, Python jsonschema, harrel, json-sKema | loads all | loads all, all records agree |
What changed
- No lookahead. Each field's format ends with
$plusnot: {pattern: "[^.0-9]"}instead of(?![\s\S]), which Go's RE2 does not support. The second pattern is needed because$in Python, Java and .NET also matches before a final line terminator; tests now cover\n,\r,\u0085and. - At most 32 nesting levels. Subschemas that would nest deeper move into a root
$defs. JsonSchema.Net's JSON parser stops at 64 levels, and networknt's load time grows steeply with depth.compile(spec, { maxDepth })sets the limit. - Optional
$defslayout.--defsorcompile(spec, { layout: 'defs' })declares every shared resource in root$defs, so none sits inside another, which @cfworker/json-schema requires. It costs 17–20% more bytes. - Browser preparation now orders resources by dependency.
Check it without Schema Calc
Python 3 and jsonschema only, in an empty directory:
python3 -m pip install jsonschema==4.25.1
base=https://github.com/fMindstormer/schema-calc/releases/download/v0.1.1
for f in validate.py invoice.schema.json invoice.valid.json invoice.invalid.json; do curl -fLO "$base/$f"; done
python3 validate.py invoice.schema.json invoice.valid.json invoice.invalid.jsonACCEPT invoice.valid.json
REJECT invoice.invalid.json
Sizes
| Example | v0.1.0 | v0.1.1 |
|---|---|---|
| invoice | 41,232 B | 41,364 B |
| allocation | 16,315 B | 16,447 B |
| carry chain | 20,510 B | 20,605 B |
Files
invoice.schema.json is the compiled invoice contract; invoice.valid.json and invoice.invalid.json are the correct record and the one a cent off, unchanged from 0.1.0. validate.py is the standalone validator: it needs only jsonschema and never imports the compiler. schema-calc-0.1.1.zip is the source, with a MANIFEST.sha256 inside; schema-calc-0.1.1.zip.sha256 is its checksum and SHA256SUMS covers every file.
Scope
Unchanged: sums and differences of nonnegative decimal strings, up to 8 fields, 8 equations and 12 digits. A research prototype; it is not published to npm. Benchmark timings in the repository were measured on the 0.1.0 schemas.