@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,142 @@
1
+ export { compileMessageTemplate, compileMessageCatalog, } from '@jarenjs/core/message';
2
+ /**
3
+ * The built-in English catalog: one entry per message key the validator
4
+ * produces, rendering the exact strings of the historical `#convertErrors`
5
+ * if/else chain. Keywords without an entry (`const`, `enum`,
6
+ * `dependentRequired`, ...) fall back to the generic
7
+ * `validation failed for keyword '<keyword>'` - as before.
8
+ * @type {Record<string, string | ((params: object, error?: object) => string)>}
9
+ */
10
+ export declare const messagesEn: Record<string, string | ((params: object, error?: object) => string)>;
11
+ /**
12
+ * JSON Schema Validation Error
13
+ * Represents a validation error according to the JSON Schema specification.
14
+ * @see https://json-schema.org/draft/2020-12/json-schema-core.html#output
15
+ */
16
+ export declare class ValidationError {
17
+ keyword: string;
18
+ instancePath: string;
19
+ schemaPath: string;
20
+ params: object;
21
+ msgid: string;
22
+ message: string;
23
+ /**
24
+ * @param {object} options - Error options
25
+ * @param {string} options.keyword - The keyword that failed validation
26
+ * @param {string} options.instancePath - JSON Pointer to the data location
27
+ * @param {string} options.schemaPath - JSON Pointer to the schema location
28
+ * @param {object} options.params - Keyword-specific parameters
29
+ * @param {string} [options.msgid] - Stable message key resolving this error in a catalog
30
+ * @param {string} [options.message] - Human-readable error message
31
+ */
32
+ constructor(options: {
33
+ keyword: string;
34
+ instancePath: string;
35
+ schemaPath: string;
36
+ params: object;
37
+ msgid?: string;
38
+ message?: string;
39
+ });
40
+ /**
41
+ * Convert error to a plain object
42
+ * @returns {object} Plain object representation
43
+ */
44
+ toJSON(): object;
45
+ }
46
+ /**
47
+ * Render the message of an error through a catalog - the tail of the
48
+ * resolution precedence chain (no `errorMessage` registry involvement):
49
+ * catalog[msgid], built-in English[msgid], catalog[keyword],
50
+ * built-in English[keyword], then the generic fallback text.
51
+ * @param {ValidationError | {keyword: string, msgid?: string, params?: object}} error - The error to render
52
+ * @param {Readonly<Record<string, (params: object, error?: object) => string>>} [catalog] - A compiled catalog (see {@link compileMessageCatalog})
53
+ * @returns {string} The rendered message
54
+ */
55
+ export declare function renderErrorMessage(error: ValidationError | {
56
+ keyword: string;
57
+ msgid?: string;
58
+ params?: object;
59
+ }, catalog?: Readonly<Record<string, (params: object, error?: object) => string>>): string;
60
+ /**
61
+ * Re-render the `message` of every error from its `msgid` + `params`
62
+ * through the given catalog, with built-in English fallback. This is the
63
+ * whole post-hoc i18n story:
64
+ * `localizeErrors(validate(data).errors, compileMessageCatalog(nl))`.
65
+ *
66
+ * Inline schema-authored messages (a MessageSpec without `$msgid`) are
67
+ * single-language by definition and are NOT re-rendered - that is why
68
+ * `$msgid` exists. An error whose `msgid` resolves in no catalog keeps
69
+ * its current message (e.g. the spec's inline fallback text).
70
+ * @param {ValidationError[]} errors - Errors from a collect-mode validation
71
+ * @param {Readonly<Record<string, (params: object, error?: object) => string>>} catalog - A compiled catalog (see {@link compileMessageCatalog})
72
+ * @returns {ValidationError[]} The same array, messages re-rendered
73
+ */
74
+ export declare function localizeErrors(errors: ValidationError[], catalog: Readonly<Record<string, (params: object, error?: object) => string>>): ValidationError[];
75
+ export type CompiledMessageSpec = {
76
+ /**
77
+ * - Catalog key to resolve at render time
78
+ */
79
+ msgid: string | null;
80
+ /**
81
+ * - Compiled inline template
82
+ */
83
+ render: ((params: object, error?: object) => string) | null;
84
+ /**
85
+ * - Author params, merged OVER the error's params
86
+ */
87
+ params: object | null;
88
+ };
89
+ export type CompiledErrorMessageNode = {
90
+ /**
91
+ * - String-form spec: covers this node AND its subtree
92
+ */
93
+ all: CompiledMessageSpec | null;
94
+ /**
95
+ * - Map-form per-keyword specs (this node only)
96
+ */
97
+ keywords: Map<string, CompiledMessageSpec | {
98
+ perKey: Map<string, CompiledMessageSpec>;
99
+ fallback: CompiledMessageSpec | null;
100
+ }> | null;
101
+ /**
102
+ * - The '_' entry (this node only)
103
+ */
104
+ catchAll: CompiledMessageSpec | null;
105
+ };
106
+ /**
107
+ * A compiled 'errorMessage' node registered on the ValidationRoot.
108
+ * @typedef {object} CompiledErrorMessageNode
109
+ * @property {CompiledMessageSpec|null} all - String-form spec: covers this node AND its subtree
110
+ * @property {Map<string, CompiledMessageSpec | {perKey: Map<string, CompiledMessageSpec>, fallback: CompiledMessageSpec|null}>|null} keywords - Map-form per-keyword specs (this node only)
111
+ * @property {CompiledMessageSpec|null} catchAll - The '_' entry (this node only)
112
+ */
113
+ /**
114
+ * Compile the value of an 'errorMessage' keyword into a registry node.
115
+ * Grammar (validated here, at schema compile time):
116
+ * - MessageSpec (string / `$msgid` object): covers the whole subtree;
117
+ * - map form: per-keyword MessageSpecs for this node, where `required`
118
+ * also accepts a per-missing-property map, `$query` a per-runtime-code
119
+ * map (with `default` for the EBV-false failure), and `_` is the
120
+ * node-level catch-all.
121
+ * @param {unknown} errorMessage - The keyword's value
122
+ * @param {string} path - The schema path, for compile error messages
123
+ * @returns {CompiledErrorMessageNode} The compiled node
124
+ */
125
+ export declare function compileErrorMessageSpec(errorMessage: unknown, path: string): CompiledErrorMessageNode;
126
+ /**
127
+ * Convert internal validation errors to the public ValidationError format.
128
+ * Params extraction is table-driven off the failed keyword; message text
129
+ * goes through the errorMessage registry (if any) and the built-in
130
+ * English catalog. With `options.messages === false` no message is
131
+ * rendered at all (`message: ''`, params and msgid still set).
132
+ * @param {Array<{object: any, key: string|string[], expected: any, dataKey: any, value: any, rest: any[]}>} internalErrors - The root's internal error records
133
+ * @returns {ValidationError[]} The public errors
134
+ */
135
+ export declare function convertInternalErrors(internalErrors: Array<{
136
+ object: any;
137
+ key: string | string[];
138
+ expected: any;
139
+ dataKey: any;
140
+ value: any;
141
+ rest: any[];
142
+ }>): ValidationError[];
@@ -0,0 +1,107 @@
1
+ export type Normalizer<In = unknown, Out = In> = (data: In) => Out;
2
+ export type NormalizeOptions = {
3
+ /**
4
+ * - Materialize `default` for absent object properties, recursively
5
+ */
6
+ useDefaults?: boolean | ((schemaNode: Record<string, unknown>) => boolean);
7
+ /**
8
+ * - Strip unknown properties: `true` only where `additionalProperties: false`, `'all'` wherever an object shape is declared
9
+ */
10
+ removeAdditional?: boolean | 'all';
11
+ /**
12
+ * - Convert a value to the node's declared scalar `type` when it is convertible
13
+ */
14
+ coerceTypes?: boolean | ((schemaNode: Record<string, unknown>) => boolean);
15
+ /**
16
+ * - Trim leading/trailing whitespace from strings, before coercion
17
+ */
18
+ trimStrings?: boolean | ((schemaNode: Record<string, unknown>) => boolean);
19
+ };
20
+ /**
21
+ * Collect the `$anchor` declarations of one schema document: a map from
22
+ * anchor name to the schema node that declares it. Exported because
23
+ * `@jarenjs/emit` resolves the same references when it derives types, and two
24
+ * walks with different scope rules would make a generated type disagree with
25
+ * this normalizer — the one defect class that package must not have.
26
+ *
27
+ * The scope is the same-document scope the rest of this module uses: a
28
+ * subtree that declares its own `$id` is an embedded resource with its own
29
+ * anchor scope, so it is not descended. First declaration wins, which keeps
30
+ * the map deterministic for a document that (invalidly) repeats a name.
31
+ * @param {object|boolean} root - The root schema of the document
32
+ * @returns {Map<string, object>} anchor name -> schema node
33
+ */
34
+ export declare function collectSameDocumentAnchors(root: object | boolean): Map<string, object>;
35
+ /**
36
+ * Resolve a same-document `$ref` — `#`, `#/` followed by a JSON Pointer, or
37
+ * `#name` for a plain `$anchor` — to the schema it addresses. Refs into other
38
+ * documents are not followed: a normalizer compiles one schema, and reaching
39
+ * a registered sibling would mean owning the whole resolution scope that
40
+ * `compile` owns. Exported for `@jarenjs/emit`, which must resolve references
41
+ * with exactly these rules when it derives the accepted/normalized variants.
42
+ * @param {string} ref - The reference
43
+ * @param {object|boolean} root - The root schema being compiled
44
+ * @param {Map<string, object>} [anchors] - The document's anchor map, from
45
+ * {@link collectSameDocumentAnchors}; omit to skip anchor resolution
46
+ * @returns {object|boolean|undefined} The addressed schema, or undefined
47
+ */
48
+ export declare function resolveSameDocumentRef(ref: string, root: object | boolean, anchors?: Map<string, object>): object | boolean | undefined;
49
+ /**
50
+ * Resolve a per-node normalization switch at COMPILE time. Exported because
51
+ * `@jarenjs/emit` has to answer the same question when it derives the accepted
52
+ * and normalized type variants: two implementations of this rule would drift,
53
+ * and a type that disagrees with the normalizer is worse than no type. `true` turns the
54
+ * behavior on everywhere, `false` nowhere, and a predicate decides per schema
55
+ * node — which is how a consumer expresses "trim these 34 string fields, not
56
+ * the other 185" without the option becoming a whole-schema blunt instrument.
57
+ * Because it runs during compilation, a predicate costs nothing at runtime.
58
+ * @param {boolean|((node: Record<string, unknown>) => boolean)|undefined} option
59
+ * @param {object} node - The schema node the switch applies to
60
+ * @returns {boolean}
61
+ */
62
+ export declare function resolveNormalizeSwitch(option: boolean | ((node: Record<string, unknown>) => boolean) | undefined, node: object): boolean;
63
+ /**
64
+ * Compile a JSON Schema into a normalizer: a function that returns a
65
+ * normalized copy of its input, leaving the input untouched.
66
+ *
67
+ * Validation is unaffected and unchanged - normalize first, then hand the
68
+ * result to a compiled validator:
69
+ *
70
+ * ```javascript
71
+ * const normalize = compileNormalizer(schema, { useDefaults: true, trimStrings: true });
72
+ * const validate = new JarenValidator({ collectErrors: true }).compile(schema);
73
+ * const shaped = normalize(input);
74
+ * const result = validate(shaped);
75
+ * ```
76
+ *
77
+ * **What is normalized.** `properties`, `patternProperties`,
78
+ * `additionalProperties`, `items`/`prefixItems`/`additionalItems`, same-document
79
+ * `$ref` (`#`, `#/pointer` and plain `#anchor` forms), and `allOf` (composed,
80
+ * with stripping disabled inside it).
81
+ *
82
+ * **What is not, and why.** `anyOf`, `oneOf`, `if`/`then`/`else` and `not`
83
+ * are not descended: which branch applies is only known after validating,
84
+ * and normalizing under a branch can change which branch validates. Nothing
85
+ * arbitrary runs either - there is no transform hook, because an arbitrary
86
+ * transform is application code, not schema semantics, and belongs on the
87
+ * caller's side of the boundary.
88
+ * @template [In=unknown]
89
+ * @template [Out=In]
90
+ * @param {object|boolean} schema - The schema to compile
91
+ * @param {NormalizeOptions} [options] - Which normalizations to apply
92
+ * @returns {Normalizer<In, Out>} The compiled normalizer
93
+ * @example
94
+ * const normalize = compileNormalizer({
95
+ * type: 'object',
96
+ * properties: {
97
+ * name: { type: 'string' },
98
+ * port: { type: 'integer', default: 8080 },
99
+ * },
100
+ * additionalProperties: false,
101
+ * }, { useDefaults: true, removeAdditional: true, coerceTypes: true, trimStrings: true });
102
+ *
103
+ * const input = { name: ' jaren ', port: '9000', stray: 1 };
104
+ * normalize(input); // { name: 'jaren', port: 9000 }
105
+ * input; // { name: ' jaren ', port: '9000', stray: 1 } - untouched
106
+ */
107
+ export declare function compileNormalizer<In = unknown, Out = In>(schema: object | boolean, options?: NormalizeOptions): Normalizer<In, Out>;
@@ -0,0 +1 @@
1
+ export declare function compileNumberBasic(schemaObj: any, jsonSchema: any): ((data: any, dataPath: any) => any) | undefined;
@@ -0,0 +1,3 @@
1
+ export declare function compileObjectPrimitives(schemaObj: any, jsonSchema: any): ((data: any, dataPath: any, dataRoot: any, dataKeys: any) => any) | undefined;
2
+ export declare function compileObjectChildren(schemaObj: any, jsonSchema: any): ((data: any, dataPath: any, dataRoot: any, dataKeys: any) => boolean) | undefined;
3
+ export declare function compileObjectSchema(schemaObj: any, jsonSchema: any): ((data: any, dataPath: any, dataRoot: any) => any) | undefined;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Compile the '$query' keyword of a schema into a validator.
3
+ *
4
+ * The query document compiles with a `compileTypeTest` hook backed by the
5
+ * owning `JarenValidator` instance (threaded through `ValidationRoot`), so
6
+ * schema literals inside the query (`$valid`/`$assert`/`$as`) may `$ref`
7
+ * schemas registered on that instance with `addSchema`. Malformed query
8
+ * documents (`JQ0xxx`) and externals other than `root`/`path` throw here,
9
+ * at schema compile time. At validation time the query never throws:
10
+ * a `JsonQueryRuntimeError` (`JQ2xxx` - a data-shaped failure such as the
11
+ * EBV of a multi-item result or arithmetic on a non-number) reports as a
12
+ * validation failure whose error params carry the `code` and the query
13
+ * `docPath`.
14
+ *
15
+ * @param {object} schemaObj - The validation object
16
+ * @param {object} jsonSchema - The JSON schema containing the '$query' keyword
17
+ * @returns {function|undefined} The compiled validator function or undefined
18
+ */
19
+ export declare function compileQuerySchema(schemaObj: object, jsonSchema: object): Function | undefined;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Create a `compileTypeTest` hook for `compileJsonQuery` (see
3
+ * `@jarenjs/json/query`), backed by a `JarenValidator`.
4
+ *
5
+ * The hook compiles each schema literal with the validator and returns
6
+ * its boolean-mode validation function - errors off, the fast path of
7
+ * this package's architecture. Schema compile failures (an invalid
8
+ * schema literal, an unresolvable `$ref`) propagate as plain errors; the
9
+ * query engine wraps them into `JsonQueryCompileError` `JQ0009` with the
10
+ * operator's document pointer.
11
+ *
12
+ * @param {object | (() => object)} [validator] - a `JarenValidator`
13
+ * instance to compile with, or a zero-argument factory producing one.
14
+ * Supply an instance with registered schemas (`addSchema`) so `$ref`s
15
+ * in query schema literals resolve against them. Omitted, a fresh
16
+ * default (boolean-mode) instance is created.
17
+ * @returns {(schemaJson: any, docPath: string) => ((value: any) => boolean)}
18
+ * a hook suitable for `compileJsonQuery(doc, { compileTypeTest })`
19
+ * @example
20
+ * import { compileJsonQuery } from '@jarenjs/json/query';
21
+ * import { createTypeTestCompiler } from '@jarenjs/validate/query';
22
+ *
23
+ * const query = compileJsonQuery({
24
+ * "$for": { "b": "$.store.book[*]" },
25
+ * "$as": { "b": { "type": "object", "required": ["price"] } },
26
+ * "$return": "$b.title"
27
+ * }, { compileTypeTest: createTypeTestCompiler() });
28
+ */
29
+ export declare function createTypeTestCompiler(validator?: object | (() => object)): (schemaJson: any, docPath: string) => ((value: any) => boolean);
@@ -0,0 +1 @@
1
+ export declare function compileSchemaObject(schemaObj: any, jsonSchema: any): any;
@@ -0,0 +1 @@
1
+ export declare function compileStringBasic(schemaObj: any, jsonSchema: any): ((data: any, dataPath: any) => any) | undefined;
@@ -0,0 +1,109 @@
1
+ import { isBooleanType } from '@jarenjs/core';
2
+ import { isRegExpType } from '@jarenjs/core/string';
3
+ export declare function isBoolOrObjectClass(obj: any): boolean;
4
+ /**
5
+ * getBoolOrObjectClass
6
+ * extract the data of first parameter if data is boolean or object type otherwise return default
7
+ * @param {any} obj any data data has to be tested on boolean or object type
8
+ * @param {boolean | object | undefined} def default return type if not boolean or object type
9
+ * @returns {boolean | undefined} return value when boolean or object otherwise def
10
+ */
11
+ export declare function getBoolOrObjectClass(obj: any, def?: boolean | object | undefined): boolean | undefined;
12
+ export declare function getArrayClassMinItems(obj: any, len?: number, def?: undefined): any;
13
+ export declare function isOfSchemaType(schema: any, type: any): boolean;
14
+ export declare function hasSchemaRef(schema: any): boolean;
15
+ export declare function hasSchemaRecursiveRef(schema: any): boolean;
16
+ export declare function hasSchemaDynamicRef(schema: any): boolean;
17
+ /**
18
+ * Whether a sibling keyword of unevaluatedProperties already evaluates every
19
+ * property of the instance. additionalProperties (boolean or schema) applies
20
+ * to each property not matched by properties/patternProperties, so once it
21
+ * has passed no property is left unevaluated.
22
+ * @param {object} schema - The schema holding the unevaluatedProperties keyword
23
+ * @returns {boolean} True when the unevaluatedProperties check can never match
24
+ */
25
+ export declare function hasUnevaluatedPropertiesCoverage(schema: object): boolean;
26
+ /**
27
+ * Whether a sibling keyword of unevaluatedItems already evaluates every item
28
+ * of the instance: a uniform items schema (boolean or object) covers all
29
+ * items beyond any prefixItems, and a tuple-form items with additionalItems
30
+ * covers the items beyond the tuple.
31
+ * @param {object} schema - The schema holding the unevaluatedItems keyword
32
+ * @returns {boolean} True when the unevaluatedItems check can never match
33
+ */
34
+ export declare function hasUnevaluatedItemsCoverage(schema: object): boolean;
35
+ export declare function createIsSchemaTypeHandler(type: any, isStrict?: boolean): typeof isBooleanType | typeof isRegExpType | undefined;
36
+ /**
37
+ * The fallback resolver of the data-reference keywords (`data`, `$data`):
38
+ * a ref that fails the strict compile keeps the lax keyword semantics, so
39
+ * it resolves as not-found and the keyword asserts nothing.
40
+ * @returns {any} the JSON Pointer not-found sentinel
41
+ */
42
+ export declare const resolveNothing: () => any;
43
+ /**
44
+ * Build the keyword validators the two data-reference keywords share
45
+ * verbatim. The `data` keyword (json-everything, absolute + relative
46
+ * pointers via `compileDataRef`) and the Ajv-style `$data` keyword
47
+ * (relative pointers only) differ ONLY in which pointer compiler
48
+ * resolves a ref, so each module passes its own `compileRefResolver`
49
+ * and gets the same fifteen compilers back.
50
+ *
51
+ * Every validator follows one lax contract: a data instance outside the
52
+ * keyword's type, an unresolvable ref, or a resolved constraint of the
53
+ * wrong type asserts nothing.
54
+ *
55
+ * @param {(ref: string) => (dataRoot: any, dataPath: string) => any} compileRefResolver
56
+ * @returns {Record<string, (schemaObj: object, ref: string) => ((data: any, dataPath: string, dataRoot: any) => boolean) | undefined>}
57
+ */
58
+ export declare function createDataRefCompilers(compileRefResolver: (ref: string) => (dataRoot: any, dataPath: string) => any): Record<string, (schemaObj: object, ref: string) => ((data: any, dataPath: string, dataRoot: any) => boolean) | undefined>;
59
+ /**
60
+ * Records which properties (string keys) and items (numeric indexes) of a
61
+ * data instance were successfully evaluated during validation, so that
62
+ * unevaluatedProperties/unevaluatedItems can be checked afterwards.
63
+ *
64
+ * Entries are (data reference, key) pairs appended in application order.
65
+ * Applicators that discard annotations (failed anyOf/oneOf branches, not,
66
+ * failed if) take a mark() before running and rollback(mark) afterwards.
67
+ * The numeric key -1 means "all items of this array were evaluated".
68
+ */
69
+ export declare class EvalLog {
70
+ #private;
71
+ /** Clears the log; called at the start of each root validation. */
72
+ reset(): void;
73
+ /** @returns {number} The current log position */
74
+ mark(): number;
75
+ /** Discards all entries recorded after the given mark. */
76
+ rollback(mark: any): void;
77
+ /** Records that `key` of instance `data` was evaluated. */
78
+ add(data: any, key: any): void;
79
+ /** @returns {boolean} True when property `key` of `data` was evaluated at or after `from` */
80
+ hasKey(data: any, key: any, from: any): boolean;
81
+ /** @returns {boolean} True when item `index` of `data` was evaluated at or after `from` (-1 entries cover all items) */
82
+ hasItem(data: any, index: any, from: any): boolean;
83
+ }
84
+ /**
85
+ * Combine INDEPENDENT keyword validators without short-circuiting.
86
+ *
87
+ * `a(...) && b(...)` is the right composition in boolean mode: the answer is
88
+ * known at the first failure and nothing is gained by continuing. When errors
89
+ * are recorded it is wrong, because each validator is the only thing that can
90
+ * report its own fault, so the first failure hides every sibling's. This runs
91
+ * all of them and ANDs the results — the boolean answer is identical, the
92
+ * error list is complete.
93
+ *
94
+ * Only use it where the validators genuinely are independent. A precondition
95
+ * (a type guard before a length check) must keep its short-circuit: running
96
+ * past it is meaningless at best and throws at worst.
97
+ * @param {Function[]} validators - Independent validators, in report order
98
+ * @returns {Function} A validator that runs every one of them
99
+ */
100
+ export declare function combineIndependent(validators: Function[]): Function;
101
+ export declare class ValidationResult {
102
+ match: boolean;
103
+ errors: number;
104
+ static undefThat(): ValidationResult;
105
+ constructor(match?: boolean, errors?: number);
106
+ addValid(valid?: boolean): this;
107
+ addMatch(valid?: boolean): this;
108
+ addResult(result?: ValidationResult): this;
109
+ }
@@ -0,0 +1,32 @@
1
+ export declare function encodeJsonPointerPath(path: any, key: any, index: any): string;
2
+ export declare function decodeJsonPointerPath(path: any): any;
3
+ declare class JsonPointerOptions {
4
+ anchorsGlobal: boolean;
5
+ anchorsAllowed: boolean;
6
+ skipErrors: boolean;
7
+ constructor(anchorsGlobal?: boolean, anchorsAllowed?: boolean, skipErrors?: boolean);
8
+ }
9
+ declare class JsonPointer {
10
+ id: any;
11
+ search: any;
12
+ leftUri: any;
13
+ fragment: any;
14
+ constructor(id: any, search: any, leftUri: any, fragment: any);
15
+ }
16
+ export declare function createJsonPointer(refUri: any, baseUri: any, opts?: JsonPointerOptions): JsonPointer;
17
+ export declare function storeSchemaIdsInMap(schemas: any, baseUri: any, schema: any, opts?: JsonPointerOptions): any;
18
+ export declare function resolveRefSchemaShallow(schemas: any, refUri: any, baseUri: any, opts?: JsonPointerOptions): {
19
+ id: any;
20
+ schema: any;
21
+ };
22
+ export declare function restoreSchemaRefsInMap(schemas: any, opts?: JsonPointerOptions): void;
23
+ export declare class TraverseOptions extends JsonPointerOptions {
24
+ origin: string;
25
+ mergeSchemas: boolean;
26
+ constructor(origin?: string, mergeSchemas?: boolean, anchorsGlobal?: boolean, anchorsAllowed?: boolean, skipErrors?: boolean);
27
+ }
28
+ export declare function resolveRefSchemaDeep(schemas: any, baseUri: any, refschema: any, opts?: TraverseOptions): {
29
+ id: any;
30
+ schema: any;
31
+ };
32
+ export {};
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Wraps a compiled schema validator so unevaluatedProperties/unevaluatedItems
3
+ * run last, seeing every annotation produced on this instance by the schema's
4
+ * own keywords and its in-place applicators (allOf/anyOf/oneOf/if/$ref/...).
5
+ * Returns the validator unchanged when evaluation tracking is off or the
6
+ * schema has no unevaluated* keywords.
7
+ * @param {import('./index.js').ValidationObject} schemaObj
8
+ * @param {object} jsonSchema
9
+ * @param {function} validator - The compiled validator for all other keywords
10
+ * @returns {function} The wrapped (or original) validator
11
+ */
12
+ export declare function wrapUnevaluated(schemaObj: import('./index.js').ValidationObject, jsonSchema: object, validator: Function): Function;