v0.15.0
v0.15.0 ships compiler-grade error messages for JSON Schema validation. Every error now carries a stable code, a code-frame pointing at the offending schema line, another pointing at the offending bytes in the request payload, and (when ata is confident) a suggestion. The output is tsc --pretty / rustc shaped, not the structured-JSON wall of text validators have shipped for a decade.
The frame is possible because ata is AOT-compiled: the schema file path, line, and column travel into the compiled validator. Runtime validators get the same frame when constructed with { source: { path, content } }. Bundle size on production builds (NODE_ENV=production or --no-source) is unchanged from v0.14.
error[ATA3001]: value does not match format "email"
--> schemas/user.json:5:7
|
5 | "email": { "type": "string", "format": "email" }
| ^ expected format 'email'
|
--> input, byte 23
|
1 | { "name": "M", "email": "not-an-email", "age": -3 }
| ^^^^^^^^^^^^^^ got "not-an-email"
|
= help: missing '@' and domain part
= note: see https://ata-validator.com/e/ATA3001
Added
ATA####error code registry. 46 stable codes covering type, shape, constraint, format, composition, ref, enum, and system categories. Every error gets one. Permalinks athttps://ata-validator.com/e/<CODE>. Full registry indocs/error-codes.md.- Renderer API.
renderPretty,renderCompact, andrenderJSONexported fromata-validator. Pretty is rustc-style; compact is one line per error (CI-grep-friendly); JSON is structured for tooling. TTY auto-picks pretty, pipes auto-pick compact. ata validate <schema> <data>CLI subcommand. Runs a schema against a JSON data file, exits 0/1, prints via the active renderer. Flags:--pretty,--compact,--format=json,--max-errors,--color,--no-color.- Schema source frames.
schemaSource: { file, line, col, text }on every error. AOT-compiled validators bake the frame at codegen time. Runtime validators get parity withnew Validator(schema, { source: { path, content } }). - Request payload frames.
dataFrame: { byteOffset, length, line, col, text }whenevervalidateJSON()was called with a string or Buffer. Zero cost on the valid path, JS-side reparse only on failure. oneOf/anyOfcollapse. Branching failures collapse to a single best-branch error (ATA4001/ATA4002/ATA4003) instead of the full branch-tree explosion. The closest matching variant's errors stay available underbranchErrors.allOferrors continue to surface every failing branch.- Suggestions. A new
suggestionfield nudges users when ata is confident: typo against enum, missing-required typo close to a present key, format-violation hint, type-coercion nudge. Runtime validators populate automatically. AOT consumers callattachSuggestions(errors, data)to keep AOT bundles at zero size growth. ata compile/ata buildflags. New--source/--no-source.ata build --dualemits both a source-mapped artifact (*.compiled.mjs) and a stripped one (*.compiled.min.mjs) in a single run. Source is on by default in development, off whenNODE_ENV=productionso production bundles stay at the v0.14 size baseline.- Size budget gate.
npm run bench:sizeenforces a gzipped-byte budget over the AOT codegen output. Baseline atbenchmark/baselines/aot-size.json; gates derive from the baseline with 1.5x headroom. richErrors: falseopt-out.new Validator(schema, { richErrors: false })returns the v0.14 error shape byte-for-byte. For users who built log dashboards or alerts on the prior shape.release:checknpm script. Runs prebuilds, doc-coverage, and error-code lockfile checks in strict mode before publish.
Changed
prepublishOnlynow chainscheck-prebuilds,check-doc-coverage, and the error-code lockfile test.ata compileandata buildfailures route through the renderer with codeATA9002, so command-line schema errors look the same as runtime ones.abortEarly: truereturns the existing short-circuit stub withcode: 'ATA9000'. Measured 68.95x faster than full enrichment on the same payload; the perf gate (intests/test_abort_early.js) asserts at least 3x.
Notes
- Backward compatibility. New fields are additive.
result.errors[i].message,.path,.keyword,.schemaPath,.instancePath,.dataPath,.params, and.parentSchemaare unchanged. Existing code consumers and theata-validator/compatAJV-shim do not need to migrate. - Log scrapers. If you serialize
result.errorsdirectly into logs, line size will grow because of the new fields. Pipe throughrenderCompactfor a stable one-line format, or passrichErrors: falsefor the v0.14 shape. - Production bundle size. Source-mapped variants (
.compiled.mjs) add up to ~200 gzipped bytes for a 10-field schema. Production builds (NODE_ENV=productionor--no-source) emit the no-source variant; size unchanged. - Companion releases. A
fastify-atarelease wires the new error format into Fastify route responses.