ata-validator 0.17.1 → 0.17.2

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 (3) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/index.js +23 -0
  3. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to ata-validator are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/), and this project adheres to semantic versioning.
4
4
 
5
+ ## 0.17.2 - 2026-05-24
6
+
7
+ ### Fixed
8
+
9
+ - `validate()` now returns the typed `data` on success, the validated input after any in-place coercion or defaults. The `ValidationResult<T>` type has carried `data: T` since 0.17.0, but the runtime never populated it, so `result.data` was `undefined`. `isValidObject()` and `abortEarly` stay allocation-free for callers that only need a boolean.
10
+
5
11
  ## 0.17.1 - 2026-05-24
6
12
 
7
13
  ### Fixed
package/index.js CHANGED
@@ -1055,6 +1055,20 @@ class Validator {
1055
1055
  }
1056
1056
  }
1057
1057
 
1058
+ // validate() resolves a typed `data` on success: the validated input, after
1059
+ // any in-place coercion/defaults. This matches the ValidationResult<T>
1060
+ // contract. isValidObject() and abortEarly stay allocation-free for hot
1061
+ // paths that only need a boolean.
1062
+ if (this.validate) {
1063
+ const _bare = this.validate;
1064
+ this.validate = (data) => {
1065
+ const r = _bare(data);
1066
+ return (r.valid === true && r.data === undefined)
1067
+ ? { valid: true, data, errors: r.errors }
1068
+ : r;
1069
+ };
1070
+ }
1071
+
1058
1072
  // Save to identity cache for ultra-fast reuse with same schema object
1059
1073
  if (this._schemaObj && typeof this._schemaObj === 'object') {
1060
1074
  _identityCache.set(this._schemaObj, this);
@@ -1325,6 +1339,15 @@ ${exports}`;
1325
1339
  return mod.boolFn(data) ? VALID_RESULT : errFn(data);
1326
1340
  }
1327
1341
  : (data) => (mod.boolFn(data) ? VALID_RESULT : errFn(data));
1342
+ {
1343
+ const _bare = v.validate;
1344
+ v.validate = (data) => {
1345
+ const r = _bare(data);
1346
+ return (r.valid === true && r.data === undefined)
1347
+ ? { valid: true, data, errors: r.errors }
1348
+ : r;
1349
+ };
1350
+ }
1328
1351
  v.isValidObject = mod.boolFn;
1329
1352
  v.isValidJSON = (jsonStr) => {
1330
1353
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ata-validator",
3
- "version": "0.17.1",
3
+ "version": "0.17.2",
4
4
  "description": "JSON Schema validation with first-class TypeScript and zero runtime cost. AOT compile to per-schema ESM modules with zero validator dependency. Generic Validator<T> for TypeBox/Zod/Valibot composition. Optional runtime API. Standard Schema V1 compatible.",
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -42,7 +42,7 @@
42
42
  "rebuild": "cmake-js rebuild --target ata",
43
43
  "prebuild": "pkg-prebuilds-copy --baseDir build/Release --source ata.node --name=ata --strip --napi_version=10",
44
44
  "prebuild-all": "npm run prebuild -- --arch x64 && npm run prebuild -- --arch arm64",
45
- "test": "node test.js && node tests/test_no_native.js && node tests/test_aot_build.js && node tests/test_aot_differential.js && node tests/test_aot_cli_build.js && node tests/test_aot_cli_smoke.js && node tests/test_bundle_standalone.js && node tests/test_standalone_anyof.js && node tests/test_typed_validator_runner.js && node tests/test_define_schema.js && node tests/test_error_codes_lock.js && node tests/test_nullable.js && node tests/test_validate_and_parse.js && node tests/test_enrich_error.js && node tests/test_rich_errors_optout.js && node tests/test_source_positions.js && node tests/fuzz_positions.js && node tests/test_data_positions.js && node tests/test_render_shared.js && node tests/test_renderers.js && node tests/test_runtime_error_dx.js && node tests/test_aot_error_dx.js && node tests/test_abort_early.js && node tests/test_branch_collapse.js && node tests/test_suggestions.js && node tests/test_cli_validate.js && node benchmark/bench_aot_size.mjs",
45
+ "test": "node test.js && node tests/test_no_native.js && node tests/test_aot_build.js && node tests/test_aot_differential.js && node tests/test_aot_cli_build.js && node tests/test_aot_cli_smoke.js && node tests/test_bundle_standalone.js && node tests/test_standalone_anyof.js && node tests/test_typed_validator_runner.js && node tests/test_define_schema.js && node tests/test_error_codes_lock.js && node tests/test_nullable.js && node tests/test_validate_and_parse.js && node tests/test_validate_data.js && node tests/test_enrich_error.js && node tests/test_rich_errors_optout.js && node tests/test_source_positions.js && node tests/fuzz_positions.js && node tests/test_data_positions.js && node tests/test_render_shared.js && node tests/test_renderers.js && node tests/test_runtime_error_dx.js && node tests/test_aot_error_dx.js && node tests/test_abort_early.js && node tests/test_branch_collapse.js && node tests/test_suggestions.js && node tests/test_cli_validate.js && node benchmark/bench_aot_size.mjs",
46
46
  "bench:size": "node benchmark/bench_aot_size.mjs",
47
47
  "test:suite": "node tests/run_suite.js",
48
48
  "test:compat": "node tests/test_compat.js",