z-schema 10.0.0 → 12.0.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.
- package/README.md +35 -17
- package/cjs/index.d.ts +345 -34
- package/cjs/index.js +4446 -1685
- package/dist/errors.js +5 -0
- package/dist/format-validators.js +131 -107
- package/dist/json-schema-versions.js +4 -1
- package/dist/json-schema.js +50 -16
- package/dist/json-validation.js +524 -669
- package/dist/report.js +37 -16
- package/dist/schema-cache.js +76 -18
- package/dist/schema-compiler.js +72 -47
- package/dist/schema-validator.js +117 -52
- package/dist/schemas/draft-07-schema.json +172 -0
- package/dist/schemas/draft-2019-09-meta-applicator.json +52 -0
- package/dist/schemas/draft-2019-09-meta-content.json +12 -0
- package/dist/schemas/draft-2019-09-meta-core.json +53 -0
- package/dist/schemas/draft-2019-09-meta-format.json +10 -0
- package/dist/schemas/draft-2019-09-meta-meta-data.json +32 -0
- package/dist/schemas/draft-2019-09-meta-validation.json +94 -0
- package/dist/schemas/draft-2019-09-schema.json +41 -0
- package/dist/schemas/draft-2020-12-meta-applicator.json +44 -0
- package/dist/schemas/draft-2020-12-meta-content.json +12 -0
- package/dist/schemas/draft-2020-12-meta-core.json +47 -0
- package/dist/schemas/draft-2020-12-meta-format-annotation.json +10 -0
- package/dist/schemas/draft-2020-12-meta-format-assertion.json +10 -0
- package/dist/schemas/draft-2020-12-meta-meta-data.json +32 -0
- package/dist/schemas/draft-2020-12-meta-unevaluated.json +11 -0
- package/dist/schemas/draft-2020-12-meta-validation.json +94 -0
- package/dist/schemas/draft-2020-12-schema.json +57 -0
- package/dist/types/errors.d.ts +4 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/json-schema-versions.d.ts +128 -9
- package/dist/types/json-schema.d.ts +28 -11
- package/dist/types/json-validation.d.ts +2 -3
- package/dist/types/report.d.ts +14 -4
- package/dist/types/schema-cache.d.ts +7 -0
- package/dist/types/schema-compiler.d.ts +5 -3
- package/dist/types/schema-validator.d.ts +2 -2
- package/dist/types/utils/array.d.ts +8 -1
- package/dist/types/utils/base64.d.ts +2 -0
- package/dist/types/utils/clone.d.ts +1 -1
- package/dist/types/utils/date.d.ts +1 -0
- package/dist/types/utils/hostname.d.ts +2 -0
- package/dist/types/utils/json.d.ts +2 -1
- package/dist/types/utils/properties.d.ts +0 -1
- package/dist/types/utils/time.d.ts +12 -0
- package/dist/types/utils/unicode.d.ts +3 -12
- package/dist/types/validation/array.d.ts +12 -0
- package/dist/types/validation/combinators.d.ts +10 -0
- package/dist/types/validation/numeric.d.ts +8 -0
- package/dist/types/validation/object.d.ts +13 -0
- package/dist/types/validation/ref.d.ts +11 -0
- package/dist/types/validation/shared.d.ts +26 -0
- package/dist/types/validation/string.d.ts +9 -0
- package/dist/types/validation/type.d.ts +6 -0
- package/dist/types/z-schema-base.d.ts +39 -1
- package/dist/types/z-schema-options.d.ts +3 -0
- package/dist/types/z-schema.d.ts +144 -8
- package/dist/utils/array.js +49 -7
- package/dist/utils/base64.js +29 -0
- package/dist/utils/clone.js +13 -12
- package/dist/utils/date.js +21 -0
- package/dist/utils/hostname.js +146 -0
- package/dist/utils/json.js +11 -6
- package/dist/utils/properties.js +1 -6
- package/dist/utils/time.js +50 -0
- package/dist/utils/unicode.js +8 -41
- package/dist/utils/uri.js +1 -1
- package/dist/validation/array.js +128 -0
- package/dist/validation/combinators.js +107 -0
- package/dist/validation/numeric.js +97 -0
- package/dist/validation/object.js +238 -0
- package/dist/validation/ref.js +70 -0
- package/dist/validation/shared.js +136 -0
- package/dist/validation/string.js +178 -0
- package/dist/validation/type.js +55 -0
- package/dist/z-schema-base.js +52 -32
- package/dist/z-schema-options.js +12 -8
- package/dist/z-schema-versions.js +92 -9
- package/dist/z-schema.js +135 -38
- package/package.json +22 -8
- package/src/errors.ts +8 -0
- package/src/format-validators.ts +146 -105
- package/src/index.ts +10 -1
- package/src/json-schema-versions.ts +181 -11
- package/src/json-schema.ts +102 -35
- package/src/json-validation.ts +653 -724
- package/src/report.ts +42 -20
- package/src/schema-cache.ts +94 -18
- package/src/schema-compiler.ts +94 -51
- package/src/schema-validator.ts +132 -56
- package/src/schemas/draft-07-schema.json +172 -0
- package/src/schemas/draft-2019-09-meta-applicator.json +53 -0
- package/src/schemas/draft-2019-09-meta-content.json +14 -0
- package/src/schemas/draft-2019-09-meta-core.json +54 -0
- package/src/schemas/draft-2019-09-meta-format.json +11 -0
- package/src/schemas/draft-2019-09-meta-meta-data.json +34 -0
- package/src/schemas/draft-2019-09-meta-validation.json +95 -0
- package/src/schemas/draft-2019-09-schema.json +42 -0
- package/src/schemas/draft-2020-12-meta-applicator.json +45 -0
- package/src/schemas/draft-2020-12-meta-content.json +14 -0
- package/src/schemas/draft-2020-12-meta-core.json +48 -0
- package/src/schemas/draft-2020-12-meta-format-annotation.json +11 -0
- package/src/schemas/draft-2020-12-meta-format-assertion.json +11 -0
- package/src/schemas/draft-2020-12-meta-meta-data.json +34 -0
- package/src/schemas/draft-2020-12-meta-unevaluated.json +12 -0
- package/src/schemas/draft-2020-12-meta-validation.json +95 -0
- package/src/schemas/draft-2020-12-schema.json +58 -0
- package/src/utils/array.ts +51 -7
- package/src/utils/base64.ts +32 -0
- package/src/utils/clone.ts +16 -12
- package/src/utils/date.ts +23 -0
- package/src/utils/hostname.ts +174 -0
- package/src/utils/json.ts +15 -6
- package/src/utils/properties.ts +1 -7
- package/src/utils/time.ts +73 -0
- package/src/utils/unicode.ts +8 -39
- package/src/utils/uri.ts +1 -1
- package/src/validation/array.ts +158 -0
- package/src/validation/combinators.ts +132 -0
- package/src/validation/numeric.ts +120 -0
- package/src/validation/object.ts +318 -0
- package/src/validation/ref.ts +85 -0
- package/src/validation/shared.ts +191 -0
- package/src/validation/string.ts +224 -0
- package/src/validation/type.ts +66 -0
- package/src/z-schema-base.ts +54 -36
- package/src/z-schema-options.ts +15 -8
- package/src/z-schema-versions.ts +107 -12
- package/src/z-schema.ts +158 -42
- package/umd/ZSchema.js +4446 -1685
- package/umd/ZSchema.min.js +1 -1
- package/dist/schemas/draft-04-hyper-schema.json +0 -135
- package/dist/schemas/draft-06-hyper-schema.json +0 -132
- package/dist/schemas/draft-06-links.json +0 -43
- package/src/schemas/draft-04-hyper-schema.json +0 -136
- package/src/schemas/draft-06-hyper-schema.json +0 -133
- package/src/schemas/draft-06-links.json +0 -43
|
@@ -1,23 +1,142 @@
|
|
|
1
1
|
import type { JsonSchemaCommon, ZSchemaInternalProperties } from './json-schema.js';
|
|
2
|
-
export type JsonSchemaVersion = 'draft-04' | 'draft-06';
|
|
2
|
+
export type JsonSchemaVersion = 'draft-04' | 'draft-06' | 'draft-07' | 'draft2019-09' | 'draft2020-12';
|
|
3
3
|
export declare const CURRENT_DEFAULT_SCHEMA_VERSION: JsonSchemaVersion;
|
|
4
4
|
export declare const VERSION_SCHEMA_URL_MAPPING: Record<JsonSchemaVersion, string>;
|
|
5
|
-
|
|
6
|
-
export type
|
|
7
|
-
|
|
5
|
+
/** Union of all draft-specific schema interfaces — the public API type. */
|
|
6
|
+
export type JsonSchema = JsonSchemaDraft4 | JsonSchemaDraft6 | JsonSchemaDraft7 | JsonSchemaDraft201909 | JsonSchemaDraft202012;
|
|
7
|
+
/**
|
|
8
|
+
* Superset of ALL draft-specific properties with the widest possible types.
|
|
9
|
+
* Use inside the validator where the active draft is not known at compile time.
|
|
10
|
+
*
|
|
11
|
+
* NOTE: this is a manually defined interface (not a computed intersection)
|
|
12
|
+
* because `exclusiveMinimum` is `boolean` in Draft-04 and `number` in
|
|
13
|
+
* Draft-06+, which would yield `never` in a plain intersection.
|
|
14
|
+
*/
|
|
15
|
+
export interface JsonSchemaAll extends JsonSchemaCommon {
|
|
16
|
+
/** Pre-`$id` identifier (draft-04 only). */
|
|
17
|
+
id?: string;
|
|
18
|
+
/** Schema identifier (replaces `id` from draft-06 onward). */
|
|
19
|
+
$id?: string;
|
|
20
|
+
const?: unknown;
|
|
21
|
+
contains?: JsonSchema;
|
|
22
|
+
propertyNames?: JsonSchema;
|
|
23
|
+
examples?: unknown[];
|
|
24
|
+
if?: JsonSchema | boolean;
|
|
25
|
+
then?: JsonSchema | boolean;
|
|
26
|
+
else?: JsonSchema | boolean;
|
|
27
|
+
contentEncoding?: string;
|
|
28
|
+
contentMediaType?: string;
|
|
29
|
+
$defs?: Record<string, JsonSchema>;
|
|
30
|
+
$anchor?: string;
|
|
31
|
+
$vocabulary?: Record<string, boolean>;
|
|
32
|
+
$recursiveAnchor?: boolean;
|
|
33
|
+
$recursiveRef?: string;
|
|
34
|
+
dependentSchemas?: Record<string, JsonSchema>;
|
|
35
|
+
dependentRequired?: Record<string, string[]>;
|
|
36
|
+
unevaluatedItems?: JsonSchema | boolean;
|
|
37
|
+
unevaluatedProperties?: JsonSchema | boolean;
|
|
38
|
+
maxContains?: number;
|
|
39
|
+
minContains?: number;
|
|
40
|
+
$dynamicAnchor?: string;
|
|
41
|
+
$dynamicRef?: string;
|
|
42
|
+
prefixItems?: Array<JsonSchema | boolean>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Internal schema type used throughout the validator. Based on `JsonSchemaAll`
|
|
46
|
+
* so that validators can access any draft-specific property without narrowing.
|
|
47
|
+
*/
|
|
48
|
+
export type JsonSchemaInternal = JsonSchemaAll & ZSchemaInternalProperties;
|
|
49
|
+
/** @deprecated Use `JsonSchemaInternal` — they are now equivalent. */
|
|
8
50
|
export type JsonSchemaInternalAll = JsonSchemaAll & ZSchemaInternalProperties;
|
|
9
51
|
export type JsonSchemaInternalD4 = JsonSchemaDraft4 & ZSchemaInternalProperties;
|
|
10
52
|
export type JsonSchemaInternalD6 = JsonSchemaDraft6 & ZSchemaInternalProperties;
|
|
53
|
+
export type JsonSchemaInternalD7 = JsonSchemaDraft7 & ZSchemaInternalProperties;
|
|
54
|
+
export type JsonSchemaInternalD201909 = JsonSchemaDraft201909 & ZSchemaInternalProperties;
|
|
55
|
+
export type JsonSchemaInternalD202012 = JsonSchemaDraft202012 & ZSchemaInternalProperties;
|
|
56
|
+
/**
|
|
57
|
+
* JSON Schema Draft-04.
|
|
58
|
+
*
|
|
59
|
+
* Key differences from later drafts:
|
|
60
|
+
* - Uses `id` instead of `$id`.
|
|
61
|
+
* - `exclusiveMinimum`/`exclusiveMaximum` are boolean modifiers on `minimum`/`maximum`
|
|
62
|
+
* (inherited as `boolean | number` from `JsonSchemaCommon` for cross-draft compatibility).
|
|
63
|
+
* - No `const`, `contains`, `propertyNames`, `examples`, `if`/`then`/`else`.
|
|
64
|
+
*
|
|
65
|
+
* @see https://json-schema.org/draft-04/draft-zyp-json-schema-04
|
|
66
|
+
*/
|
|
11
67
|
export interface JsonSchemaDraft4 extends JsonSchemaCommon {
|
|
12
|
-
|
|
13
|
-
|
|
68
|
+
/** Schema identifier (draft-04). Replaced by `$id` in draft-06+. */
|
|
69
|
+
id?: string;
|
|
14
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* JSON Schema Draft-06.
|
|
73
|
+
*
|
|
74
|
+
* Additions over Draft-04:
|
|
75
|
+
* - `$id` replaces `id`.
|
|
76
|
+
* - `exclusiveMinimum`/`exclusiveMaximum` changed to standalone `number` values.
|
|
77
|
+
* - Added `const`, `contains`, `propertyNames`, `examples`.
|
|
78
|
+
*
|
|
79
|
+
* @see https://json-schema.org/draft-06/draft-wright-json-schema-validation-01
|
|
80
|
+
*/
|
|
15
81
|
export interface JsonSchemaDraft6 extends JsonSchemaCommon {
|
|
16
82
|
$id?: string;
|
|
17
|
-
examples?: unknown[];
|
|
18
83
|
const?: unknown;
|
|
19
84
|
contains?: JsonSchema;
|
|
20
85
|
propertyNames?: JsonSchema;
|
|
21
|
-
|
|
22
|
-
|
|
86
|
+
examples?: unknown[];
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* JSON Schema Draft-07.
|
|
90
|
+
*
|
|
91
|
+
* Additions over Draft-06:
|
|
92
|
+
* - `if`/`then`/`else` conditional applicators.
|
|
93
|
+
* - `contentEncoding`, `contentMediaType`.
|
|
94
|
+
*
|
|
95
|
+
* @see https://json-schema.org/draft-07/draft-handrews-json-schema-validation-01
|
|
96
|
+
*/
|
|
97
|
+
export interface JsonSchemaDraft7 extends JsonSchemaDraft6 {
|
|
98
|
+
if?: JsonSchema | boolean;
|
|
99
|
+
then?: JsonSchema | boolean;
|
|
100
|
+
else?: JsonSchema | boolean;
|
|
101
|
+
contentEncoding?: string;
|
|
102
|
+
contentMediaType?: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* JSON Schema Draft 2019-09.
|
|
106
|
+
*
|
|
107
|
+
* Additions over Draft-07:
|
|
108
|
+
* - `$defs` (replaces `definitions`), `$anchor`, `$vocabulary`.
|
|
109
|
+
* - `$recursiveAnchor`/`$recursiveRef` for recursive references.
|
|
110
|
+
* - `dependentSchemas`/`dependentRequired` (split from `dependencies`).
|
|
111
|
+
* - `unevaluatedItems`/`unevaluatedProperties`.
|
|
112
|
+
* - `maxContains`/`minContains`.
|
|
113
|
+
*
|
|
114
|
+
* @see https://json-schema.org/draft/2019-09/release-notes
|
|
115
|
+
*/
|
|
116
|
+
export interface JsonSchemaDraft201909 extends JsonSchemaDraft7 {
|
|
117
|
+
$defs?: Record<string, JsonSchema>;
|
|
118
|
+
$anchor?: string;
|
|
119
|
+
$vocabulary?: Record<string, boolean>;
|
|
120
|
+
$recursiveAnchor?: boolean;
|
|
121
|
+
$recursiveRef?: string;
|
|
122
|
+
dependentSchemas?: Record<string, JsonSchema>;
|
|
123
|
+
dependentRequired?: Record<string, string[]>;
|
|
124
|
+
unevaluatedItems?: JsonSchema | boolean;
|
|
125
|
+
unevaluatedProperties?: JsonSchema | boolean;
|
|
126
|
+
maxContains?: number;
|
|
127
|
+
minContains?: number;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* JSON Schema Draft 2020-12.
|
|
131
|
+
*
|
|
132
|
+
* Additions over Draft 2019-09:
|
|
133
|
+
* - `$dynamicAnchor`/`$dynamicRef` replace `$recursiveAnchor`/`$recursiveRef`.
|
|
134
|
+
* - `prefixItems` replaces the array form of `items`.
|
|
135
|
+
*
|
|
136
|
+
* @see https://json-schema.org/draft/2020-12/release-notes
|
|
137
|
+
*/
|
|
138
|
+
export interface JsonSchemaDraft202012 extends JsonSchemaDraft201909 {
|
|
139
|
+
$dynamicAnchor?: string;
|
|
140
|
+
$dynamicRef?: string;
|
|
141
|
+
prefixItems?: Array<JsonSchema | boolean>;
|
|
23
142
|
}
|
|
@@ -1,49 +1,66 @@
|
|
|
1
1
|
import type { JsonSchema, JsonSchemaInternal } from './json-schema-versions.js';
|
|
2
2
|
import type { Reference } from './schema-compiler.js';
|
|
3
3
|
import type { ZSchemaOptions } from './z-schema-options.js';
|
|
4
|
+
/**
|
|
5
|
+
* Keywords whose values are not JSON Schema sub-schemas and must not be
|
|
6
|
+
* traversed during schema walking (id collection, reference collection, etc.).
|
|
7
|
+
*/
|
|
8
|
+
export declare const NON_SCHEMA_KEYWORDS: readonly ["enum", "const", "default", "examples"];
|
|
9
|
+
/** Returns true if the key is an internal z-schema property (prefixed with `__$`). */
|
|
10
|
+
export declare const isInternalKey: (key: string) => boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Properties present in ALL JSON Schema drafts (04 through 2020-12) with
|
|
13
|
+
* identical types. Draft-specific additions live on the individual draft
|
|
14
|
+
* interfaces in `json-schema-versions.ts`.
|
|
15
|
+
*/
|
|
4
16
|
export interface JsonSchemaCommon {
|
|
5
17
|
$ref?: string;
|
|
6
18
|
$schema?: string;
|
|
7
|
-
id?: string;
|
|
8
19
|
title?: string;
|
|
9
20
|
description?: string;
|
|
10
21
|
default?: unknown;
|
|
11
|
-
definitions?: Record<string, JsonSchema>;
|
|
12
22
|
type?: string | string[];
|
|
13
|
-
|
|
14
|
-
|
|
23
|
+
enum?: Array<unknown>;
|
|
24
|
+
format?: string;
|
|
15
25
|
multipleOf?: number;
|
|
16
26
|
minimum?: number;
|
|
17
27
|
maximum?: number;
|
|
28
|
+
/** Draft-04: `boolean` modifier on `minimum`/`maximum`. Draft-06+: standalone `number`. */
|
|
29
|
+
exclusiveMinimum?: boolean | number;
|
|
30
|
+
/** Draft-04: `boolean` modifier on `minimum`/`maximum`. Draft-06+: standalone `number`. */
|
|
31
|
+
exclusiveMaximum?: boolean | number;
|
|
18
32
|
minLength?: number;
|
|
19
33
|
maxLength?: number;
|
|
20
34
|
pattern?: string;
|
|
35
|
+
items?: JsonSchema | boolean | Array<JsonSchema | boolean>;
|
|
21
36
|
additionalItems?: boolean | JsonSchema;
|
|
22
|
-
items?: JsonSchema | JsonSchema[];
|
|
23
37
|
minItems?: number;
|
|
24
38
|
maxItems?: number;
|
|
25
39
|
uniqueItems?: boolean;
|
|
40
|
+
properties?: Record<string, JsonSchema | boolean>;
|
|
41
|
+
patternProperties?: Record<string, JsonSchema>;
|
|
42
|
+
additionalProperties?: boolean | JsonSchema;
|
|
43
|
+
required?: string[];
|
|
26
44
|
minProperties?: number;
|
|
27
45
|
maxProperties?: number;
|
|
28
|
-
required?: string[];
|
|
29
|
-
additionalProperties?: boolean | JsonSchema;
|
|
30
46
|
dependencies?: Record<string, string[] | JsonSchema>;
|
|
31
|
-
enum?: Array<unknown>;
|
|
32
|
-
format?: string;
|
|
33
47
|
allOf?: JsonSchema[];
|
|
34
48
|
anyOf?: JsonSchema[];
|
|
35
49
|
oneOf?: JsonSchema[];
|
|
36
50
|
not?: JsonSchema;
|
|
51
|
+
definitions?: Record<string, JsonSchema>;
|
|
37
52
|
}
|
|
38
53
|
export type JsonSchemaType = 'array' | 'boolean' | 'integer' | 'null' | 'number' | 'object' | 'string';
|
|
39
54
|
export interface ZSchemaInternalProperties {
|
|
40
55
|
__$compiled?: unknown;
|
|
41
56
|
__$missingReferences?: Reference[];
|
|
42
57
|
__$refResolved?: JsonSchema;
|
|
58
|
+
__$dynamicRefResolved?: JsonSchema;
|
|
59
|
+
__$recursiveRefResolved?: JsonSchema;
|
|
60
|
+
__$resourceRoot?: JsonSchemaInternal;
|
|
43
61
|
__$schemaResolved?: unknown;
|
|
44
62
|
__$validated?: boolean;
|
|
45
63
|
__$validationOptions?: ZSchemaOptions;
|
|
46
|
-
__$visited?: boolean;
|
|
47
64
|
}
|
|
48
65
|
export declare const getId: (schema: JsonSchemaInternal) => string | undefined;
|
|
49
|
-
export declare const findId: (schema: JsonSchemaInternal, id: string) => JsonSchemaInternal | undefined;
|
|
66
|
+
export declare const findId: (schema: JsonSchemaInternal, id: string, targetBaseUri?: string, currentBaseUri?: string, maxDepth?: number, _depth?: number) => JsonSchemaInternal | undefined;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { JsonSchemaAll, JsonSchemaInternal } from './json-schema-versions.js';
|
|
2
2
|
import type { ZSchemaBase } from './z-schema-base.js';
|
|
3
3
|
import { Report } from './report.js';
|
|
4
|
-
type JsonValidatorFn
|
|
4
|
+
import { type JsonValidatorFn } from './validation/shared.js';
|
|
5
5
|
export declare const JsonValidators: Record<keyof JsonSchemaAll, JsonValidatorFn>;
|
|
6
6
|
export declare function validate(this: ZSchemaBase, report: Report, schema: boolean | JsonSchemaInternal, json: unknown): boolean;
|
|
7
|
-
export {};
|
package/dist/types/report.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ErrorCode, ErrorParam } from './errors.js';
|
|
2
|
-
import type { JsonSchema, JsonSchemaInternal } from './json-schema-versions.js';
|
|
2
|
+
import type { JsonSchema, JsonSchemaAll, JsonSchemaInternal } from './json-schema-versions.js';
|
|
3
3
|
import type { ValidateCallback, ValidateOptions } from './z-schema-base.js';
|
|
4
4
|
import type { ZSchemaOptions } from './z-schema-options.js';
|
|
5
5
|
export interface SchemaErrorDetail {
|
|
@@ -44,7 +44,7 @@ export interface SchemaErrorDetail {
|
|
|
44
44
|
* The schema keyword that caused this validation error.
|
|
45
45
|
* Example: "required", "type", "minLength"
|
|
46
46
|
*/
|
|
47
|
-
keyword?: keyof
|
|
47
|
+
keyword?: keyof JsonSchemaAll;
|
|
48
48
|
}
|
|
49
49
|
export interface ReportOptions {
|
|
50
50
|
maxErrors?: number;
|
|
@@ -57,6 +57,9 @@ type AsyncTask = [TaskFn, TaskFnArgs, TaskProcessFn];
|
|
|
57
57
|
export declare class Report {
|
|
58
58
|
asyncTasks: AsyncTask[];
|
|
59
59
|
commonErrorMessage?: string;
|
|
60
|
+
__$recursiveAnchorStack: JsonSchemaInternal[];
|
|
61
|
+
__$dynamicScopeStack: JsonSchemaInternal[];
|
|
62
|
+
__validationResultCache: Map<unknown, Map<unknown, boolean>>;
|
|
60
63
|
errors: SchemaErrorDetail[];
|
|
61
64
|
json?: unknown;
|
|
62
65
|
path: Array<number | string>;
|
|
@@ -71,14 +74,21 @@ export declare class Report {
|
|
|
71
74
|
constructor(parentReport: Report, reportOptions: ReportOptions, validateOptions?: ValidateOptions);
|
|
72
75
|
isValid(): boolean;
|
|
73
76
|
addAsyncTask<FV, FN extends (...args: any[]) => FV>(fn: FN, args: Parameters<FN>, asyncTaskResultProcessFn: (result: ReturnType<FN>) => void): void;
|
|
77
|
+
/**
|
|
78
|
+
* Like {@link addAsyncTask}, but automatically saves the current `path` and
|
|
79
|
+
* restores it around `processFn`. This eliminates the manual
|
|
80
|
+
* path-save/restore boilerplate that every async-aware validator would
|
|
81
|
+
* otherwise need.
|
|
82
|
+
*/
|
|
83
|
+
addAsyncTaskWithPath(fn: (...args: any[]) => any, args: any[], processFn: (result: any) => void): void;
|
|
74
84
|
getAncestor(id: string): Report | undefined;
|
|
75
85
|
processAsyncTasks(timeout: number | undefined, callback: ValidateCallback): void;
|
|
76
86
|
getPath(returnPathAsString?: boolean): string | (string | number)[];
|
|
77
87
|
getSchemaPath(): Array<string | number>;
|
|
78
88
|
getSchemaId(): string | undefined;
|
|
79
89
|
hasError(errCode: string, errParams: Array<any>): boolean;
|
|
80
|
-
addError(errCode: ErrorCode, errParams?: ErrorParam[], subReports?: Report | Report[], schema?: JsonSchema | boolean, keyword?: keyof
|
|
90
|
+
addError(errCode: ErrorCode, errParams?: ErrorParam[], subReports?: Report | Report[], schema?: JsonSchema | boolean, keyword?: keyof JsonSchemaAll): void;
|
|
81
91
|
getJson(): unknown;
|
|
82
|
-
addCustomError(errorCode: ErrorCode, errorMessage: string, params?: ErrorParam[], subReports?: Report | Report[], schema?: JsonSchema | boolean, keyword?: keyof
|
|
92
|
+
addCustomError(errorCode: ErrorCode, errorMessage: string, params?: ErrorParam[], subReports?: Report | Report[], schema?: JsonSchema | boolean, keyword?: keyof JsonSchemaAll): void;
|
|
83
93
|
}
|
|
84
94
|
export {};
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import type { JsonSchema, JsonSchemaInternal } from './json-schema-versions.js';
|
|
2
2
|
import type { ZSchemaBase } from './z-schema-base.js';
|
|
3
|
+
import type { ZSchemaOptions } from './z-schema-options.js';
|
|
3
4
|
import { Report } from './report.js';
|
|
4
5
|
export type SchemaCacheStorage = Record<string, JsonSchemaInternal>;
|
|
5
6
|
export type ReferenceSchemaCacheStorage = Array<[JsonSchemaInternal, JsonSchemaInternal]>;
|
|
7
|
+
/**
|
|
8
|
+
* Shared logic for registering a remote reference schema.
|
|
9
|
+
* Used by both the static `ZSchema.setRemoteReference()` (global cache) and
|
|
10
|
+
* the instance `validator.setRemoteReference()` (instance cache).
|
|
11
|
+
*/
|
|
12
|
+
export declare function prepareRemoteSchema(schema: string | JsonSchema, uri: string, validationOptions?: ZSchemaOptions, maxCloneDepth?: number): JsonSchemaInternal;
|
|
6
13
|
export declare class SchemaCache {
|
|
7
14
|
private validator;
|
|
8
15
|
static global_cache: SchemaCacheStorage;
|
|
@@ -8,14 +8,16 @@ interface Id {
|
|
|
8
8
|
absoluteParent?: Id;
|
|
9
9
|
absoluteUri?: string;
|
|
10
10
|
}
|
|
11
|
-
export declare const collectIds: (obj: JsonSchemaInternal) => Id[];
|
|
11
|
+
export declare const collectIds: (obj: JsonSchemaInternal, maxDepth?: number) => Id[];
|
|
12
12
|
export interface Reference {
|
|
13
13
|
ref: string;
|
|
14
|
-
key: '$ref' | '$schema';
|
|
14
|
+
key: '$ref' | '$schema' | '$recursiveRef' | '$dynamicRef';
|
|
15
15
|
obj: JsonSchemaInternal;
|
|
16
16
|
path: Array<string | number>;
|
|
17
17
|
}
|
|
18
|
-
export declare const collectReferences: (obj: JsonSchemaInternal, results?: Reference[], scope?: string[], path?: Reference["path"]
|
|
18
|
+
export declare const collectReferences: (obj: JsonSchemaInternal, results?: Reference[], scope?: string[], path?: Reference["path"], options?: {
|
|
19
|
+
useRefObjectScope?: boolean;
|
|
20
|
+
}, maxDepth?: number, _depth?: number) => Reference[];
|
|
19
21
|
export declare class SchemaCompiler {
|
|
20
22
|
private validator;
|
|
21
23
|
constructor(validator: ZSchemaBase);
|
|
@@ -5,6 +5,6 @@ export declare class SchemaValidator {
|
|
|
5
5
|
private validator;
|
|
6
6
|
constructor(validator: ZSchemaBase);
|
|
7
7
|
get options(): import("./z-schema-options.js").ZSchemaOptions;
|
|
8
|
-
validateArrayOfSchemas(report: Report, arr: JsonSchemaInternal
|
|
9
|
-
validateSchema(report: Report, schema: JsonSchemaInternal | JsonSchemaInternal
|
|
8
|
+
validateArrayOfSchemas(report: Report, arr: Array<JsonSchemaInternal | boolean>): boolean;
|
|
9
|
+
validateSchema(report: Report, schema: JsonSchemaInternal | boolean | Array<JsonSchemaInternal | boolean>): boolean;
|
|
10
10
|
}
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Check if all elements in an array are unique.
|
|
3
|
+
*
|
|
4
|
+
* Uses a Set-based fast path for arrays of pure primitives (O(n)).
|
|
5
|
+
* Falls back to pairwise deep comparison (O(n²)) when the array contains
|
|
6
|
+
* objects or arrays that need structural equality checks.
|
|
7
|
+
*/
|
|
8
|
+
export declare const isUniqueArray: <T>(arr: T[], indexes?: number[], maxDepth?: number) => boolean;
|
|
2
9
|
export declare const difference: (bigSet: any[], subSet: any[]) => any[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const shallowClone: <T>(src: T) => T;
|
|
2
|
-
export declare const deepClone: <T>(src: T) => T;
|
|
2
|
+
export declare const deepClone: <T>(src: T, maxDepth?: number) => T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isValidRfc3339Date: (year: number, month: number, day: number) => boolean;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
interface AreEqualOptions {
|
|
2
2
|
caseInsensitiveComparison?: boolean;
|
|
3
|
+
maxDepth?: number;
|
|
3
4
|
}
|
|
4
|
-
export declare const areEqual: (json1: unknown, json2: unknown, options?: AreEqualOptions) => boolean;
|
|
5
|
+
export declare const areEqual: (json1: unknown, json2: unknown, options?: AreEqualOptions, _depth?: number) => boolean;
|
|
5
6
|
export declare const decodeJSONPointer: (str: string) => string;
|
|
6
7
|
export declare const sortedKeys: (obj: Record<string, unknown>) => string[];
|
|
7
8
|
export declare const get: (obj: any, path: string | Array<string | number>) => any;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const toUtcTime: (hour: number, minute: number, offsetSign: "+" | "-", offsetHour: number, offsetMinute: number) => {
|
|
2
|
+
hour: number;
|
|
3
|
+
minute: number;
|
|
4
|
+
};
|
|
5
|
+
export interface ParsedRfc3339Time {
|
|
6
|
+
hour: number;
|
|
7
|
+
minute: number;
|
|
8
|
+
second: number;
|
|
9
|
+
utcHour: number;
|
|
10
|
+
utcMinute: number;
|
|
11
|
+
}
|
|
12
|
+
export declare const parseRfc3339Time: (time: string) => ParsedRfc3339Time | null;
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* this function will convert a pair of surrogate halves (each of which
|
|
5
|
-
* UCS-2 exposes as separate characters) into a single code point,
|
|
6
|
-
* matching UTF-16.
|
|
7
|
-
* @see `punycode.ucs2.encode`
|
|
8
|
-
* @see <https://mathiasbynens.be/notes/javascript-encoding>
|
|
9
|
-
* @memberOf punycode.ucs2
|
|
10
|
-
* @name decode
|
|
11
|
-
* @param {String} string The Unicode input string (UCS-2).
|
|
12
|
-
* @returns {Array} The new array of code points.
|
|
2
|
+
* Returns the number of Unicode code points in the string.
|
|
3
|
+
* Uses the built-in string iterator which correctly handles surrogate pairs.
|
|
13
4
|
*/
|
|
14
|
-
export declare function
|
|
5
|
+
export declare function unicodeLength(str: string): number;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { JsonSchemaInternal } from '../json-schema-versions.js';
|
|
2
|
+
import type { Report } from '../report.js';
|
|
3
|
+
import type { ZSchemaBase } from '../z-schema-base.js';
|
|
4
|
+
export declare function additionalItemsValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
5
|
+
export declare function itemsValidator(): void;
|
|
6
|
+
export declare function prefixItemsValidator(): void;
|
|
7
|
+
export declare function maxItemsValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
8
|
+
export declare function minItemsValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
9
|
+
export declare function uniqueItemsValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
10
|
+
export declare function containsValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
11
|
+
export declare function maxContainsValidator(): void;
|
|
12
|
+
export declare function minContainsValidator(): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { JsonSchemaInternal } from '../json-schema-versions.js';
|
|
2
|
+
import type { ZSchemaBase } from '../z-schema-base.js';
|
|
3
|
+
import { Report } from '../report.js';
|
|
4
|
+
export declare function allOfValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
5
|
+
export declare function anyOfValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
6
|
+
export declare function oneOfValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
7
|
+
export declare function notValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
8
|
+
export declare function ifValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
9
|
+
export declare function thenValidator(): void;
|
|
10
|
+
export declare function elseValidator(): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { JsonSchemaInternal } from '../json-schema-versions.js';
|
|
2
|
+
import type { Report } from '../report.js';
|
|
3
|
+
import type { ZSchemaBase } from '../z-schema-base.js';
|
|
4
|
+
export declare function multipleOfValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
5
|
+
export declare function maximumValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
6
|
+
export declare function exclusiveMaximumValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
7
|
+
export declare function minimumValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
8
|
+
export declare function exclusiveMinimumValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { JsonSchemaInternal } from '../json-schema-versions.js';
|
|
2
|
+
import type { Report } from '../report.js';
|
|
3
|
+
import type { ZSchemaBase } from '../z-schema-base.js';
|
|
4
|
+
export declare function maxPropertiesValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
5
|
+
export declare function minPropertiesValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
6
|
+
export declare function requiredValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
7
|
+
export declare function additionalPropertiesValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
8
|
+
export declare function patternPropertiesValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
9
|
+
export declare function propertiesValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
10
|
+
export declare function dependenciesValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
11
|
+
export declare function dependentSchemasValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
12
|
+
export declare function dependentRequiredValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
13
|
+
export declare function propertyNamesValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { JsonSchemaInternal } from '../json-schema-versions.js';
|
|
2
|
+
export declare const getDynamicRefAnchorName: (dynamicRef: string) => string | undefined;
|
|
3
|
+
export declare const findDynamicAnchorInScope: (scopeSchema: JsonSchemaInternal, anchorName: string) => JsonSchemaInternal | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* Resolves the effective target for a $recursiveRef, walking the recursive anchor stack.
|
|
6
|
+
*/
|
|
7
|
+
export declare const resolveRecursiveRef: (schema: JsonSchemaInternal, recursiveAnchorStack: JsonSchemaInternal[]) => JsonSchemaInternal | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Resolves the effective target for a $dynamicRef, walking the dynamic scope stack.
|
|
10
|
+
*/
|
|
11
|
+
export declare const resolveDynamicRef: (schema: JsonSchemaInternal, dynamicScopeStack: JsonSchemaInternal[]) => JsonSchemaInternal | boolean | undefined;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { JsonSchema, JsonSchemaAll, JsonSchemaInternal, JsonSchemaVersion } from '../json-schema-versions.js';
|
|
2
|
+
import type { Report } from '../report.js';
|
|
3
|
+
import type { ValidateOptions, ZSchemaBase } from '../z-schema-base.js';
|
|
4
|
+
export type JsonValidatorFn = (this: ZSchemaBase, report: Report, schema: JsonSchema, json: unknown) => void;
|
|
5
|
+
export declare const shouldSkipValidate: (options: ValidateOptions, errors: any) => boolean;
|
|
6
|
+
export declare const supportsDependentKeywords: (schema: JsonSchemaInternal, version: JsonSchemaVersion | "none" | undefined) => boolean;
|
|
7
|
+
export declare const VALIDATION_VOCAB_KEYWORDS: Set<keyof JsonSchemaAll>;
|
|
8
|
+
export declare const isValidationVocabularyEnabled: (schema: JsonSchemaInternal, report: Report, version: JsonSchemaVersion | "none" | undefined) => boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Checks whether the format-assertion vocabulary is enabled in the meta-schema.
|
|
11
|
+
* For draft 2019-09: checks if the format vocabulary is set to true.
|
|
12
|
+
* For draft 2020-12: checks if the format-assertion vocabulary is present and true.
|
|
13
|
+
* Returns true for older drafts (format was always an assertion).
|
|
14
|
+
*/
|
|
15
|
+
export declare const isFormatAssertionVocabEnabled: (schema: JsonSchemaInternal, report: Report, version: JsonSchemaVersion | "none" | undefined) => boolean;
|
|
16
|
+
export declare function cacheValidationResult(report: Report, schema: unknown, json: unknown, passed: boolean): void;
|
|
17
|
+
export declare function getCachedValidationResult(report: Report, schema: unknown, json: unknown): boolean | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Shared async-task aggregation pattern.
|
|
20
|
+
*
|
|
21
|
+
* 1. Collects async tasks from `subReports` into `report`.
|
|
22
|
+
* 2. If new async tasks were added, defers `decisionFn` via `report.addAsyncTask`
|
|
23
|
+
* with proper path save/restore so error paths are correct.
|
|
24
|
+
* 3. Otherwise, runs `decisionFn` synchronously.
|
|
25
|
+
*/
|
|
26
|
+
export declare function deferOrRunSync(report: Report, subReports: Report[], decisionFn: () => void): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { JsonSchemaInternal } from '../json-schema-versions.js';
|
|
2
|
+
import type { Report } from '../report.js';
|
|
3
|
+
import type { ZSchemaBase } from '../z-schema-base.js';
|
|
4
|
+
export declare function minLengthValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
5
|
+
export declare function maxLengthValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
6
|
+
export declare function patternValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
7
|
+
export declare function formatValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
8
|
+
export declare function contentEncodingValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
9
|
+
export declare function contentMediaTypeValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { JsonSchemaInternal } from '../json-schema-versions.js';
|
|
2
|
+
import type { Report } from '../report.js';
|
|
3
|
+
import type { ZSchemaBase } from '../z-schema-base.js';
|
|
4
|
+
export declare function typeValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
5
|
+
export declare function enumValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
6
|
+
export declare function constValidator(this: ZSchemaBase, report: Report, schema: JsonSchemaInternal, json: unknown): void;
|
|
@@ -16,25 +16,63 @@ export type ValidateResponse = {
|
|
|
16
16
|
err?: ValidateError;
|
|
17
17
|
};
|
|
18
18
|
export type ValidateCallback = (err: ValidateResponse['err'], valid: ValidateResponse['valid']) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Module-private symbol used by `ZSchema.create()` to authorise construction.
|
|
21
|
+
* Not exported — external code cannot instantiate ZSchema variants directly.
|
|
22
|
+
*/
|
|
23
|
+
export declare const FACTORY_TOKEN: unique symbol;
|
|
19
24
|
export declare class ZSchemaBase {
|
|
20
25
|
scache: SchemaCache;
|
|
21
26
|
sc: SchemaCompiler;
|
|
22
27
|
sv: SchemaValidator;
|
|
23
28
|
validateOptions: ValidateOptions;
|
|
24
29
|
options: ZSchemaOptions;
|
|
25
|
-
constructor(options
|
|
30
|
+
constructor(options: ZSchemaOptions | undefined, token: symbol);
|
|
26
31
|
getDefaultSchemaId(): string;
|
|
27
32
|
_validate(json: unknown, schema: JsonSchema | string, options: ValidateOptions, callback: ValidateCallback): void;
|
|
28
33
|
_validate(json: unknown, schema: JsonSchema | string, callback: ValidateCallback): void;
|
|
29
34
|
_validate(json: unknown, schema: JsonSchema | string, options: ValidateOptions): true;
|
|
30
35
|
_validate(json: unknown, schema: JsonSchema | string): true;
|
|
31
36
|
_validateSchema(schemaOrArr: JsonSchema | JsonSchema[]): true;
|
|
37
|
+
/**
|
|
38
|
+
* Register a format validator on this instance only (does not affect other instances or the global registry).
|
|
39
|
+
* @param name - The format name.
|
|
40
|
+
* @param validatorFunction - A sync or async function `(value: unknown) => boolean | Promise<boolean>`.
|
|
41
|
+
*/
|
|
32
42
|
registerFormat(name: string, validatorFunction: FormatValidatorFn): void;
|
|
43
|
+
/**
|
|
44
|
+
* Unregister an instance-scoped format validator.
|
|
45
|
+
* @param name - The format name to unregister.
|
|
46
|
+
*/
|
|
33
47
|
unregisterFormat(name: string): void;
|
|
48
|
+
/** Returns the names of format validators registered on this instance. */
|
|
34
49
|
getRegisteredFormats(): string[];
|
|
50
|
+
/** Returns all supported format names (global + instance-registered). */
|
|
35
51
|
getSupportedFormats(): string[];
|
|
52
|
+
/**
|
|
53
|
+
* Register a remote schema in this instance's cache so `$ref` can resolve to it.
|
|
54
|
+
* @param uri - The URI the schema will be known by.
|
|
55
|
+
* @param schema - The schema object or JSON string.
|
|
56
|
+
* @param validationOptions - Optional options used for schema preparation.
|
|
57
|
+
*/
|
|
36
58
|
setRemoteReference(uri: string, schema: string | JsonSchema, validationOptions?: ZSchemaOptions): void;
|
|
59
|
+
/**
|
|
60
|
+
* Extract unresolvable `$ref` URIs from a validation error.
|
|
61
|
+
* @param err - A `ValidateError` from a failed validation.
|
|
62
|
+
* @returns An array of unresolvable reference URIs.
|
|
63
|
+
*/
|
|
37
64
|
getMissingReferences(err: ValidateError): string[];
|
|
65
|
+
/**
|
|
66
|
+
* Extract unresolvable **remote** `$ref` URIs from a validation error (local fragment-only refs are excluded).
|
|
67
|
+
* @param err - A `ValidateError` from a failed validation.
|
|
68
|
+
* @returns An array of remote reference base URIs.
|
|
69
|
+
*/
|
|
38
70
|
getMissingRemoteReferences(err: ValidateError): string[];
|
|
71
|
+
/**
|
|
72
|
+
* Resolve a previously compiled schema by its `$id` / `id`, cleaning up internal bookkeeping properties
|
|
73
|
+
* and inlining resolved `$ref` targets.
|
|
74
|
+
* @param schemaId - The schema identifier to look up.
|
|
75
|
+
* @returns A clean, resolved copy of the schema, or `undefined` if not found.
|
|
76
|
+
*/
|
|
39
77
|
getResolvedSchema(schemaId: string): JsonSchema | undefined;
|
|
40
78
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { FormatValidatorFn } from './format-validators.js';
|
|
2
2
|
import type { Report } from './report.js';
|
|
3
3
|
import { type JsonSchemaVersion } from './json-schema-versions.js';
|
|
4
|
+
export declare const DEFAULT_MAX_RECURSION_DEPTH = 100;
|
|
4
5
|
export interface ZSchemaOptions {
|
|
5
6
|
version?: JsonSchemaVersion | 'none';
|
|
6
7
|
asyncTimeout?: number;
|
|
@@ -24,8 +25,10 @@ export interface ZSchemaOptions {
|
|
|
24
25
|
breakOnFirstError?: boolean;
|
|
25
26
|
pedanticCheck?: boolean;
|
|
26
27
|
ignoreUnknownFormats?: boolean;
|
|
28
|
+
formatAssertions?: boolean | null;
|
|
27
29
|
customValidator?: (report: Report, schema: unknown, json: unknown) => void;
|
|
28
30
|
customFormats?: Record<string, FormatValidatorFn | null>;
|
|
31
|
+
maxRecursionDepth?: number;
|
|
29
32
|
}
|
|
30
33
|
export declare const defaultOptions: ZSchemaOptions;
|
|
31
34
|
export declare const normalizeOptions: (options?: ZSchemaOptions) => ZSchemaOptions;
|