@jarenjs/validate 0.8.4 → 0.34.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.
Files changed (53) hide show
  1. package/ARCHITECTURE.md +1131 -0
  2. package/LICENSE +21 -0
  3. package/README.md +796 -2
  4. package/dist/types/array.d.ts +2 -0
  5. package/dist/types/bigint.d.ts +1 -0
  6. package/dist/types/combine.d.ts +1 -0
  7. package/dist/types/condition.d.ts +1 -0
  8. package/dist/types/content.d.ts +3 -0
  9. package/dist/types/data.d.ts +7 -0
  10. package/dist/types/dollar-data.d.ts +11 -0
  11. package/dist/types/dynamic-ref.d.ts +44 -0
  12. package/dist/types/enum.d.ts +1 -0
  13. package/dist/types/format.d.ts +21 -0
  14. package/dist/types/index.d.ts +972 -0
  15. package/dist/types/messages.d.ts +142 -0
  16. package/dist/types/normalize.d.ts +107 -0
  17. package/dist/types/number.d.ts +1 -0
  18. package/dist/types/object.d.ts +3 -0
  19. package/dist/types/query-keyword.d.ts +19 -0
  20. package/dist/types/query.d.ts +29 -0
  21. package/dist/types/schema.d.ts +1 -0
  22. package/dist/types/string.d.ts +1 -0
  23. package/dist/types/tools.d.ts +109 -0
  24. package/dist/types/traverse.d.ts +32 -0
  25. package/dist/types/unevaluated.d.ts +12 -0
  26. package/docs/ERROR-MESSAGES.md +251 -0
  27. package/package.json +37 -7
  28. package/src/array.js +610 -0
  29. package/src/bigint.js +108 -0
  30. package/src/combine.js +276 -0
  31. package/src/condition.js +129 -0
  32. package/src/content.js +83 -0
  33. package/src/data.js +101 -0
  34. package/src/dollar-data.js +212 -0
  35. package/src/dynamic-ref.js +121 -0
  36. package/src/enum.js +147 -0
  37. package/src/format.js +108 -0
  38. package/src/index.js +1896 -0
  39. package/src/messages.js +497 -0
  40. package/src/normalize.js +585 -0
  41. package/src/number.js +169 -0
  42. package/src/object.js +848 -0
  43. package/src/query-keyword.js +99 -0
  44. package/src/query.js +85 -0
  45. package/src/schema.js +690 -0
  46. package/src/string.js +164 -0
  47. package/src/tools.js +397 -0
  48. package/src/traverse.js +442 -0
  49. package/src/unevaluated.js +173 -0
  50. package/dist/index.js +0 -1998
  51. package/dist/index.js.map +0 -7
  52. package/dist/index.min.js +0 -2
  53. package/dist/index.min.js.map +0 -7
@@ -0,0 +1,972 @@
1
+ import { TraverseOptions } from './traverse.js';
2
+ import { EvalLog } from './tools.js';
3
+ export { registerFormatCompilers } from './format.js';
4
+ export { ValidationError, messagesEn, compileMessageTemplate, compileMessageCatalog, renderErrorMessage, localizeErrors, } from './messages.js';
5
+ export { TraverseOptions };
6
+ export type DollarDataRef = {
7
+ /**
8
+ * - Relative JSON Pointer resolved from the current data location
9
+ */
10
+ $data: string;
11
+ };
12
+ export type DataKeywordSchema = {
13
+ /**
14
+ * - JSON Pointer to the minimum value
15
+ */
16
+ minimum?: string;
17
+ /**
18
+ * - JSON Pointer to the maximum value
19
+ */
20
+ maximum?: string;
21
+ /**
22
+ * - JSON Pointer to the exclusive minimum value
23
+ */
24
+ exclusiveMinimum?: string;
25
+ /**
26
+ * - JSON Pointer to the exclusive maximum value
27
+ */
28
+ exclusiveMaximum?: string;
29
+ /**
30
+ * - JSON Pointer to the multipleOf value
31
+ */
32
+ multipleOf?: string;
33
+ /**
34
+ * - JSON Pointer to the minLength value
35
+ */
36
+ minLength?: string;
37
+ /**
38
+ * - JSON Pointer to the maxLength value
39
+ */
40
+ maxLength?: string;
41
+ /**
42
+ * - JSON Pointer to the pattern string
43
+ */
44
+ pattern?: string;
45
+ /**
46
+ * - JSON Pointer to the format name
47
+ */
48
+ format?: string;
49
+ /**
50
+ * - JSON Pointer to an array of valid values
51
+ */
52
+ enum?: string;
53
+ /**
54
+ * - JSON Pointer to the constant value
55
+ */
56
+ const?: string;
57
+ /**
58
+ * - JSON Pointer to the minItems value
59
+ */
60
+ minItems?: string;
61
+ /**
62
+ * - JSON Pointer to the maxItems value
63
+ */
64
+ maxItems?: string;
65
+ /**
66
+ * - JSON Pointer to the minProperties value
67
+ */
68
+ minProperties?: string;
69
+ /**
70
+ * - JSON Pointer to the maxProperties value
71
+ */
72
+ maxProperties?: string;
73
+ };
74
+ export type JSONSchemaKeywords = {
75
+ /**
76
+ * - Schema resource identifier (URI)
77
+ */
78
+ $id?: string;
79
+ /**
80
+ * - Meta-schema URI declaring the draft dialect
81
+ */
82
+ $schema?: string;
83
+ /**
84
+ * - Reference to another schema (URI reference)
85
+ */
86
+ $ref?: string;
87
+ /**
88
+ * - Plain-name fragment identifier (2019-09+)
89
+ */
90
+ $anchor?: string;
91
+ /**
92
+ * - Dynamic reference (2020-12)
93
+ */
94
+ $dynamicRef?: string;
95
+ /**
96
+ * - Dynamic anchor (2020-12)
97
+ */
98
+ $dynamicAnchor?: string;
99
+ /**
100
+ * - Vocabulary declarations of a meta-schema
101
+ */
102
+ $vocabulary?: Record<string, boolean>;
103
+ /**
104
+ * - Comment for schema maintainers; not used in validation
105
+ */
106
+ $comment?: string;
107
+ /**
108
+ * - Reusable subschema definitions (2019-09+)
109
+ */
110
+ $defs?: Record<string, JSONSchema>;
111
+ /**
112
+ * - Reusable subschema definitions (draft-07 and earlier)
113
+ */
114
+ definitions?: Record<string, JSONSchema>;
115
+ /**
116
+ * - Expected JSON type(s): 'null', 'boolean', 'object', 'array', 'number', 'string' or 'integer'
117
+ */
118
+ type?: string | string[];
119
+ /**
120
+ * - Exhaustive list of valid values
121
+ */
122
+ enum?: unknown[] | DollarDataRef;
123
+ /**
124
+ * - Single valid value
125
+ */
126
+ const?: unknown | DollarDataRef;
127
+ /**
128
+ * - Minimum string length (in graphemes by default)
129
+ */
130
+ minLength?: number | DollarDataRef;
131
+ /**
132
+ * - Maximum string length (in graphemes by default)
133
+ */
134
+ maxLength?: number | DollarDataRef;
135
+ /**
136
+ * - ECMA-262 regular expression the string must match
137
+ */
138
+ pattern?: string | DollarDataRef;
139
+ /**
140
+ * - Encoding of a string-embedded document (e.g. 'base64')
141
+ */
142
+ contentEncoding?: string;
143
+ /**
144
+ * - Media type of a string-embedded document
145
+ */
146
+ contentMediaType?: string;
147
+ /**
148
+ * - Schema for the decoded string-embedded document
149
+ */
150
+ contentSchema?: JSONSchema;
151
+ /**
152
+ * - Number must be a multiple of this value
153
+ */
154
+ multipleOf?: number | DollarDataRef;
155
+ /**
156
+ * - Inclusive lower bound
157
+ */
158
+ minimum?: number | DollarDataRef;
159
+ /**
160
+ * - Inclusive upper bound
161
+ */
162
+ maximum?: number | DollarDataRef;
163
+ /**
164
+ * - Exclusive lower bound (boolean form in draft-04 style schemas)
165
+ */
166
+ exclusiveMinimum?: number | boolean | DollarDataRef;
167
+ /**
168
+ * - Exclusive upper bound (boolean form in draft-04 style schemas)
169
+ */
170
+ exclusiveMaximum?: number | boolean | DollarDataRef;
171
+ /**
172
+ * - Schemas for named object members
173
+ */
174
+ properties?: Record<string, JSONSchema>;
175
+ /**
176
+ * - Schemas for members whose name matches a regular expression
177
+ */
178
+ patternProperties?: Record<string, JSONSchema>;
179
+ /**
180
+ * - Schema for members not matched by properties/patternProperties
181
+ */
182
+ additionalProperties?: boolean | JSONSchema;
183
+ /**
184
+ * - Schema for members not evaluated by any subschema (2019-09+)
185
+ */
186
+ unevaluatedProperties?: boolean | JSONSchema;
187
+ /**
188
+ * - Member names that must be present
189
+ */
190
+ required?: string[] | DollarDataRef;
191
+ /**
192
+ * - Schema every member name must validate against
193
+ */
194
+ propertyNames?: JSONSchema;
195
+ /**
196
+ * - Minimum number of members
197
+ */
198
+ minProperties?: number | DollarDataRef;
199
+ /**
200
+ * - Maximum number of members
201
+ */
202
+ maxProperties?: number | DollarDataRef;
203
+ /**
204
+ * - Schema for array elements (array form is the draft-07 tuple syntax)
205
+ */
206
+ items?: JSONSchema | JSONSchema[];
207
+ /**
208
+ * - Tuple element schemas (2020-12)
209
+ */
210
+ prefixItems?: JSONSchema[];
211
+ /**
212
+ * - Schema for elements beyond the tuple prefix (draft-07 and earlier)
213
+ */
214
+ additionalItems?: boolean | JSONSchema;
215
+ /**
216
+ * - Schema for elements not evaluated by any subschema (2019-09+)
217
+ */
218
+ unevaluatedItems?: boolean | JSONSchema;
219
+ /**
220
+ * - At least one element must validate against this schema
221
+ */
222
+ contains?: JSONSchema;
223
+ /**
224
+ * - Minimum number of elements
225
+ */
226
+ minItems?: number | DollarDataRef;
227
+ /**
228
+ * - Maximum number of elements
229
+ */
230
+ maxItems?: number | DollarDataRef;
231
+ /**
232
+ * - Whether all elements must be unique
233
+ */
234
+ uniqueItems?: boolean | DollarDataRef;
235
+ /**
236
+ * - Minimum number of elements matching 'contains' (2019-09+)
237
+ */
238
+ minContains?: number;
239
+ /**
240
+ * - Maximum number of elements matching 'contains' (2019-09+)
241
+ */
242
+ maxContains?: number;
243
+ /**
244
+ * - Value must validate against all of these schemas
245
+ */
246
+ allOf?: JSONSchema[];
247
+ /**
248
+ * - Value must validate against at least one of these schemas
249
+ */
250
+ anyOf?: JSONSchema[];
251
+ /**
252
+ * - Value must validate against exactly one of these schemas
253
+ */
254
+ oneOf?: JSONSchema[];
255
+ /**
256
+ * - Value must NOT validate against this schema
257
+ */
258
+ not?: JSONSchema;
259
+ /**
260
+ * - Condition schema selecting between 'then' and 'else'
261
+ */
262
+ if?: JSONSchema;
263
+ /**
264
+ * - Applied when 'if' validates
265
+ */
266
+ then?: JSONSchema;
267
+ /**
268
+ * - Applied when 'if' does not validate
269
+ */
270
+ else?: JSONSchema;
271
+ /**
272
+ * - Schemas applied when a member is present (2019-09+)
273
+ */
274
+ dependentSchemas?: Record<string, JSONSchema>;
275
+ /**
276
+ * - Members required when a member is present (2019-09+)
277
+ */
278
+ dependentRequired?: Record<string, string[]>;
279
+ /**
280
+ * - Short descriptive title
281
+ */
282
+ title?: string;
283
+ /**
284
+ * - Explanation of the schema's purpose
285
+ */
286
+ description?: string;
287
+ /**
288
+ * - Default value annotation
289
+ */
290
+ default?: unknown;
291
+ /**
292
+ * - Example values annotation
293
+ */
294
+ examples?: unknown[];
295
+ /**
296
+ * - Value is managed by the receiving authority
297
+ */
298
+ readOnly?: boolean;
299
+ /**
300
+ * - Value is never returned by the receiving authority
301
+ */
302
+ writeOnly?: boolean;
303
+ /**
304
+ * - Value is deprecated
305
+ */
306
+ deprecated?: boolean;
307
+ /**
308
+ * - Named semantic format (e.g. 'email', 'uri', 'date-time')
309
+ */
310
+ format?: string | DollarDataRef;
311
+ /**
312
+ * - Format-aware inclusive lower bound (non-standard, Ajv-style)
313
+ */
314
+ formatMinimum?: string;
315
+ /**
316
+ * - Format-aware inclusive upper bound (non-standard, Ajv-style)
317
+ */
318
+ formatMaximum?: string;
319
+ /**
320
+ * - Format-aware exclusive lower bound (non-standard, Ajv-style)
321
+ */
322
+ formatExclusiveMinimum?: string;
323
+ /**
324
+ * - Format-aware exclusive upper bound (non-standard, Ajv-style)
325
+ */
326
+ formatExclusiveMaximum?: string;
327
+ /**
328
+ * - Data keyword referencing instance data (json-everything style)
329
+ */
330
+ data?: DataKeywordSchema;
331
+ };
332
+ export type JSONSchema = JSONSchemaKeywords & Record<string, unknown>;
333
+ export type FormatCompiler = (schemaObj: ValidationObject, jsonSchema: JSONSchema & {
334
+ format?: string;
335
+ }) => ((data: unknown, dataPath?: string) => boolean) | undefined;
336
+ /**
337
+ * Ajv-style $data reference object.
338
+ * The value is a Relative JSON Pointer that resolves from the current data location.
339
+ * Format: `<non-negative-integer>("#"|<json-pointer>)`
340
+ * - "0" - The current value itself
341
+ * - "0#" - The property name/index of the current value
342
+ * - "0/foo" - The "foo" property of the current value
343
+ * - "1" - The parent value
344
+ * - "1/foo" - The "foo" property of the parent value
345
+ * @see https://github.com/ajv-validator/ajv/tree/master/spec/extras/%24data
346
+ * @typedef {Object} DollarDataRef
347
+ * @property {string} $data - Relative JSON Pointer resolved from the current data location
348
+ */
349
+ /**
350
+ * Data keyword schema for referencing instance data (json-everything style).
351
+ * Allows constraints to reference values from other parts of the instance;
352
+ * every property value is a (relative) JSON Pointer to the constraint's value.
353
+ * @see https://docs.json-everything.net/schema/examples/data-ref/
354
+ * @typedef {Object} DataKeywordSchema
355
+ * @property {string} [minimum] - JSON Pointer to the minimum value
356
+ * @property {string} [maximum] - JSON Pointer to the maximum value
357
+ * @property {string} [exclusiveMinimum] - JSON Pointer to the exclusive minimum value
358
+ * @property {string} [exclusiveMaximum] - JSON Pointer to the exclusive maximum value
359
+ * @property {string} [multipleOf] - JSON Pointer to the multipleOf value
360
+ * @property {string} [minLength] - JSON Pointer to the minLength value
361
+ * @property {string} [maxLength] - JSON Pointer to the maxLength value
362
+ * @property {string} [pattern] - JSON Pointer to the pattern string
363
+ * @property {string} [format] - JSON Pointer to the format name
364
+ * @property {string} [enum] - JSON Pointer to an array of valid values
365
+ * @property {string} [const] - JSON Pointer to the constant value
366
+ * @property {string} [minItems] - JSON Pointer to the minItems value
367
+ * @property {string} [maxItems] - JSON Pointer to the maxItems value
368
+ * @property {string} [minProperties] - JSON Pointer to the minProperties value
369
+ * @property {string} [maxProperties] - JSON Pointer to the maxProperties value
370
+ */
371
+ /**
372
+ * The standard JSON Schema keywords understood by Jaren
373
+ * (draft-06 through draft 2020-12). See {@link JSONSchema} for the full
374
+ * schema object type that also permits custom keywords.
375
+ * @typedef {Object} JSONSchemaKeywords
376
+ * @property {string} [$id] - Schema resource identifier (URI)
377
+ * @property {string} [$schema] - Meta-schema URI declaring the draft dialect
378
+ * @property {string} [$ref] - Reference to another schema (URI reference)
379
+ * @property {string} [$anchor] - Plain-name fragment identifier (2019-09+)
380
+ * @property {string} [$dynamicRef] - Dynamic reference (2020-12)
381
+ * @property {string} [$dynamicAnchor] - Dynamic anchor (2020-12)
382
+ * @property {Record<string, boolean>} [$vocabulary] - Vocabulary declarations of a meta-schema
383
+ * @property {string} [$comment] - Comment for schema maintainers; not used in validation
384
+ * @property {Record<string, JSONSchema>} [$defs] - Reusable subschema definitions (2019-09+)
385
+ * @property {Record<string, JSONSchema>} [definitions] - Reusable subschema definitions (draft-07 and earlier)
386
+ * @property {string | string[]} [type] - Expected JSON type(s): 'null', 'boolean', 'object', 'array', 'number', 'string' or 'integer'
387
+ * @property {unknown[] | DollarDataRef} [enum] - Exhaustive list of valid values
388
+ * @property {unknown | DollarDataRef} [const] - Single valid value
389
+ * @property {number | DollarDataRef} [minLength] - Minimum string length (in graphemes by default)
390
+ * @property {number | DollarDataRef} [maxLength] - Maximum string length (in graphemes by default)
391
+ * @property {string | DollarDataRef} [pattern] - ECMA-262 regular expression the string must match
392
+ * @property {string} [contentEncoding] - Encoding of a string-embedded document (e.g. 'base64')
393
+ * @property {string} [contentMediaType] - Media type of a string-embedded document
394
+ * @property {JSONSchema} [contentSchema] - Schema for the decoded string-embedded document
395
+ * @property {number | DollarDataRef} [multipleOf] - Number must be a multiple of this value
396
+ * @property {number | DollarDataRef} [minimum] - Inclusive lower bound
397
+ * @property {number | DollarDataRef} [maximum] - Inclusive upper bound
398
+ * @property {number | boolean | DollarDataRef} [exclusiveMinimum] - Exclusive lower bound (boolean form in draft-04 style schemas)
399
+ * @property {number | boolean | DollarDataRef} [exclusiveMaximum] - Exclusive upper bound (boolean form in draft-04 style schemas)
400
+ * @property {Record<string, JSONSchema>} [properties] - Schemas for named object members
401
+ * @property {Record<string, JSONSchema>} [patternProperties] - Schemas for members whose name matches a regular expression
402
+ * @property {boolean | JSONSchema} [additionalProperties] - Schema for members not matched by properties/patternProperties
403
+ * @property {boolean | JSONSchema} [unevaluatedProperties] - Schema for members not evaluated by any subschema (2019-09+)
404
+ * @property {string[] | DollarDataRef} [required] - Member names that must be present
405
+ * @property {JSONSchema} [propertyNames] - Schema every member name must validate against
406
+ * @property {number | DollarDataRef} [minProperties] - Minimum number of members
407
+ * @property {number | DollarDataRef} [maxProperties] - Maximum number of members
408
+ * @property {JSONSchema | JSONSchema[]} [items] - Schema for array elements (array form is the draft-07 tuple syntax)
409
+ * @property {JSONSchema[]} [prefixItems] - Tuple element schemas (2020-12)
410
+ * @property {boolean | JSONSchema} [additionalItems] - Schema for elements beyond the tuple prefix (draft-07 and earlier)
411
+ * @property {boolean | JSONSchema} [unevaluatedItems] - Schema for elements not evaluated by any subschema (2019-09+)
412
+ * @property {JSONSchema} [contains] - At least one element must validate against this schema
413
+ * @property {number | DollarDataRef} [minItems] - Minimum number of elements
414
+ * @property {number | DollarDataRef} [maxItems] - Maximum number of elements
415
+ * @property {boolean | DollarDataRef} [uniqueItems] - Whether all elements must be unique
416
+ * @property {number} [minContains] - Minimum number of elements matching 'contains' (2019-09+)
417
+ * @property {number} [maxContains] - Maximum number of elements matching 'contains' (2019-09+)
418
+ * @property {JSONSchema[]} [allOf] - Value must validate against all of these schemas
419
+ * @property {JSONSchema[]} [anyOf] - Value must validate against at least one of these schemas
420
+ * @property {JSONSchema[]} [oneOf] - Value must validate against exactly one of these schemas
421
+ * @property {JSONSchema} [not] - Value must NOT validate against this schema
422
+ * @property {JSONSchema} [if] - Condition schema selecting between 'then' and 'else'
423
+ * @property {JSONSchema} [then] - Applied when 'if' validates
424
+ * @property {JSONSchema} [else] - Applied when 'if' does not validate
425
+ * @property {Record<string, JSONSchema>} [dependentSchemas] - Schemas applied when a member is present (2019-09+)
426
+ * @property {Record<string, string[]>} [dependentRequired] - Members required when a member is present (2019-09+)
427
+ * @property {string} [title] - Short descriptive title
428
+ * @property {string} [description] - Explanation of the schema's purpose
429
+ * @property {unknown} [default] - Default value annotation
430
+ * @property {unknown[]} [examples] - Example values annotation
431
+ * @property {boolean} [readOnly] - Value is managed by the receiving authority
432
+ * @property {boolean} [writeOnly] - Value is never returned by the receiving authority
433
+ * @property {boolean} [deprecated] - Value is deprecated
434
+ * @property {string | DollarDataRef} [format] - Named semantic format (e.g. 'email', 'uri', 'date-time')
435
+ * @property {string} [formatMinimum] - Format-aware inclusive lower bound (non-standard, Ajv-style)
436
+ * @property {string} [formatMaximum] - Format-aware inclusive upper bound (non-standard, Ajv-style)
437
+ * @property {string} [formatExclusiveMinimum] - Format-aware exclusive lower bound (non-standard, Ajv-style)
438
+ * @property {string} [formatExclusiveMaximum] - Format-aware exclusive upper bound (non-standard, Ajv-style)
439
+ * @property {DataKeywordSchema} [data] - Data keyword referencing instance data (json-everything style)
440
+ */
441
+ /**
442
+ * Represents a JSON Schema object.
443
+ * Covers the standard keywords of drafts 06, 07, 2019-09 and 2020-12
444
+ * (see {@link JSONSchemaKeywords}) while remaining open for custom
445
+ * keywords: any property outside the standard set is permitted.
446
+ * Note that a complete schema is `JSONSchema | boolean` - the boolean
447
+ * forms accept everything (`true`) or nothing (`false`).
448
+ * @typedef {JSONSchemaKeywords & Record<string, unknown>} JSONSchema
449
+ */
450
+ /**
451
+ * A format compiler function.
452
+ * Called once per schema location at compile time with the compiling
453
+ * ValidationObject and the schema that declares the format; returns the
454
+ * format validator that is invoked for each instance value, or undefined
455
+ * when the format does not apply to the schema location. Compilers are
456
+ * only invoked for schemas whose `format` member is a plain string.
457
+ * @typedef {(schemaObj: ValidationObject, jsonSchema: JSONSchema & {format?: string}) => ((data: unknown, dataPath?: string) => boolean) | undefined} FormatCompiler
458
+ */
459
+ export declare const DEFAULT_SCHEMA_DRAFT = "http://json-schema.org/draft-06/schema#";
460
+ /**
461
+ * Detects the JSON Schema draft version from the schema's $schema property
462
+ * @param {object} schema - The JSON schema
463
+ * @returns {number} - The draft version (6, 7, 2019, or 2020)
464
+ */
465
+ export declare function detectSchemaDraft(schema: object): number;
466
+ declare class InternalValidationError {
467
+ timeStamp: any;
468
+ object: any;
469
+ key: any;
470
+ expected: any;
471
+ dataKey: any;
472
+ value: any;
473
+ rest: any;
474
+ constructor(obj: any, key: any, expected: any, dataKey: any, value: any, rest: any);
475
+ }
476
+ /**
477
+ * ValidationOptions configures the behavior of the validation process.
478
+ * @class
479
+ */
480
+ export declare class ValidationOptions {
481
+ /** @type {boolean} Whether to stop at first error or continue */
482
+ skipErrors: boolean;
483
+ /** @type {boolean} Whether to use grapheme cluster counting for string length */
484
+ useGrapheme: boolean;
485
+ /** @type {boolean} Whether to collect and return detailed errors */
486
+ collectErrors: boolean;
487
+ /** @type {boolean|null} Whether to validate contentEncoding/contentMediaType (null = auto based on draft) */
488
+ contentValidation: boolean | null;
489
+ /** @type {number} The JSON Schema draft version (6, 7, 2019, or 2020) */
490
+ draftVersion: number;
491
+ /** @type {boolean} Whether validation vocabulary keywords (type, minimum, ...) are asserted */
492
+ vocabValidation: boolean;
493
+ /** @type {boolean|null} Whether the format keyword asserts (null = auto by draft) */
494
+ formatAssertion: boolean | null;
495
+ /** @type {boolean} Whether collected errors carry rendered message text */
496
+ messages: boolean;
497
+ /** @type {'error'|'ignore'} What an asserting `format` with no registered compiler does */
498
+ unknownFormats: 'error' | 'ignore';
499
+ /**
500
+ * Creates validation options.
501
+ * @param {boolean} [skipErrors=true] - Whether to stop at first error or continue
502
+ * @param {boolean} [useGrapheme=true] - Whether to use grapheme cluster counting for strings
503
+ * @param {boolean} [collectErrors=false] - Whether to collect all errors or just return boolean
504
+ * @param {boolean|null} [contentValidation=null] - Whether to validate contentEncoding/contentMediaType (null = auto based on draft)
505
+ * @param {number} [draftVersion=7] - The JSON Schema draft version (6, 7, 2019, or 2020)
506
+ * @param {boolean} [vocabValidation=true] - Whether the validation vocabulary is enabled (false when the schema's metaschema omits it via $vocabulary)
507
+ * @param {boolean|null} [formatAssertion=null] - Whether format asserts (null = auto: asserts below draft 2020-12, annotation-only from 2020-12 on)
508
+ * @param {boolean} [messages=true] - Whether collected errors carry rendered message text; false skips rendering (message: '', params/msgid still set)
509
+ * @param {'error'|'ignore'} [unknownFormats='ignore'] - What to do when an ASSERTING `format` names something no compiler is registered for: 'ignore' (the default, and what the specification requires) accepts it as an annotation; 'error' throws at COMPILE time. Never affects instance validation, and never applies where format is annotation-only anyway.
510
+ */
511
+ constructor(skipErrors?: boolean, useGrapheme?: boolean, collectErrors?: boolean, contentValidation?: boolean | null, draftVersion?: number, vocabValidation?: boolean, formatAssertion?: boolean | null, messages?: boolean, unknownFormats?: 'error' | 'ignore');
512
+ }
513
+ /**
514
+ * ValidationRoot manages the compilation and validation context for a schema.
515
+ * It holds references to all schemas, formats, options, and compiled ValidationObjects.
516
+ * @class
517
+ */
518
+ export declare class ValidationRoot {
519
+ #private;
520
+ /**
521
+ * Creates a new ValidationRoot.
522
+ * @param {string} origin - The root schema origin/URI
523
+ * @param {Map} schemas - Map of schema paths to schema objects
524
+ * @param {Record<string, FormatCompiler>} formats - Registered format validators
525
+ * @param {ValidationOptions} [opts] - Validation options
526
+ * @param {TraverseOptions} [traverse] - Schema traversal options
527
+ * @param {object|null} [owner] - The owning JarenValidator instance; extension
528
+ * keywords ('$query') compile embedded schema literals against it so their
529
+ * `$ref`s resolve to the owner's `addSchema` registrations
530
+ */
531
+ constructor(origin: string, schemas: Map<any, any>, formats: Record<string, FormatCompiler>, opts?: ValidationOptions, traverse?: TraverseOptions, owner?: object | null);
532
+ /** @returns {TraverseOptions} Schema traversal options */
533
+ get traverse(): TraverseOptions;
534
+ /** @returns {ValidationOptions} Validation options */
535
+ get options(): ValidationOptions;
536
+ /** @returns {object} Registered format validators */
537
+ get formats(): object;
538
+ /** @returns {Array} Array of validation errors */
539
+ get errors(): any[];
540
+ /** @returns {boolean} Whether any schema in this compilation contains a $data reference */
541
+ get usesDollarData(): boolean;
542
+ /** @returns {boolean} Whether any schema in this compilation contains unevaluatedProperties/unevaluatedItems */
543
+ get usesUnevaluated(): boolean;
544
+ /** @returns {EvalLog} The evaluation log for unevaluated* annotation tracking */
545
+ get evalLog(): EvalLog;
546
+ /** @returns {object|null} The owning JarenValidator instance, or null when constructed standalone */
547
+ get owner(): object | null;
548
+ /** @returns {Map<string, object>|null} Compiled 'errorMessage' specs by schema path, or null when the schema set has none */
549
+ get errorMessages(): Map<string, object> | null;
550
+ /**
551
+ * Register a compiled 'errorMessage' spec for a schema location.
552
+ * Called at schema compile time (see compileSchemaObject); the registry
553
+ * is only consulted at report time, over the already-failed set.
554
+ * @param {string} path - The schema path (ValidationObject.path)
555
+ * @param {object} spec - The compiled spec (see messages.js compileErrorMessageSpec)
556
+ */
557
+ registerErrorMessage(path: string, spec: object): void;
558
+ /**
559
+ * Creates a new ValidationObject for the given path and schema.
560
+ * @param {string} path - The URI path for this schema object
561
+ * @param {object|boolean} schema - The JSON schema
562
+ * @param {string} baseUri - The base URI for resolving relative refs
563
+ * @returns {ValidationObject} The created ValidationObject
564
+ */
565
+ createObject(path: string, schema: object | boolean, baseUri: string, parentDeclaredDraft?: null): ValidationObject;
566
+ /**
567
+ * Checks if an object exists at the given path without creating it.
568
+ * @param {string} path - The URI path to check
569
+ * @returns {ValidationObject|null|undefined} The existing object, null if marked unresolved, or undefined if not known
570
+ */
571
+ unresolvedObject(path: string): ValidationObject | null | undefined;
572
+ /**
573
+ * Gets the raw schema object by its URI/ID directly from the schemas map.
574
+ * This performs a direct lookup without following references.
575
+ * @param {string} uri - The schema URI to look up
576
+ * @returns {object|undefined} The raw schema object or undefined
577
+ */
578
+ getSchemaByUri(uri: string): object | undefined;
579
+ /**
580
+ * Resolves a $ref to a ValidationObject, creating it if necessary.
581
+ * @param {string} ref - The reference URI to resolve
582
+ * @param {string} path - The current path (for error messages)
583
+ * @param {object} schema - The schema containing the $ref
584
+ * @returns {ValidationObject} The resolved ValidationObject
585
+ */
586
+ resolveObject(ref: string, path: string, schema: object): ValidationObject;
587
+ /**
588
+ * Adds an error to the validation errors list.
589
+ * @param {InternalValidationError} error - The error to add
590
+ * @returns {boolean} Always returns false for convenience in validators
591
+ */
592
+ addError(error: InternalValidationError): boolean;
593
+ /**
594
+ * A checkpoint in the collected-error list.
595
+ *
596
+ * A SPECULATIVE applicator - an `anyOf` branch, an `if` condition, the
597
+ * subschema of a `not`, a `contains` candidate - runs a validator whose
598
+ * failure may be entirely expected. Those failures still call `addError`,
599
+ * so without a checkpoint they leak into the caller's issue list and blame
600
+ * a document for not matching a branch it was never required to match.
601
+ * Marking before the probe and rolling back after is the same discipline
602
+ * `EvalLog` already uses for annotations.
603
+ * @returns {number} The mark to pass to {@link rollbackErrors}
604
+ */
605
+ errorMark(): number;
606
+ /**
607
+ * Discard every error collected since `mark`.
608
+ * @param {number} mark - A value from {@link errorMark}
609
+ */
610
+ rollbackErrors(mark: number): void;
611
+ /**
612
+ * Validates data against the root schema.
613
+ * @param {unknown} data - The data to validate
614
+ * @returns {boolean} True if valid, false otherwise
615
+ */
616
+ validate(data: unknown): boolean;
617
+ /**
618
+ * Returns the fastest repeated-validation entry point for this root.
619
+ * Error collection and root-level dynamic anchors need the per-call
620
+ * bookkeeping of validate(); without them the compiled root validator
621
+ * only needs the annotation log cleared (when tracking is on) and can
622
+ * otherwise be invoked directly. Dynamic anchors pushed during
623
+ * validation are balanced by try/finally, so the anchor map needs no
624
+ * per-call clearing here.
625
+ * @returns {(data: unknown) => boolean} The validation entry point
626
+ */
627
+ createValidateFn(): (data: unknown) => boolean;
628
+ /**
629
+ * Get the stored validator for a dynamic anchor.
630
+ * Used by $dynamicRef for runtime resolution.
631
+ * Per draft 2020-12, $dynamicRef resolves to the FIRST (outermost)
632
+ * resource in the dynamic scope that defines the anchor.
633
+ * @param {string} anchorName - The anchor name
634
+ * @returns {Function|null} The validator function or null if not set
635
+ */
636
+ getDynamicAnchorValidator(anchorName: string): Function | null;
637
+ /**
638
+ * Get the outermost validator for a recursive anchor.
639
+ * Used by $recursiveRef for runtime resolution.
640
+ * Returns the bottom of the stack (first/outermost registered validator).
641
+ * @param {string} anchorName - The anchor name (empty string for $recursiveRef)
642
+ * @returns {Function|null} The validator function or null if not set
643
+ */
644
+ getOutermostDynamicAnchorValidator(anchorName: string): Function | null;
645
+ /**
646
+ * Push a validator onto the stack for a dynamic anchor.
647
+ * Called when entering a schema with $recursiveAnchor or $dynamicAnchor.
648
+ * @param {string} anchorName - The anchor name
649
+ * @param {Function} validator - The validator function
650
+ */
651
+ pushDynamicAnchorValidator(anchorName: string, validator: Function): void;
652
+ /**
653
+ * Pop a validator from the stack for a dynamic anchor.
654
+ * Called when exiting a schema with $recursiveAnchor or $dynamicAnchor.
655
+ * @param {string} anchorName - The anchor name
656
+ */
657
+ popDynamicAnchorValidator(anchorName: string): void;
658
+ /**
659
+ * Get or create a validator for a given schema.
660
+ * This is used when we need a validator for a schema at validation time
661
+ * (e.g., for dynamic anchors collected from $defs).
662
+ * @param {object} schema - The schema to create a validator for
663
+ * @param {string} basePath - The base path for the schema
664
+ * @param {string} baseUri - The base URI for the schema
665
+ * @returns {Function} The validator function
666
+ */
667
+ getOrCreateValidator(schema: object, basePath: string, baseUri: string): Function;
668
+ }
669
+ /**
670
+ * ValidationObject represents a single schema location with its compiled validator.
671
+ * It handles the compilation of schema validation logic and provides methods for
672
+ * creating child validators and error handlers.
673
+ * @class
674
+ */
675
+ export declare class ValidationObject {
676
+ #private;
677
+ /**
678
+ * Compiles a validator function for the given schema.
679
+ * This is the main entry point for schema compilation. It handles:
680
+ * - Simple schemas (type-only, required-only) via fast paths
681
+ * - Schemas with $ref by resolving to target validators
682
+ * - Complex schemas by delegating to compileSchemaObject
683
+ * @param {ValidationObject} self - The validation object that is compiling this validator
684
+ * @param {string} path - The path to this schema object (its URI identifier)
685
+ * @param {any} schema - The schema object to compile
686
+ * @param {string} baseUri - The base URI for resolving $ref (parent's base, before any sibling $id)
687
+ * @returns {function(any, any):boolean} A function that validates data against the compiled schema and returns a boolean.
688
+ */
689
+ static compileValidator(self: ValidationObject, path: string, schema: any, baseUri: string): Function;
690
+ /**
691
+ * Creates a new ValidationObject.
692
+ * @param {ValidationRoot} root - The root validation context
693
+ * @param {string} path - The URI path identifying this schema object
694
+ * @param {any} schema - The schema object to compile
695
+ * @param {string} baseUri - The base URI for resolving $ref
696
+ * @param {number|null} [parentDeclaredDraft] - The declared draft inherited from the parent schema object
697
+ */
698
+ constructor(root: ValidationRoot, path: string, schema: any, baseUri: string, parentDeclaredDraft?: number | null);
699
+ /** @returns {string} The URI path identifying this schema object */
700
+ get path(): string;
701
+ /** @returns {string} The effective base URI for resolving relative $refs */
702
+ get baseUri(): string;
703
+ /** @returns {function} The compiled validator function */
704
+ get validate(): Function;
705
+ /** @returns {ValidationOptions} The validation options */
706
+ get options(): ValidationOptions;
707
+ /** @returns {object} The registered format validators */
708
+ get formats(): object;
709
+ /** @returns {ValidationRoot} The root validation context */
710
+ get root(): ValidationRoot;
711
+ /** @returns {object} The schema object */
712
+ get schema(): object;
713
+ /** @returns {number|null} Draft version declared by this schema's document via $schema, or null when never declared */
714
+ get declaredDraft(): number | null;
715
+ /**
716
+ * Creates an error handler function for validation failures.
717
+ * @param {any} expected - The expected value that failed validation
718
+ * @param {string | string[]} key - The keyword or keywords that failed
719
+ * @returns {(data: unknown, ...meta: any[]) => boolean} A function that adds an error and returns false
720
+ */
721
+ createErrorHandler(expected: any, key: string | string[]): (data: unknown, ...meta: any[]) => boolean;
722
+ /**
723
+ * Creates a validator function for a child schema.
724
+ * This is used when compiling nested schemas (e.g., array items, object properties).
725
+ * @param {JSONSchema | boolean} schema - The child schema to compile
726
+ * @param {string} key - The property key where the schema is located
727
+ * @param {number} [index] - Optional array index for tuple items
728
+ * @returns {function|undefined} The compiled validator function, or undefined if schema is invalid
729
+ */
730
+ createValidator(schema: JSONSchema | boolean, key: string, index?: number): Function | undefined;
731
+ }
732
+ /**
733
+ * ValidatorOptions configures the JarenValidator instance.
734
+ * Can be created with positional arguments or an options object.
735
+ * @class
736
+ * @example
737
+ * // Positional arguments
738
+ * const options = new ValidatorOptions(formats, schemas, validation, traverse);
739
+ *
740
+ * // Options object (recommended)
741
+ * const options = new ValidatorOptions({
742
+ * formats: { custom: validator },
743
+ * collectErrors: true,
744
+ * useGrapheme: false
745
+ * });
746
+ */
747
+ export declare class ValidatorOptions {
748
+ /** @type {object} Registered format validators */
749
+ formats: object;
750
+ /** @type {object[]} Initial schemas to register */
751
+ schemas: object[];
752
+ validation: ValidationOptions;
753
+ /** @type {TraverseOptions} Schema traversal options */
754
+ traverse: TraverseOptions;
755
+ /**
756
+ * Creates validator options.
757
+ * @param {object|object[]} [formats={}] - Format validators or options object
758
+ * @param {object[]} [schemas=[]] - Initial schemas to register
759
+ * @param {ValidationOptions} [validation] - Validation behavior options
760
+ * @param {TraverseOptions} [traverse] - Schema traversal options
761
+ */
762
+ constructor(formats?: object | object[], schemas?: object[], validation?: ValidationOptions, traverse?: TraverseOptions);
763
+ }
764
+ export type ValidationResultObject = {
765
+ valid: boolean;
766
+ errors: import("./messages.js").ValidationError[];
767
+ };
768
+ export type CompiledPredicate<T> = (data: unknown) => data is T;
769
+ export type CompiledCollector = (data: unknown) => ValidationResultObject;
770
+ export type ValidatorInit<TCollect extends boolean = false> = {
771
+ /**
772
+ * - Format compilers to register
773
+ */
774
+ formats?: Record<string, FormatCompiler>;
775
+ /**
776
+ * - Schemas to register
777
+ */
778
+ schemas?: (JSONSchema | boolean)[];
779
+ /**
780
+ * - Validation behavior options
781
+ */
782
+ validation?: ValidationOptions;
783
+ /**
784
+ * - Schema traversal options
785
+ */
786
+ traverse?: TraverseOptions;
787
+ /**
788
+ * - Return `{ valid, errors }` instead of a boolean
789
+ */
790
+ collectErrors?: TCollect;
791
+ /**
792
+ * - Stop at the first failure (defaults to `!collectErrors`)
793
+ */
794
+ skipErrors?: boolean;
795
+ /**
796
+ * - Count grapheme clusters for string length
797
+ */
798
+ useGrapheme?: boolean;
799
+ /**
800
+ * - Assert contentEncoding/contentMediaType
801
+ */
802
+ contentValidation?: boolean;
803
+ /**
804
+ * - The JSON Schema draft version
805
+ */
806
+ draftVersion?: number;
807
+ /**
808
+ * - Assert the format keyword
809
+ */
810
+ formatAssertion?: boolean;
811
+ /**
812
+ * - Render English message text on collected errors
813
+ */
814
+ messages?: boolean;
815
+ /**
816
+ * - What an ASSERTING `format` with no registered compiler does: 'ignore' (default, per spec) accepts it as an annotation, 'error' throws at compile time
817
+ */
818
+ unknownFormats?: 'error' | 'ignore';
819
+ };
820
+ /**
821
+ * The object a compiled validator returns when `collectErrors` is enabled.
822
+ * @typedef {{ valid: boolean, errors: import("./messages.js").ValidationError[] }} ValidationResultObject
823
+ */
824
+ /**
825
+ * A compiled validator in the default boolean mode. It is a type guard, so
826
+ * `T` is whatever the caller asserts the schema describes; with no `T` it
827
+ * behaves as an ordinary boolean predicate.
828
+ * @template T
829
+ * @typedef {(data: unknown) => data is T} CompiledPredicate
830
+ */
831
+ /**
832
+ * A compiled validator in collect-errors mode.
833
+ * @typedef {(data: unknown) => ValidationResultObject} CompiledCollector
834
+ */
835
+ /**
836
+ * The plain-object form accepted by the JarenValidator constructor, mixing
837
+ * validator-level settings with the ValidationOptions fields.
838
+ * @template {boolean} [TCollect=false]
839
+ * @typedef {object} ValidatorInit
840
+ * @property {Record<string, FormatCompiler>} [formats] - Format compilers to register
841
+ * @property {(JSONSchema | boolean)[]} [schemas] - Schemas to register
842
+ * @property {ValidationOptions} [validation] - Validation behavior options
843
+ * @property {TraverseOptions} [traverse] - Schema traversal options
844
+ * @property {TCollect} [collectErrors] - Return `{ valid, errors }` instead of a boolean
845
+ * @property {boolean} [skipErrors] - Stop at the first failure (defaults to `!collectErrors`)
846
+ * @property {boolean} [useGrapheme] - Count grapheme clusters for string length
847
+ * @property {boolean} [contentValidation] - Assert contentEncoding/contentMediaType
848
+ * @property {number} [draftVersion] - The JSON Schema draft version
849
+ * @property {boolean} [formatAssertion] - Assert the format keyword
850
+ * @property {boolean} [messages] - Render English message text on collected errors
851
+ * @property {'error'|'ignore'} [unknownFormats] - What an ASSERTING `format` with no registered compiler does: 'ignore' (default, per spec) accepts it as an annotation, 'error' throws at compile time
852
+ */
853
+ /**
854
+ * JarenValidator is the main entry point for JSON Schema validation.
855
+ * It manages schema registration, format registration, and compilation.
856
+ *
857
+ * The `collectErrors` option decides what a compiled validator returns, and
858
+ * it is carried in the type parameter so the two shapes never have to be
859
+ * distinguished at runtime.
860
+ * @template {boolean} [TCollect=false]
861
+ * @class
862
+ * @example
863
+ * const validator = new JarenValidator();
864
+ * validator.addSchema({ $id: 'http://example.com/schema', type: 'object' });
865
+ * const validate = validator.compile({ $ref: 'http://example.com/schema' });
866
+ * const valid = validate({ foo: 'bar' }); // true
867
+ */
868
+ export declare class JarenValidator<TCollect extends boolean = false> {
869
+ #private;
870
+ /**
871
+ * Creates a new JarenValidator instance.
872
+ * @param {ValidatorOptions | ValidatorInit<TCollect>} [options] - Validator options including formats, schemas, validation options, and traverse options
873
+ */
874
+ constructor(options?: ValidatorOptions | ValidatorInit<TCollect>);
875
+ /**
876
+ * Adds a format validator.
877
+ * @param {string} name - The format name (e.g., 'email', 'uri', 'date-time')
878
+ * @param {FormatCompiler} formatCompiler - A function that compiles format validators
879
+ * @returns {this} This validator instance for chaining (the polymorphic `this` keeps the collectErrors type parameter across a chain)
880
+ * @example
881
+ * validator.addFormat('custom', (schemaObj, schema) => {
882
+ * return (data) => data.startsWith('custom:');
883
+ * });
884
+ */
885
+ addFormat(name: string, formatCompiler: FormatCompiler): this;
886
+ /**
887
+ * Adds multiple format validators at once.
888
+ * @param {Record<string, FormatCompiler>} formatCompilers - Object mapping format names to compiler functions
889
+ * @returns {this} This validator instance for chaining (the polymorphic `this` keeps the collectErrors type parameter across a chain)
890
+ */
891
+ addFormats(formatCompilers: Record<string, FormatCompiler>): this;
892
+ /**
893
+ * Adds schema(s) to the validator instance.
894
+ * This method does not compile schemas - it only registers them for reference.
895
+ * Dependencies can be added in any order, and circular dependencies are supported.
896
+ * @param {JSONSchema | boolean | (JSONSchema | boolean)[]} schema - The schema(s) to add
897
+ * @param {string} [key] - Optional key/URI to register the schema under
898
+ * @returns {this} This validator instance for chaining (the polymorphic `this` keeps the collectErrors type parameter across a chain)
899
+ * @example
900
+ * // Add a single schema
901
+ * validator.addSchema({ $id: 'http://example.com/user', type: 'object' });
902
+ *
903
+ * // Add multiple schemas
904
+ * validator.addSchema([schema1, schema2]);
905
+ *
906
+ * // Add with explicit key
907
+ * validator.addSchema({ type: 'string' }, 'http://example.com/name');
908
+ */
909
+ addSchema(schema: JSONSchema | boolean | (JSONSchema | boolean)[], key?: string): this;
910
+ static normalizeUriKey(key: any): any;
911
+ /**
912
+ * Adds meta-schema(s) that can be used to validate schemas.
913
+ * Meta-schemas are schemas that describe the structure of valid JSON schemas.
914
+ * @param {JSONSchema | boolean | (JSONSchema | boolean)[]} schema - The meta-schema(s) to add
915
+ * @param {string} [key] - Optional key/URI for the meta-schema
916
+ * @returns {this} This validator instance for chaining (the polymorphic `this` keeps the collectErrors type parameter across a chain)
917
+ * @example
918
+ * validator.addMetaSchema(draft7MetaSchema, 'http://json-schema.org/draft-07/schema');
919
+ */
920
+ addMetaSchema(schema: JSONSchema | boolean | (JSONSchema | boolean)[], key?: string): this;
921
+ /**
922
+ * Retrieves a registered schema by its key/URI.
923
+ * @param {string} key - The schema URI/key
924
+ * @returns {JSONSchema | boolean | null} The registered schema, or null if not found
925
+ */
926
+ getSchema(key: string): JSONSchema | boolean | null;
927
+ /**
928
+ * Validates a schema against a registered meta-schema.
929
+ * This is used to ensure schemas are valid according to the JSON Schema specification.
930
+ * @param {JSONSchema | boolean} schema - The schema to validate
931
+ * @returns {boolean} True if the schema is valid
932
+ * @example
933
+ * validator.addMetaSchema(draft7MetaSchema);
934
+ * const isValid = validator.validateSchema({ type: 'string' }); // true
935
+ */
936
+ validateSchema(schema: JSONSchema | boolean): boolean;
937
+ /**
938
+ * Compiles a schema into a validation function.
939
+ * This is the main method for creating validators. It resolves all $ref references,
940
+ * compiles the schema structure, and returns a function that validates data.
941
+ * The return type follows the instance's `collectErrors` setting: a type
942
+ * guard over `unknown` by default, or a function producing
943
+ * `{ valid, errors }` when errors are collected. Jaren does not infer `T`
944
+ * from the schema — the caller asserts what the schema describes, which is
945
+ * what a checked contract wrapper wants; pair it with a schema-to-type
946
+ * generator if you need the shape derived mechanically.
947
+ * @template [T=unknown]
948
+ * @param {JSONSchema | boolean} schema - The schema to compile
949
+ * @param {(JSONSchema | boolean)[]} [schemas] - Additional schemas to reference during compilation
950
+ * @returns {TCollect extends true ? CompiledCollector : CompiledPredicate<T>} A validation function
951
+ * @example
952
+ * const validate = validator.compile({
953
+ * type: 'object',
954
+ * properties: {
955
+ * name: { type: 'string' }
956
+ * }
957
+ * });
958
+ *
959
+ * const valid = validate({ name: 'John' }); // true
960
+ * const invalid = validate({ name: 123 }); // false
961
+ *
962
+ * // Narrowing to a caller-asserted type
963
+ * const isUser = validator.compile<{ name: string }>(userSchema);
964
+ * if (isUser(input)) input.name; // input is { name: string } here
965
+ *
966
+ * // With error collection
967
+ * const collecting = new JarenValidator({ collectErrors: true });
968
+ * const result = collecting.compile(schema)({ name: 123 });
969
+ * // result = { valid: false, errors: [...] }
970
+ */
971
+ compile<T = unknown>(schema: JSONSchema | boolean, schemas?: (JSONSchema | boolean)[]): TCollect extends true ? CompiledCollector : CompiledPredicate<T>;
972
+ }