{"id":47711238,"url":"https://github.com/ata-core/ata-validator","last_synced_at":"2026-05-18T01:07:40.559Z","repository":{"id":346413953,"uuid":"1188841276","full_name":"ata-core/ata-validator","owner":"ata-core","description":"Native C++ validator built on simdjson and RE2. Hybrid JS codegen with V8 TurboFan optimizations. Up to 94x faster on $dynamicRef, 5.3x on normal schemas, 2,729x faster compilation. Full $dynamicRef/$anchor support, Draft 2020-12 + Draft 7 compatible","archived":false,"fork":false,"pushed_at":"2026-05-09T14:31:00.000Z","size":2171,"stargazers_count":328,"open_issues_count":5,"forks_count":6,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-05-09T14:36:02.888Z","etag":null,"topics":["fast","json-schema","napi","native","schema","simdjson","standard-schema","validation","validator"],"latest_commit_sha":null,"homepage":"https://ata-validator.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ata-core.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-22T16:53:00.000Z","updated_at":"2026-05-09T14:29:06.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ata-core/ata-validator","commit_stats":null,"previous_names":["ata-core/ata-validator"],"tags_count":50,"template":false,"template_full_name":null,"purl":"pkg:github/ata-core/ata-validator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ata-core%2Fata-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ata-core%2Fata-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ata-core%2Fata-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ata-core%2Fata-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ata-core","download_url":"https://codeload.github.com/ata-core/ata-validator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ata-core%2Fata-validator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33161411,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T22:39:12.733Z","status":"ssl_error","status_checked_at":"2026-05-17T22:39:10.741Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fast","json-schema","napi","native","schema","simdjson","standard-schema","validation","validator"],"created_at":"2026-04-02T18:32:26.831Z","updated_at":"2026-05-18T01:07:40.546Z","avatar_url":"https://github.com/ata-core.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ata-validator\n\nJSON Schema validation with first-class TypeScript and zero runtime cost. AOT compile your schemas to per-schema ESM modules with no validator dependency. `Validator\u003cT\u003e` composes with TypeBox, Zod-from-JSON-Schema, Valibot, or hand-written types. Runtime API available for dynamic schemas.\n\n[![npm](https://img.shields.io/npm/v/ata-validator)](https://www.npmjs.com/package/ata-validator)\n[![License](https://img.shields.io/npm/l/ata-validator)](LICENSE)\n\n## Quick start\n\n```bash\nnpm install --save-dev ata-validator\nnpx ata build 'schemas/*.json' --out-dir src/generated\n```\n\nIn your code:\n\n```ts\nimport { validate, isValid, type User } from './generated/user.compiled.mjs'\n\nif (isValid(req.body)) {\n  const user: User = req.body\n  // ...\n}\n```\n\nThe `.compiled.mjs` modules are self-contained: zero runtime dependency on ata-validator, fully tree-shakeable, with TypeScript types emitted alongside.\n\n## Why AOT\n\n| Dimension | Schema | ata-AOT | AJV-runtime | Difference |\n|---|---|---|---|---|\n| Bundle (gzipped) | simple | 955 B | 52.7 KB | 56x smaller |\n| Bundle (gzipped) | complex | 1.6 KB | 52.7 KB | 32x smaller |\n| Cold start | simple | 21 ms | 38 ms | 1.8x faster |\n| Throughput (10M ops) | simple | 345 Mops/s | 116 Mops/s | 3.0x faster |\n| Compile time | simple | 6 µs | 1.5 ms | 246x faster |\n\nReproduce on your machine with `npm run bench:aot-vs-ajv`. Numbers measured on Apple M4 Pro, Node 25.2.1.\n\nThe wins are largest on bundle size and compile time because AOT moves work from runtime to build time. Throughput and cold start are also faster because the compiled validator is a tight straight-line function with no schema-walk overhead.\n\n## When to use the runtime API instead\n\n`ata build` is for schemas you know at build time. If your schemas are user-supplied at runtime (form builders, no-code platforms, dynamic API ingestion), use the runtime API:\n\n```js\nimport { Validator } from 'ata-validator'\n\nconst v = new Validator(schema)\nconst result = v.validate(data)\n```\n\nThe runtime API is unchanged from previous releases. AJV-shim users continue importing from `ata-validator/compat`.\n\n## Usage\n\n### Node.js\n\n```javascript\nconst { Validator } = require('ata-validator');\n\nconst v = new Validator({\n  type: 'object',\n  properties: {\n    name: { type: 'string', minLength: 1 },\n    email: { type: 'string', format: 'email' },\n    age: { type: 'integer', minimum: 0 },\n    role: { type: 'string', default: 'user' }\n  },\n  required: ['name', 'email']\n});\n\n// Fast boolean check - JS codegen, 15.3M ops/sec\nv.isValidObject({ name: 'Mert', email: 'mert@example.com', age: 26 }); // true\n\n// Full validation with error details + defaults applied\nconst result = v.validate({ name: 'Mert', email: 'mert@example.com' });\n// result.valid === true, data.role === 'user' (default applied)\n\n// JSON string validation (simdjson fast path)\nv.validateJSON('{\"name\": \"Mert\", \"email\": \"mert@example.com\"}');\nv.isValidJSON('{\"name\": \"Mert\", \"email\": \"mert@example.com\"}'); // true\n\n// Buffer input (zero-copy, raw NAPI)\nv.isValid(Buffer.from('{\"name\": \"Mert\", \"email\": \"mert@example.com\"}'));\n\n// Parallel batch - multi-core, NDJSON, 13.4M items/sec\nconst ndjson = Buffer.from(lines.join('\\n'));\nv.isValidParallel(ndjson);  // bool[]\nv.countValid(ndjson);        // number\n```\n\n### Type-safe schemas\n\n`Validator` is generic. Pair it with any schema authoring tool, or a hand-written type, to get TypeScript narrowing in your handler code.\n\n```ts\nimport { Type, type Static } from '@sinclair/typebox'\nimport { Validator } from 'ata-validator'\n\nconst UserSchema = Type.Object({\n  id: Type.Integer({ minimum: 1 }),\n  name: Type.String({ minLength: 1 }),\n  email: Type.String({ format: 'email' }),\n})\n\ntype User = Static\u003ctypeof UserSchema\u003e\n\nconst v = new Validator\u003cUser\u003e(UserSchema)\n\nif (v.isValidObject(data)) {\n  // data is narrowed to User, no cast needed\n  console.log(data.name)\n}\n\nconst result = v.validate(data)\nif (result.valid) {\n  // result.data is User\n} else {\n  // result.errors: ValidationError[]\n}\n```\n\nThe same pattern works with Zod-from-JSON-Schema, Valibot, or a hand-written `type User = {...}` alongside a JSON Schema literal. `Validator\u003cT\u003e` makes no library-specific assumption.\n\n### Cross-Schema `$ref`\n\n```javascript\nconst addressSchema = {\n  $id: 'https://example.com/address',\n  type: 'object',\n  properties: { street: { type: 'string' }, city: { type: 'string' } },\n  required: ['street', 'city']\n};\n\nconst v = new Validator({\n  type: 'object',\n  properties: {\n    name: { type: 'string' },\n    address: { $ref: 'https://example.com/address' }\n  }\n}, { schemas: [addressSchema] });\n\n// Or use addSchema()\nconst v2 = new Validator(mainSchema);\nv2.addSchema(addressSchema);\n```\n\n### Options\n\n```javascript\nconst v = new Validator(schema, {\n  coerceTypes: true,       // \"42\" → 42 for integer fields\n  removeAdditional: true,  // strip properties not in schema\n  schemas: [otherSchema],  // cross-schema $ref registry\n  abortEarly: true,        // skip detailed error collection on failure (~4x faster on invalid data)\n});\n```\n\n`abortEarly` returns a shared `{ valid: false, errors: [{ message: 'validation failed' }] }` on failure instead of running the detailed error collector. Useful when the caller only needs a pass/fail decision (Fastify route guards, high-throughput gatekeepers, request rejection at the edge).\n\n### Build-time compile (`ata compile`)\n\nThe `ata` CLI turns a JSON Schema file into a self-contained JavaScript module. No runtime dependency on `ata-validator`, so only the generated validator ships to the browser. Typical output is ~1 KB gzipped compared to ~27 KB for the full runtime.\n\n```bash\nnpx ata compile schemas/user.json -o src/generated/user.validator.mjs\n```\n\nThe CLI emits two files: the validator itself and a paired `.d.mts` (or `.d.cts`) with the inferred TypeScript type plus an `isValid` type predicate.\n\n```ts\nimport { isValid, validate, type User } from './user.validator.mjs'\n\nconst incoming: unknown = JSON.parse(req.body)\n\nif (isValid(incoming)) {\n  // TypeScript narrows to User here\n  incoming.id      // number\n  incoming.role    // 'admin' | 'user' | 'guest' | undefined\n}\n\nconst r = validate(incoming)\n// { valid: true, errors: [] } | { valid: false, errors: ValidationError[] }\n```\n\nCLI options:\n\n| Flag | Default | Description |\n|---|---|---|\n| `-o, --output \u003cfile\u003e` | `\u003cschema\u003e.validator.mjs` | Output path |\n| `-f, --format \u003cfmt\u003e` | `esm` | `esm` or `cjs` |\n| `--name \u003cTypeName\u003e` | from filename | Root type name in the `.d.ts` |\n| `--abort-early` | off | Generate the stub-error variant (~0.5 KB gzipped) |\n| `--no-types` | off | Skip the `.d.mts` / `.d.cts` output |\n\nFor a project with many schemas, `ata build \u003cglob\u003e` compiles them all in one command:\n\n```bash\nnpx ata build 'schemas/*.json' --out-dir build/validators --check\n```\n\nRun with `--watch` during development for incremental rebuilds.\n\nTypical bundle sizes (10-field user schema, gzipped):\n\n| Variant | Size | Notes |\n|---|---|---|\n| `ata-validator` runtime | ~27 KB | Full compiler + all keywords |\n| `ata compile` (standard) | **~1.1 KB** | Validator + detailed error collector |\n| `ata compile --abort-early` | **~0.5 KB** | Validator + stub errors only |\n\nProgrammatic API if you prefer to script it:\n\n```javascript\nconst fs = require('fs');\nconst { Validator } = require('ata-validator');\n\nconst v = new Validator(schema);\nfs.writeFileSync('./user.validator.mjs', v.toStandaloneModule({ format: 'esm' }));\n```\n\n**Fastify startup (10 routes cold): ajv 12.6ms → ata 0.5ms (24x faster boot, no build step required)**\n\n### Standard Schema V1\n\n```javascript\nconst v = new Validator(schema);\n\n// Works with Fastify, tRPC, TanStack, etc.\nconst result = v['~standard'].validate(data);\n// { value: data } on success\n// { issues: [{ message, path }] } on failure\n```\n\n### Fastify Plugin\n\n```bash\nnpm install fastify-ata\n```\n\n```javascript\nconst fastify = require('fastify')();\nfastify.register(require('fastify-ata'), {\n  coerceTypes: true,\n  removeAdditional: true,\n});\n\n// All existing JSON Schema route definitions work as-is\n```\n\n### C++\n\n```cpp\n#include \"ata.h\"\n\nauto schema = ata::compile(R\"({\n  \"type\": \"object\",\n  \"properties\": { \"name\": {\"type\": \"string\"} },\n  \"required\": [\"name\"]\n})\");\n\nauto result = ata::validate(schema, R\"({\"name\": \"Mert\"})\");\n// result.valid == true\n```\n\n## Framework integrations\n\nCopy-paste recipes for the common frameworks. Most need 10-20 lines of glue. See [docs/integrations](docs/integrations/) for the full set.\n\n| Framework | Pattern | Recipe |\n|---|---|---|\n| Fastify | dedicated plugin | [`fastify-ata`](https://github.com/ata-core/fastify-ata) |\n| Vite (build-time compile) | dedicated plugin | [`ata-vite`](https://github.com/ata-core/ata-vite) |\n| Hono | async middleware | [docs/integrations/hono.md](docs/integrations/hono.md) |\n| Elysia | direct handler check | [docs/integrations/elysia.md](docs/integrations/elysia.md) |\n| tRPC | Standard Schema V1 input | [docs/integrations/trpc.md](docs/integrations/trpc.md) |\n| TanStack Form | Standard Schema V1 validator | [docs/integrations/tanstack-form.md](docs/integrations/tanstack-form.md) |\n| Express | sync middleware | [docs/integrations/express.md](docs/integrations/express.md) |\n| Koa | async ctx middleware | [docs/integrations/koa.md](docs/integrations/koa.md) |\n| NestJS | validation pipe | [docs/integrations/nestjs.md](docs/integrations/nestjs.md) |\n| SvelteKit | form action, API route | [docs/integrations/sveltekit.md](docs/integrations/sveltekit.md) |\n| Astro | API route, server action | [docs/integrations/astro.md](docs/integrations/astro.md) |\n\n## Supported Keywords\n\n| Category | Keywords |\n|----------|----------|\n| Type | `type` |\n| Numeric | `minimum`, `maximum`, `exclusiveMinimum`, `exclusiveMaximum`, `multipleOf` |\n| String | `minLength`, `maxLength`, `pattern`, `format` |\n| Array | `items`, `prefixItems`, `minItems`, `maxItems`, `uniqueItems`, `contains`, `minContains`, `maxContains`, `unevaluatedItems` |\n| Object | `properties`, `required`, `additionalProperties`, `patternProperties`, `minProperties`, `maxProperties`, `propertyNames`, `dependentRequired`, `dependentSchemas`, `unevaluatedProperties` |\n| Enum/Const | `enum`, `const` |\n| Composition | `allOf`, `anyOf`, `oneOf`, `not` |\n| Conditional | `if`, `then`, `else` |\n| References | `$ref`, `$defs`, `definitions`, `$id` |\n| Boolean | `true`, `false` |\n\n### Format Validators (hand-written, no regex)\n\n`email`, `date`, `date-time`, `time`, `uri`, `uri-reference`, `ipv4`, `ipv6`, `uuid`, `hostname`\n\n## Building from Source\n\n### Development prerequisites\n\nNative builds require C/C++ toolchain support and the following libraries:\n\n- `re2`\n- `abseil`\n- `mimalloc`\n\nInstall them before running `npm install` / `npm run build`:\n\n```bash\n# macOS (Homebrew)\nbrew install re2 abseil mimalloc\n```\n\n```bash\n# Ubuntu/Debian (apt)\nsudo apt-get update\nsudo apt-get install -y libre2-dev libabsl-dev libmimalloc-dev\n```\n\n```bash\n# C++ library + tests\ncmake -B build\ncmake --build build\n./build/ata_tests\n\n# Node.js addon\nnpm install\nnpm run build\nnpm test\n\n# JSON Schema Test Suite\nnpm run test:suite\n```\n\n## License\n\nMIT\n\n## Authors\n\n[Mert Can Altin](https://github.com/mertcanaltin)\n[Daniel Lemire](https://github.com/lemire)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fata-core%2Fata-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fata-core%2Fata-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fata-core%2Fata-validator/lists"}