ata-validator 0.13.0 → 0.13.1

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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
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.13.1 — 2026-05-09
6
+
7
+ ### Fixed
8
+
9
+ - **Custom format checkers in `validate()`** are now actually applied. The combined codegen path (used by `Validator#validate` and one-shot `validate()`) silently dropped the `userFormats` argument, so schemas with `format: <user-defined>` returned `{ valid: true }` regardless of the checker function's return value. The boolean (`isValidObject`) and error-only paths were already wired correctly. Fixes RJSF integration where custom formats are routed through `customFormats` (rjsf-team/react-jsonschema-form#5052).
10
+ - **Glob patterns with backslash separators on Windows** now resolve correctly in `ata build`. The Node 18 fallback regex only recognized forward slashes, so `path.join(dir, '*.json')` produced patterns the matcher couldn't parse on `windows-latest` runners.
11
+
5
12
  ## 0.13.0 — 2026-05-09
6
13
 
7
14
  ### Added
package/lib/aot-build.js CHANGED
@@ -8,7 +8,11 @@ const { Validator } = require('..');
8
8
 
9
9
  async function expandGlobs(globs) {
10
10
  const out = [];
11
- for (const g of globs) {
11
+ for (const raw of globs) {
12
+ // Glob patterns use forward slashes; normalize Windows backslashes so the
13
+ // matcher (Node 22+ fs.glob or the fallback regex) sees a consistent
14
+ // separator. Node accepts forward slashes in paths on Windows.
15
+ const g = raw.replace(/\\/g, '/');
12
16
  if (typeof fs.promises.glob === 'function') {
13
17
  // Node 22+
14
18
  for await (const f of fs.promises.glob(g)) out.push(path.resolve(f));
@@ -3001,7 +3001,7 @@ function genCodeE(schema, v, pathExpr, lines, ctx, schemaPrefix) {
3001
3001
  // Returns VALID_RESULT for valid data, {valid:false, errors} for invalid.
3002
3002
  // Avoids double-pass (jsFn → false → errFn runs same checks again).
3003
3003
  // Uses type-aware optimizations: after type check passes, skip guards.
3004
- function compileToJSCombined(schema, VALID_RESULT, schemaMap) {
3004
+ function compileToJSCombined(schema, VALID_RESULT, schemaMap, userFormats) {
3005
3005
  // Bail on unevaluated keywords — combined codegen doesn't support them yet
3006
3006
  if (typeof schema === 'object' && schema !== null) {
3007
3007
  const s = JSON.stringify(schema)
@@ -3063,7 +3063,7 @@ function compileToJSCombined(schema, VALID_RESULT, schemaMap) {
3063
3063
  }
3064
3064
 
3065
3065
  const ctx = { varCounter: 0, helperCode: [], closureVars: ['_cpLen'], closureVals: [_cpLen],
3066
- rootDefs: cRootDefs, refStack: new Set(), schemaMap: schemaMap || null, anchors: cAnchors, rootSchema: schema }
3066
+ rootDefs: cRootDefs, refStack: new Set(), schemaMap: schemaMap || null, anchors: cAnchors, rootSchema: schema, userFormats: userFormats || null }
3067
3067
  const lines = []
3068
3068
  genCodeC(schema, 'd', '', lines, ctx, '#')
3069
3069
  if (lines.length === 0) return () => VALID_RESULT
@@ -3321,6 +3321,15 @@ function genCodeC(schema, v, pathExpr, lines, ctx, schemaPrefix) {
3321
3321
  if (fc) {
3322
3322
  const code = fc(v, isStr).replace(/return false/g, `{${fail('format', 'format', `{format:'${esc(schema.format)}'}`, `'must match format "${esc(schema.format)}"'`)}}`)
3323
3323
  lines.push(code)
3324
+ } else if (ctx.userFormats && typeof ctx.userFormats[schema.format] === 'function') {
3325
+ const safeName = schema.format.replace(/[^a-zA-Z0-9_]/g, '_')
3326
+ const closureName = `_uf_${safeName}`
3327
+ if (!ctx.closureVars.includes(closureName)) {
3328
+ ctx.closureVars.push(closureName)
3329
+ ctx.closureVals.push(ctx.userFormats[schema.format])
3330
+ }
3331
+ const guard = isStr ? '' : `typeof ${v}==='string'&&`
3332
+ lines.push(`if(${guard}!${closureName}(${v})){${fail('format', 'format', `{format:'${esc(schema.format)}'}`, `'must match format "${esc(schema.format)}"'`)}}`)
3324
3333
  }
3325
3334
  }
3326
3335
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ata-validator",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
4
4
  "description": "Ultra-fast JSON Schema validator. 5x faster validation, 159,000x faster compilation. Works without native addon. Cross-schema $ref, Draft 2020-12 + Draft 7, V8-optimized JS codegen, simdjson, RE2, multi-core. Standard Schema V1 compatible.",
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",