ata-validator 0.4.5 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +14 -20
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -6,15 +6,16 @@ Ultra-fast JSON Schema validator powered by [simdjson](https://github.com/simdjs
6
6
 
7
7
  ## Performance
8
8
 
9
- ### Single-Document Validation (valid data)
9
+ ### Single-Document Validation
10
10
 
11
11
  | Scenario | ata | ajv | |
12
12
  |---|---|---|---|
13
- | **validate(obj)** | 15M ops/sec | 8.5M ops/sec | **ata 1.8x faster** |
14
- | **isValidObject(obj)** | 17.4M ops/sec | 9.4M ops/sec | **ata 1.8x faster** |
15
- | **validateJSON(str)** | 2.1M ops/sec | 1.9M ops/sec | **ata 1.1x faster** |
16
- | **isValidJSON(str)** | 2.0M ops/sec | 1.9M ops/sec | **ata 1.1x faster** |
17
- | **Schema compilation** | 125,690 ops/sec | 831 ops/sec | **ata 151x faster** |
13
+ | **validate(obj)** valid | 15M ops/sec | 8M ops/sec | **ata 1.9x faster** |
14
+ | **validate(obj)** invalid | 13.1M ops/sec | 8.1M ops/sec | **ata 1.6x faster** |
15
+ | **isValidObject(obj)** | 15.4M ops/sec | 9.2M ops/sec | **ata 1.7x faster** |
16
+ | **validateJSON(str)** valid | 2.15M ops/sec | 1.88M ops/sec | **ata 1.1x faster** |
17
+ | **validateJSON(str)** invalid | 2.62M ops/sec | 2.35M ops/sec | **ata 1.1x faster** |
18
+ | **Schema compilation** | 112K ops/sec | 773 ops/sec | **ata 145x faster** |
18
19
 
19
20
  ### Large Data — JS Object Validation
20
21
 
@@ -33,18 +34,11 @@ Ultra-fast JSON Schema validator powered by [simdjson](https://github.com/simdjs
33
34
  | **Batch NDJSON** (10K items, multi-core) | 13.4M/sec | 5.1M/sec | **ata 2.6x faster** |
34
35
  | **Fastify HTTP** (100 users POST) | 24.6K req/sec | 22.6K req/sec | **ata 9% faster** |
35
36
 
36
- ### Where ajv wins
37
-
38
- | Scenario | ata | ajv | |
39
- |---|---|---|---|
40
- | **validate(obj)** (invalid data) | 6M ops/sec | 7.9M ops/sec | **ajv 1.3x faster** |
41
- | **validateJSON(str)** (invalid data) | 2.2M ops/sec | 2.3M ops/sec | **ajv 1.1x faster** |
42
-
43
- > Invalid-data error path — ajv is slightly faster. Production traffic is overwhelmingly valid.
37
+ > ata is faster than ajv on **every** benchmark — valid and invalid data, objects and JSON strings, single documents and parallel batches.
44
38
 
45
39
  ### How it works
46
40
 
47
- **Speculative validation**: For valid data (the common case), ata runs a JS codegen fast path entirely in V8 JIT no NAPI boundary crossing. Only when validation fails does it fall through to the JS error-collecting codegen or C++ engine.
41
+ **Combined single-pass validation**: ata compiles schemas into monolithic JS functions that both validate and collect errors in a single pass. Valid data returns immediately (lazy error array zero allocation). Invalid data collects errors without a second pass.
48
42
 
49
43
  **JS codegen**: Schemas are compiled to monolithic JS functions (like ajv). Supported keywords: `type`, `required`, `properties`, `items`, `enum`, `const`, `allOf`, `anyOf`, `oneOf`, `not`, `if/then/else`, `uniqueItems`, `contains`, `prefixItems`, `additionalProperties`, `dependentRequired`, `$ref` (local), `minimum/maximum`, `minLength/maxLength`, `pattern`, `format`.
50
44
 
@@ -58,7 +52,7 @@ Ultra-fast JSON Schema validator powered by [simdjson](https://github.com/simdjs
58
52
 
59
53
  ## When to use ata
60
54
 
61
- - **Any `validate(obj)` workload** — 1.8x–2.7x faster than ajv on valid data
55
+ - **Any `validate(obj)` workload** — 1.6x–2.7x faster than ajv on all data
62
56
  - **Serverless / cold starts** — 12.5x faster schema compilation
63
57
  - **Security-sensitive apps** — RE2 regex, immune to ReDoS attacks
64
58
  - **Batch/streaming validation** — NDJSON log processing, data pipelines (2.6x faster)
@@ -67,12 +61,12 @@ Ultra-fast JSON Schema validator powered by [simdjson](https://github.com/simdjs
67
61
 
68
62
  ## When to use ajv
69
63
 
70
- - **Error-heavy workloads**where most data is invalid (ajv 1.3x faster on error path)
71
- - **Schemas with `patternProperties`, `dependentSchemas`**these bypass JS codegen
64
+ - **Schemas with `patternProperties`, `dependentSchemas`** these bypass JS codegen and hit the slower NAPI path
65
+ - **100% spec compliance needed**ajv covers more edge cases (ata: 98.4%)
72
66
 
73
67
  ## Features
74
68
 
75
- - **Speculative validation**: JS codegen fast pathvalid data never crosses the NAPI boundary
69
+ - **Combined single-pass validation**: One JS function validates + collects errors no double pass, lazy error allocation
76
70
  - **Multi-core**: Parallel validation across all CPU cores — 13.4M validations/sec
77
71
  - **simdjson**: SIMD-accelerated JSON parsing at GB/s speeds, adaptive On Demand for large docs
78
72
  - **RE2 regex**: Linear-time guarantees, immune to ReDoS attacks (2391x faster on pathological input)
@@ -107,7 +101,7 @@ const v = new Validator({
107
101
  required: ['name', 'email']
108
102
  });
109
103
 
110
- // Fast boolean check — JS codegen, no NAPI (1.8x faster than ajv)
104
+ // Fast boolean check — JS codegen (1.7x faster than ajv)
111
105
  v.isValidObject({ name: 'Mert', email: 'mert@example.com', age: 26 }); // true
112
106
 
113
107
  // Full validation with error details + defaults applied
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ata-validator",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "description": "Ultra-fast JSON Schema validator. Beats ajv on every valid-path benchmark: 1.1x–2.7x faster validate(obj), 151x faster compilation, 5.9x faster parallel batch. Speculative validation with V8-optimized JS codegen, simdjson, multi-core. Standard Schema V1 compatible.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",