ata-validator 0.12.3 → 0.12.4

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/index.d.ts +42 -3
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -4,8 +4,17 @@ export interface ValidationError {
4
4
  schemaPath: string;
5
5
  params: Record<string, unknown>;
6
6
  message: string;
7
+ /**
8
+ * The schema object that owns the failing keyword. Populated only when the
9
+ * Validator was constructed with `verbose: true`. Matches ajv's `verbose`
10
+ * behavior.
11
+ */
12
+ parentSchema?: object;
7
13
  }
8
14
 
15
+ /** A user-supplied format checker. Receives the candidate value, returns true if valid. */
16
+ export type FormatChecker = (value: string) => boolean;
17
+
9
18
  export interface ValidationResult {
10
19
  valid: boolean;
11
20
  errors: ValidationError[];
@@ -21,6 +30,26 @@ export interface ValidatorOptions {
21
30
  coerceTypes?: boolean;
22
31
  removeAdditional?: boolean;
23
32
  schemas?: Record<string, object> | object[];
33
+ /**
34
+ * Custom format checkers. Keys are format names referenced from `format` in
35
+ * the schema. Values are functions that return true when the input is valid.
36
+ */
37
+ formats?: Record<string, FormatChecker>;
38
+ /**
39
+ * When true, validation errors include `parentSchema` (the schema object
40
+ * that produced the error). Matches ajv's `verbose: true`.
41
+ */
42
+ verbose?: boolean;
43
+ /**
44
+ * When true, validate() returns a shared frozen result on the first failure
45
+ * instead of collecting full error details. Smaller hot-path allocation.
46
+ */
47
+ abortEarly?: boolean;
48
+ }
49
+
50
+ export interface BundleStandaloneOptions extends ValidatorOptions {
51
+ /** Module format for the emitted bundle. Default: 'cjs'. */
52
+ format?: 'esm' | 'cjs';
24
53
  }
25
54
 
26
55
  export interface StandardSchemaV1Props {
@@ -30,7 +59,13 @@ export interface StandardSchemaV1Props {
30
59
  value: unknown
31
60
  ):
32
61
  | { value: unknown }
33
- | { issues: Array<{ message: string; path?: ReadonlyArray<{ key: PropertyKey }> }> };
62
+ | {
63
+ issues: Array<{
64
+ message: string;
65
+ /** Array indices are emitted as numbers, object keys as strings. */
66
+ path?: ReadonlyArray<{ key: PropertyKey }>;
67
+ }>;
68
+ };
34
69
  }
35
70
 
36
71
  export interface StandaloneModule {
@@ -98,8 +133,12 @@ export class Validator {
98
133
  /** Bundle multiple schemas into a single JS module string. Load with Validator.loadBundle(). */
99
134
  static bundle(schemas: object[], options?: ValidatorOptions): string;
100
135
 
101
- /** Bundle multiple schemas into a self-contained JS module. No ata-validator import needed at runtime. */
102
- static bundleStandalone(schemas: object[], options?: ValidatorOptions): string;
136
+ /**
137
+ * Bundle multiple schemas into a self-contained JS module with no
138
+ * ata-validator runtime dependency. Cross-schema `$ref` resolves between
139
+ * the supplied schemas. Set `format: 'esm'` for ESM output (default 'cjs').
140
+ */
141
+ static bundleStandalone(schemas: object[], options?: BundleStandaloneOptions): string;
103
142
 
104
143
  /** Bundle multiple schemas with deduplicated shared templates. Smaller output than bundle(). */
105
144
  static bundleCompact(schemas: object[], options?: ValidatorOptions): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ata-validator",
3
- "version": "0.12.3",
3
+ "version": "0.12.4",
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",