ata-validator 0.1.0 → 0.2.0

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.
package/index.js CHANGED
@@ -1,22 +1,56 @@
1
1
  const native = require("node-gyp-build")(__dirname);
2
2
 
3
+ function parsePointerPath(path) {
4
+ if (!path) return [];
5
+ return path
6
+ .split("/")
7
+ .filter(Boolean)
8
+ .map((seg) => ({
9
+ key: seg.replace(/~1/g, "/").replace(/~0/g, "~"),
10
+ }));
11
+ }
12
+
3
13
  class Validator {
4
14
  constructor(schema) {
5
15
  const schemaStr =
6
16
  typeof schema === "string" ? schema : JSON.stringify(schema);
7
17
  this._compiled = new native.CompiledSchema(schemaStr);
18
+
19
+ const self = this;
20
+ Object.defineProperty(this, "~standard", {
21
+ value: Object.freeze({
22
+ version: 1,
23
+ vendor: "ata-validator",
24
+ validate(value) {
25
+ const result = self._compiled.validate(value);
26
+ if (result.valid) {
27
+ return { value };
28
+ }
29
+ return {
30
+ issues: result.errors.map((err) => ({
31
+ message: err.message,
32
+ path: parsePointerPath(err.path),
33
+ })),
34
+ };
35
+ },
36
+ }),
37
+ writable: false,
38
+ enumerable: false,
39
+ configurable: false,
40
+ });
8
41
  }
9
42
 
10
- // Validates data directly — no JSON.stringify overhead
11
- // Accepts JS objects, arrays, strings, numbers, booleans, null
12
43
  validate(data) {
13
44
  return this._compiled.validate(data);
14
45
  }
15
46
 
16
- // Force JSON string path (simdjson parse + validate)
17
47
  validateJSON(jsonStr) {
18
48
  return this._compiled.validateJSON(jsonStr);
19
49
  }
50
+
51
+ isValidJSON(jsonStr) {
52
+ return this._compiled.isValidJSON(jsonStr);
53
+ }
20
54
  }
21
55
 
22
56
  function validate(schema, data) {
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "ata-validator",
3
- "version": "0.1.0",
4
- "description": "Ultra-fast JSON Schema validator powered by simdjson. 11,000x faster schema compilation, 2-4x faster validation than ajv.",
3
+ "version": "0.2.0",
4
+ "description": "Ultra-fast JSON Schema validator powered by simdjson, RE2, and codegen bytecode engine. 120x faster schema compilation, 98.6% spec compliant, Standard Schema V1 compatible.",
5
5
  "main": "index.js",
6
+ "types": "index.d.ts",
6
7
  "scripts": {
7
8
  "install": "node-gyp-build",
8
9
  "build": "node-gyp rebuild",
@@ -11,6 +12,7 @@
11
12
  "test": "node test.js",
12
13
  "test:suite": "node tests/run_suite.js",
13
14
  "test:compat": "node tests/test_compat.js",
15
+ "test:standard-schema": "node tests/test_standard_schema.js",
14
16
  "bench": "node benchmark/bench_large.js"
15
17
  },
16
18
  "keywords": [
@@ -24,24 +26,28 @@
24
26
  "simdjson",
25
27
  "napi",
26
28
  "ajv",
27
- "ajv-alternative"
29
+ "ajv-alternative",
30
+ "standard-schema",
31
+ "fastify"
28
32
  ],
29
33
  "author": "Mert Can Altin <mertcanaltin01@gmail.com>",
30
34
  "license": "MIT",
31
35
  "repository": {
32
36
  "type": "git",
33
- "url": "git+https://github.com/mertcanaltin/ata.git"
37
+ "url": "git+https://github.com/mertcanaltin/ata-validator.git"
34
38
  },
35
39
  "bugs": {
36
- "url": "https://github.com/mertcanaltin/ata/issues"
40
+ "url": "https://github.com/mertcanaltin/ata-validator/issues"
37
41
  },
38
- "homepage": "https://github.com/mertcanaltin/ata#readme",
42
+ "homepage": "https://ata-validator.com",
39
43
  "engines": {
40
44
  "node": ">=18.0.0"
41
45
  },
42
46
  "files": [
43
47
  "index.js",
48
+ "index.d.ts",
44
49
  "compat.js",
50
+ "compat.d.ts",
45
51
  "binding.gyp",
46
52
  "binding/",
47
53
  "include/",
@@ -52,11 +58,11 @@
52
58
  "LICENSE"
53
59
  ],
54
60
  "dependencies": {
55
- "node-addon-api": "^8.0.0"
61
+ "node-addon-api": "^8.0.0",
62
+ "node-gyp-build": "^4.8.4"
56
63
  },
57
64
  "devDependencies": {
58
65
  "node-gyp": "^11.0.0",
59
- "node-gyp-build": "^4.8.4",
60
66
  "prebuildify": "^6.0.1"
61
67
  },
62
68
  "gypfile": true