Repository navigation
0.12.0
Validators compile through ata-validator/ir by default. Needs ata-validator 1.63.0; with an older one nothing changes.
A validator the file only calls (validate(), isValidObject()) is compiled by the new compiler, whose modules import their helpers from ata-validator/kernels, once per page however many validators it has. Verdicts, errors (every field, in order, rich or plain) and filled defaults are the same as before. Measured with esbuild (minified, gzip level 9) on form schemas with their errors read:
| validators in the bundle | 0.11.3 | 0.12.0 |
|---|---|---|
| 1 | 11.0 KB | 4.3 KB |
| 3 | 12.7 KB | 5.5 KB |
| 10 | 17.6 KB | 5.8 KB |
Across the 654 SchemaStore schemas both paths compile away, the bundle is 0.52 of the previous one at the median and larger on none. Reading the errors of an invalid document takes 0.64 of the previous time at the median and is slower on none of 116 schemas; a valid document's verdict takes 1.03 of it at the median, and 1.9 times as long on the slowest schema measured alone. Loaded fresh with its first ten calls, the new module took 0.49 of the time at the median and was faster on all 48 schemas sampled, mostly because there is less to load.
Many forms as data. table: 'auto', on by default: the build rewrites each file both with written modules and with plans for one interpreter shared across the bundle (ata-validator/ir tableModule), and keeps the plans when the rewritten application comes out smaller, by a threshold set from Vite + React builds of 1 to 10 forms, on which it never took the plans for the larger bundle. In a Vite + React application with ten six-field forms reading plain errors, the validators add 2.02 KB gzipped to the first load, against 5.35 KB as modules; with email and uri fields, 2.70 against 8.24. A single form keeps its module, 1.41 KB. Verdicts, errors and defaults are the same; a plan is slower per call (445 against 22 ns on a valid order form). table: false keeps modules.
One OpenAPI document for the server and the page. openapi: 'openapi.json' writes openapi.validators.mjs and .d.mts beside the document: one validator per operation's JSON request body, plain source a server imports as it is, compiled by the page's build. On a nine-field signup operation the server and the page disagreed on 0 of 50,000 generated documents, every error compared; the page's validation added 3.78 KB gzipped to a Vite + React first load. Needs ata-validator 1.63.0 (ata-validator/openapi).
Next.js, under Turbopack too. withAta(nextConfig, options) from @ata-project/unplugin/next covers both bundlers Next runs: Turbopack, the default since Next.js 16, through a loader (@ata-project/unplugin/turbopack), and webpack through the plugin. Before, the plugin had no way into Turbopack and a Next.js 16 app kept the runtime. On a Next.js 16 page with one order form that reads its errors, the validator adds 4.2 KB gzipped to the first load under Turbopack and 4.6 KB under webpack, against 67.5 and 58.3 KB for the runtime Validator.
ir: false keeps the previous modules. A schema or option the new compiler does not cover (custom keywords or formats, errorMessage, options other than richErrors, useDefaults and assertFormat) takes the previous path on its own, as does a validator handed to other code.
ataResolver(schema) from @hookform/resolvers/ata-validator compiles through the new compiler too, with plain errors (a resolver reads the same fields from them), once the installed resolvers export ataCompiledResolver: 4.8 KB to 2.6 KB on the test fixture.
The ir default and ata-validator 1.63.1. The default compiles with ata-validator/ir only on ata-validator 1.63.1 and later, the release whose module writer was measured: on 1.63.0 the IR's modules were slower than the compiled ones on 129 of 438 SchemaStore schemas by a fifth or more; from 1.63.1 on 51, and faster on 216. On 1.63.0 the plugin keeps the compiled modules unless ir: true is given. The many-forms sizes above (2.02 and 2.70 KB) are the same on both.