baobox 0.1.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 +193 -0
- package/dist/compile/bun-fast-path.d.ts +14 -0
- package/dist/compile/bun-fast-path.d.ts.map +1 -0
- package/dist/compile/emit.d.ts +5 -0
- package/dist/compile/emit.d.ts.map +1 -0
- package/dist/compile/index.d.ts +57 -0
- package/dist/compile/index.d.ts.map +1 -0
- package/dist/compile/index.js +4711 -0
- package/dist/compile/index.js.map +65 -0
- package/dist/error/catalog-types.d.ts +30 -0
- package/dist/error/catalog-types.d.ts.map +1 -0
- package/dist/error/collector/advanced.d.ts +5 -0
- package/dist/error/collector/advanced.d.ts.map +1 -0
- package/dist/error/collector/collections-basic.d.ts +5 -0
- package/dist/error/collector/collections-basic.d.ts.map +1 -0
- package/dist/error/collector/collections-derived.d.ts +5 -0
- package/dist/error/collector/collections-derived.d.ts.map +1 -0
- package/dist/error/collector/collections-parameters.d.ts +5 -0
- package/dist/error/collector/collections-parameters.d.ts.map +1 -0
- package/dist/error/collector/collections.d.ts +5 -0
- package/dist/error/collector/collections.d.ts.map +1 -0
- package/dist/error/collector/primitives.d.ts +5 -0
- package/dist/error/collector/primitives.d.ts.map +1 -0
- package/dist/error/collector/shared.d.ts +6 -0
- package/dist/error/collector/shared.d.ts.map +1 -0
- package/dist/error/collector.d.ts +5 -0
- package/dist/error/collector.d.ts.map +1 -0
- package/dist/error/errors.d.ts +23 -0
- package/dist/error/errors.d.ts.map +1 -0
- package/dist/error/index.d.ts +11 -0
- package/dist/error/index.d.ts.map +1 -0
- package/dist/error/index.js +3163 -0
- package/dist/error/index.js.map +53 -0
- package/dist/error/locales/de.d.ts +3 -0
- package/dist/error/locales/de.d.ts.map +1 -0
- package/dist/error/locales/en.d.ts +3 -0
- package/dist/error/locales/en.d.ts.map +1 -0
- package/dist/error/locales/es.d.ts +3 -0
- package/dist/error/locales/es.d.ts.map +1 -0
- package/dist/error/locales/fr.d.ts +3 -0
- package/dist/error/locales/fr.d.ts.map +1 -0
- package/dist/error/locales/ja.d.ts +3 -0
- package/dist/error/locales/ja.d.ts.map +1 -0
- package/dist/error/locales/ko.d.ts +3 -0
- package/dist/error/locales/ko.d.ts.map +1 -0
- package/dist/error/locales/pt.d.ts +3 -0
- package/dist/error/locales/pt.d.ts.map +1 -0
- package/dist/error/locales/shared.d.ts +4 -0
- package/dist/error/locales/shared.d.ts.map +1 -0
- package/dist/error/locales/zh.d.ts +4 -0
- package/dist/error/locales/zh.d.ts.map +1 -0
- package/dist/error/messages.d.ts +7 -0
- package/dist/error/messages.d.ts.map +1 -0
- package/dist/format/format.d.ts +61 -0
- package/dist/format/format.d.ts.map +1 -0
- package/dist/format/index.d.ts +5 -0
- package/dist/format/index.d.ts.map +1 -0
- package/dist/format/index.js +1475 -0
- package/dist/format/index.js.map +29 -0
- package/dist/guard/guard.d.ts +73 -0
- package/dist/guard/guard.d.ts.map +1 -0
- package/dist/guard/index.d.ts +7 -0
- package/dist/guard/index.d.ts.map +1 -0
- package/dist/guard/index.js +342 -0
- package/dist/guard/index.js.map +11 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8938 -0
- package/dist/index.js.map +104 -0
- package/dist/locale/index.d.ts +124 -0
- package/dist/locale/index.d.ts.map +1 -0
- package/dist/locale/index.js +564 -0
- package/dist/locale/index.js.map +20 -0
- package/dist/schema/build.d.ts +32 -0
- package/dist/schema/build.d.ts.map +1 -0
- package/dist/schema/check.d.ts +6 -0
- package/dist/schema/check.d.ts.map +1 -0
- package/dist/schema/compile.d.ts +16 -0
- package/dist/schema/compile.d.ts.map +1 -0
- package/dist/schema/core-keywords.d.ts +8 -0
- package/dist/schema/core-keywords.d.ts.map +1 -0
- package/dist/schema/core.d.ts +3 -0
- package/dist/schema/core.d.ts.map +1 -0
- package/dist/schema/emitter-advanced.d.ts +6 -0
- package/dist/schema/emitter-advanced.d.ts.map +1 -0
- package/dist/schema/emitter-base.d.ts +8 -0
- package/dist/schema/emitter-base.d.ts.map +1 -0
- package/dist/schema/emitter-derived.d.ts +5 -0
- package/dist/schema/emitter-derived.d.ts.map +1 -0
- package/dist/schema/emitter-reference.d.ts +5 -0
- package/dist/schema/emitter-reference.d.ts.map +1 -0
- package/dist/schema/emitter-types.d.ts +5 -0
- package/dist/schema/emitter-types.d.ts.map +1 -0
- package/dist/schema/emitter-wrapper.d.ts +5 -0
- package/dist/schema/emitter-wrapper.d.ts.map +1 -0
- package/dist/schema/emitter.d.ts +52 -0
- package/dist/schema/emitter.d.ts.map +1 -0
- package/dist/schema/engine.d.ts +61 -0
- package/dist/schema/engine.d.ts.map +1 -0
- package/dist/schema/error-collector.d.ts +4 -0
- package/dist/schema/error-collector.d.ts.map +1 -0
- package/dist/schema/errors.d.ts +7 -0
- package/dist/schema/errors.d.ts.map +1 -0
- package/dist/schema/index.d.ts +4 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +3661 -0
- package/dist/schema/index.js.map +50 -0
- package/dist/schema/parse.d.ts +14 -0
- package/dist/schema/parse.d.ts.map +1 -0
- package/dist/schema/pointer.d.ts +13 -0
- package/dist/schema/pointer.d.ts.map +1 -0
- package/dist/schema/predicates.d.ts +62 -0
- package/dist/schema/predicates.d.ts.map +1 -0
- package/dist/schema/resolve.d.ts +6 -0
- package/dist/schema/resolve.d.ts.map +1 -0
- package/dist/schema/runtime-keywords.d.ts +136 -0
- package/dist/schema/runtime-keywords.d.ts.map +1 -0
- package/dist/schema/schema.d.ts +14 -0
- package/dist/schema/schema.d.ts.map +1 -0
- package/dist/schema/shared.d.ts +61 -0
- package/dist/schema/shared.d.ts.map +1 -0
- package/dist/script/generic.d.ts +3 -0
- package/dist/script/generic.d.ts.map +1 -0
- package/dist/script/index.d.ts +7 -0
- package/dist/script/index.d.ts.map +1 -0
- package/dist/script/index.js +3948 -0
- package/dist/script/index.js.map +55 -0
- package/dist/script/literals.d.ts +5 -0
- package/dist/script/literals.d.ts.map +1 -0
- package/dist/script/shared.d.ts +15 -0
- package/dist/script/shared.d.ts.map +1 -0
- package/dist/shared/bytes.d.ts +9 -0
- package/dist/shared/bytes.d.ts.map +1 -0
- package/dist/shared/format-constants.d.ts +16 -0
- package/dist/shared/format-constants.d.ts.map +1 -0
- package/dist/shared/format-validators.d.ts +13 -0
- package/dist/shared/format-validators.d.ts.map +1 -0
- package/dist/shared/locale.d.ts +43 -0
- package/dist/shared/locale.d.ts.map +1 -0
- package/dist/shared/object-utils.d.ts +21 -0
- package/dist/shared/object-utils.d.ts.map +1 -0
- package/dist/shared/regex-json.d.ts +5 -0
- package/dist/shared/regex-json.d.ts.map +1 -0
- package/dist/shared/registries.d.ts +41 -0
- package/dist/shared/registries.d.ts.map +1 -0
- package/dist/shared/runtime-context.d.ts +109 -0
- package/dist/shared/runtime-context.d.ts.map +1 -0
- package/dist/shared/runtime-guards.d.ts +7 -0
- package/dist/shared/runtime-guards.d.ts.map +1 -0
- package/dist/shared/schema-access.d.ts +34 -0
- package/dist/shared/schema-access.d.ts.map +1 -0
- package/dist/shared/utils.d.ts +9 -0
- package/dist/shared/utils.d.ts.map +1 -0
- package/dist/shared/utils.js +1321 -0
- package/dist/shared/utils.js.map +27 -0
- package/dist/standard/index.d.ts +51 -0
- package/dist/standard/index.d.ts.map +1 -0
- package/dist/standard/index.js +4551 -0
- package/dist/standard/index.js.map +66 -0
- package/dist/system/index.d.ts +5 -0
- package/dist/system/index.d.ts.map +1 -0
- package/dist/system/index.js +1632 -0
- package/dist/system/index.js.map +33 -0
- package/dist/system/system.d.ts +154 -0
- package/dist/system/system.d.ts.map +1 -0
- package/dist/type/actions.d.ts +48 -0
- package/dist/type/actions.d.ts.map +1 -0
- package/dist/type/base-types.d.ts +5 -0
- package/dist/type/base-types.d.ts.map +1 -0
- package/dist/type/codec-builtins.d.ts +9 -0
- package/dist/type/codec-builtins.d.ts.map +1 -0
- package/dist/type/combinator-core.d.ts +26 -0
- package/dist/type/combinator-core.d.ts.map +1 -0
- package/dist/type/combinator-functions.d.ts +16 -0
- package/dist/type/combinator-functions.d.ts.map +1 -0
- package/dist/type/combinator-objects.d.ts +30 -0
- package/dist/type/combinator-objects.d.ts.map +1 -0
- package/dist/type/combinators.d.ts +4 -0
- package/dist/type/combinators.d.ts.map +1 -0
- package/dist/type/composite-types.d.ts +39 -0
- package/dist/type/composite-types.d.ts.map +1 -0
- package/dist/type/containers-types.d.ts +47 -0
- package/dist/type/containers-types.d.ts.map +1 -0
- package/dist/type/containers.d.ts +7 -0
- package/dist/type/containers.d.ts.map +1 -0
- package/dist/type/extends.d.ts +32 -0
- package/dist/type/extends.d.ts.map +1 -0
- package/dist/type/extensions.d.ts +86 -0
- package/dist/type/extensions.d.ts.map +1 -0
- package/dist/type/guards.d.ts +78 -0
- package/dist/type/guards.d.ts.map +1 -0
- package/dist/type/index.d.ts +29 -0
- package/dist/type/index.d.ts.map +1 -0
- package/dist/type/index.js +4049 -0
- package/dist/type/index.js.map +51 -0
- package/dist/type/instantiation.d.ts +10 -0
- package/dist/type/instantiation.d.ts.map +1 -0
- package/dist/type/kind.d.ts +76 -0
- package/dist/type/kind.d.ts.map +1 -0
- package/dist/type/narrow-types.d.ts +23 -0
- package/dist/type/narrow-types.d.ts.map +1 -0
- package/dist/type/primitives-types.d.ts +103 -0
- package/dist/type/primitives-types.d.ts.map +1 -0
- package/dist/type/primitives.d.ts +81 -0
- package/dist/type/primitives.d.ts.map +1 -0
- package/dist/type/root-constants.d.ts +65 -0
- package/dist/type/root-constants.d.ts.map +1 -0
- package/dist/type/root-cyclic.d.ts +12 -0
- package/dist/type/root-cyclic.d.ts.map +1 -0
- package/dist/type/root-deferred.d.ts +39 -0
- package/dist/type/root-deferred.d.ts.map +1 -0
- package/dist/type/root-guards.d.ts +15 -0
- package/dist/type/root-guards.d.ts.map +1 -0
- package/dist/type/root-helpers.d.ts +28 -0
- package/dist/type/root-helpers.d.ts.map +1 -0
- package/dist/type/root-instantiate.d.ts +33 -0
- package/dist/type/root-instantiate.d.ts.map +1 -0
- package/dist/type/root-shared.d.ts +14 -0
- package/dist/type/root-shared.d.ts.map +1 -0
- package/dist/type/root-template.d.ts +15 -0
- package/dist/type/root-template.d.ts.map +1 -0
- package/dist/type/schema.d.ts +10 -0
- package/dist/type/schema.d.ts.map +1 -0
- package/dist/type/static-const-types.d.ts +25 -0
- package/dist/type/static-const-types.d.ts.map +1 -0
- package/dist/type/static-shared-types.d.ts +17 -0
- package/dist/type/static-shared-types.d.ts.map +1 -0
- package/dist/type/static-types.d.ts +39 -0
- package/dist/type/static-types.d.ts.map +1 -0
- package/dist/type/string-action-types.d.ts +24 -0
- package/dist/type/string-action-types.d.ts.map +1 -0
- package/dist/type/transform-types.d.ts +54 -0
- package/dist/type/transform-types.d.ts.map +1 -0
- package/dist/type/uint8array-codec.d.ts +8 -0
- package/dist/type/uint8array-codec.d.ts.map +1 -0
- package/dist/type/wrapper-types.d.ts +71 -0
- package/dist/type/wrapper-types.d.ts.map +1 -0
- package/dist/typebox.d.ts +3 -0
- package/dist/typebox.d.ts.map +1 -0
- package/dist/typebox.js +4767 -0
- package/dist/typebox.js.map +55 -0
- package/dist/value/assert.d.ts +8 -0
- package/dist/value/assert.d.ts.map +1 -0
- package/dist/value/check-collections-derived.d.ts +6 -0
- package/dist/value/check-collections-derived.d.ts.map +1 -0
- package/dist/value/check-collections.d.ts +5 -0
- package/dist/value/check-collections.d.ts.map +1 -0
- package/dist/value/check-extensions.d.ts +3 -0
- package/dist/value/check-extensions.d.ts.map +1 -0
- package/dist/value/check-primitives.d.ts +4 -0
- package/dist/value/check-primitives.d.ts.map +1 -0
- package/dist/value/check.d.ts +13 -0
- package/dist/value/check.d.ts.map +1 -0
- package/dist/value/clean.d.ts +4 -0
- package/dist/value/clean.d.ts.map +1 -0
- package/dist/value/clone.d.ts +3 -0
- package/dist/value/clone.d.ts.map +1 -0
- package/dist/value/convert.d.ts +4 -0
- package/dist/value/convert.d.ts.map +1 -0
- package/dist/value/create.d.ts +4 -0
- package/dist/value/create.d.ts.map +1 -0
- package/dist/value/decode.d.ts +4 -0
- package/dist/value/decode.d.ts.map +1 -0
- package/dist/value/default.d.ts +4 -0
- package/dist/value/default.d.ts.map +1 -0
- package/dist/value/diff.d.ts +9 -0
- package/dist/value/diff.d.ts.map +1 -0
- package/dist/value/encode.d.ts +4 -0
- package/dist/value/encode.d.ts.map +1 -0
- package/dist/value/equal.d.ts +3 -0
- package/dist/value/equal.d.ts.map +1 -0
- package/dist/value/has-codec.d.ts +3 -0
- package/dist/value/has-codec.d.ts.map +1 -0
- package/dist/value/hash.d.ts +3 -0
- package/dist/value/hash.d.ts.map +1 -0
- package/dist/value/index.d.ts +145 -0
- package/dist/value/index.d.ts.map +1 -0
- package/dist/value/index.js +4702 -0
- package/dist/value/index.js.map +71 -0
- package/dist/value/mutate.d.ts +3 -0
- package/dist/value/mutate.d.ts.map +1 -0
- package/dist/value/parse.d.ts +13 -0
- package/dist/value/parse.d.ts.map +1 -0
- package/dist/value/patch.d.ts +4 -0
- package/dist/value/patch.d.ts.map +1 -0
- package/dist/value/pipeline.d.ts +6 -0
- package/dist/value/pipeline.d.ts.map +1 -0
- package/dist/value/pointer.d.ts +8 -0
- package/dist/value/pointer.d.ts.map +1 -0
- package/dist/value/repair.d.ts +5 -0
- package/dist/value/repair.d.ts.map +1 -0
- package/dist/value/result.d.ts +10 -0
- package/dist/value/result.d.ts.map +1 -0
- package/docs/locale-packs.md +78 -0
- package/docs/package-contract.md +89 -0
- package/docs/parity-and-extensions.md +56 -0
- package/docs/script-module-registries.md +107 -0
- package/docs/workflows.md +154 -0
- package/package.json +117 -0
|
@@ -0,0 +1,3661 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __returnValue = (v) => v;
|
|
4
|
+
function __exportSetter(name, newValue) {
|
|
5
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
+
}
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
set: __exportSetter.bind(all, name)
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// src/error/locales/shared.ts
|
|
18
|
+
function formatList(values) {
|
|
19
|
+
return values === undefined ? "" : values.join(", ");
|
|
20
|
+
}
|
|
21
|
+
function labelFor(params, fallback) {
|
|
22
|
+
return params.label ?? fallback;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// src/error/locales/de.ts
|
|
26
|
+
var deDECatalog = {
|
|
27
|
+
INVALID_TYPE: (params) => params.actual === undefined ? `Erwartet: ${params.expected ?? "Wert"}` : `Erwartet: ${params.expected ?? "Wert"}, erhalten: ${params.actual}`,
|
|
28
|
+
MIN_LENGTH: (params) => `${labelFor(params, "Der Wert")} muss mindestens ${params.minimum} sein`,
|
|
29
|
+
MAX_LENGTH: (params) => `${labelFor(params, "Der Wert")} darf h\xF6chstens ${params.maximum} sein`,
|
|
30
|
+
PATTERN: (params) => params.patterns !== undefined ? `${labelFor(params, "Der Wert")} muss einem von folgenden Mustern entsprechen: ${formatList(params.patterns)}` : `${labelFor(params, "Der Wert")} muss dem Muster ${params.pattern} entsprechen`,
|
|
31
|
+
FORMAT: (params) => `${labelFor(params, "Der Wert")} muss dem Format ${params.format} entsprechen`,
|
|
32
|
+
MINIMUM: (params) => `${labelFor(params, "Der Wert")} muss >= ${params.minimum} sein`,
|
|
33
|
+
MAXIMUM: (params) => `${labelFor(params, "Der Wert")} muss <= ${params.maximum} sein`,
|
|
34
|
+
EXCLUSIVE_MINIMUM: (params) => `${labelFor(params, "Der Wert")} muss > ${params.minimum} sein`,
|
|
35
|
+
EXCLUSIVE_MAXIMUM: (params) => `${labelFor(params, "Der Wert")} muss < ${params.maximum} sein`,
|
|
36
|
+
MULTIPLE_OF: (params) => `${labelFor(params, "Der Wert")} muss ein Vielfaches von ${params.divisor} sein`,
|
|
37
|
+
INVALID_CONST: (params) => `Erwartet: ${params.expectedValue}`,
|
|
38
|
+
MIN_ITEMS: (params) => `${labelFor(params, "Das Array")} muss mindestens ${params.minimum} Elemente enthalten`,
|
|
39
|
+
MAX_ITEMS: (params) => `${labelFor(params, "Das Array")} darf h\xF6chstens ${params.maximum} Elemente enthalten`,
|
|
40
|
+
UNIQUE_ITEMS: (params) => `Die Elemente von ${labelFor(params, "diesem Array")} m\xFCssen eindeutig sein`,
|
|
41
|
+
CONTAINS: (params) => `${labelFor(params, "Das Array")} muss mindestens ein passendes Element enthalten`,
|
|
42
|
+
MIN_CONTAINS: (params) => `${labelFor(params, "Das Array")} muss mindestens ${params.minimum} passende Elemente enthalten`,
|
|
43
|
+
MAX_CONTAINS: (params) => `${labelFor(params, "Das Array")} darf h\xF6chstens ${params.maximum} passende Elemente enthalten`,
|
|
44
|
+
MISSING_REQUIRED: (params) => `Erforderliche Eigenschaft "${params.property}" fehlt`,
|
|
45
|
+
ADDITIONAL_PROPERTY: (params) => `Unerwartete Eigenschaft "${params.property}"`,
|
|
46
|
+
ADDITIONAL_ITEMS: (params) => `Unerwartetes Element an Index ${params.count}`,
|
|
47
|
+
MIN_PROPERTIES: (params) => `${labelFor(params, "Das Objekt")} muss mindestens ${params.minimum} Eigenschaften haben`,
|
|
48
|
+
MAX_PROPERTIES: (params) => `${labelFor(params, "Das Objekt")} darf h\xF6chstens ${params.maximum} Eigenschaften haben`,
|
|
49
|
+
INVALID_KEY: (params) => `Ung\xFCltiger Schl\xFCssel "${params.key}"`,
|
|
50
|
+
UNION: () => "Der Wert passt zu keiner Union-Variante",
|
|
51
|
+
ENUM: (params) => `Der Wert muss einer von folgenden sein: ${formatList(params.values)}`,
|
|
52
|
+
UNRESOLVED_REF: () => "Nicht aufgel\xF6ste Schema-Referenz",
|
|
53
|
+
EXCLUDE: () => "Der Wert entspricht einem ausgeschlossenen Schema",
|
|
54
|
+
EXTRACT: () => "Der Wert entspricht nicht dem extrahierten Schema",
|
|
55
|
+
NEVER: () => "Der Wert ist nicht erlaubt",
|
|
56
|
+
NOT: () => "Der Wert entspricht einem negierten Schema",
|
|
57
|
+
KEYOF: (params) => `Der Wert muss einer von folgenden sein: ${formatList(params.values)}`,
|
|
58
|
+
CONDITIONAL: () => "Der Wert passt zu keinem bedingten Zweig",
|
|
59
|
+
INDEX: () => "Der Wert passt zu keinem indexierten Schema",
|
|
60
|
+
IDENTIFIER: () => "G\xFCltiger Bezeichner erwartet",
|
|
61
|
+
BASE: () => "Basisvalidierung fehlgeschlagen",
|
|
62
|
+
REFINE: (params) => params.customMessage ?? "Verfeinerung fehlgeschlagen",
|
|
63
|
+
CALL: () => "Aufrufschema konnte nicht instanziiert werden",
|
|
64
|
+
PARAMETERS_LENGTH: (params) => `${params.count} Parameter erwartet`,
|
|
65
|
+
CUSTOM_TYPE: (params) => `Validierung des benutzerdefinierten Typs "${params.kind}" fehlgeschlagen`
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// src/error/locales/en.ts
|
|
69
|
+
var enUSCatalog = {
|
|
70
|
+
INVALID_TYPE: (params) => params.actual === undefined ? `Expected ${params.expected ?? "value"}` : `Expected ${params.expected ?? "value"}, got ${params.actual}`,
|
|
71
|
+
MIN_LENGTH: (params) => `${labelFor(params, "Value")} must be at least ${params.minimum}`,
|
|
72
|
+
MAX_LENGTH: (params) => `${labelFor(params, "Value")} must be at most ${params.maximum}`,
|
|
73
|
+
PATTERN: (params) => params.patterns !== undefined ? `${labelFor(params, "Value")} must match one of: ${formatList(params.patterns)}` : `${labelFor(params, "Value")} must match pattern ${params.pattern}`,
|
|
74
|
+
FORMAT: (params) => `${labelFor(params, "Value")} must match format ${params.format}`,
|
|
75
|
+
MINIMUM: (params) => `${labelFor(params, "Value")} must be >= ${params.minimum}`,
|
|
76
|
+
MAXIMUM: (params) => `${labelFor(params, "Value")} must be <= ${params.maximum}`,
|
|
77
|
+
EXCLUSIVE_MINIMUM: (params) => `${labelFor(params, "Value")} must be > ${params.minimum}`,
|
|
78
|
+
EXCLUSIVE_MAXIMUM: (params) => `${labelFor(params, "Value")} must be < ${params.maximum}`,
|
|
79
|
+
MULTIPLE_OF: (params) => `${labelFor(params, "Value")} must be a multiple of ${params.divisor}`,
|
|
80
|
+
INVALID_CONST: (params) => `Expected ${params.expectedValue}`,
|
|
81
|
+
MIN_ITEMS: (params) => `${labelFor(params, "Array")} must have at least ${params.minimum} items`,
|
|
82
|
+
MAX_ITEMS: (params) => `${labelFor(params, "Array")} must have at most ${params.maximum} items`,
|
|
83
|
+
UNIQUE_ITEMS: (params) => `${labelFor(params, "Array")} items must be unique`,
|
|
84
|
+
CONTAINS: (params) => `${labelFor(params, "Array")} must contain at least one matching item`,
|
|
85
|
+
MIN_CONTAINS: (params) => `${labelFor(params, "Array")} must contain at least ${params.minimum} matching items`,
|
|
86
|
+
MAX_CONTAINS: (params) => `${labelFor(params, "Array")} must contain at most ${params.maximum} matching items`,
|
|
87
|
+
MISSING_REQUIRED: (params) => `Missing required property "${params.property}"`,
|
|
88
|
+
ADDITIONAL_PROPERTY: (params) => `Unexpected property "${params.property}"`,
|
|
89
|
+
ADDITIONAL_ITEMS: (params) => `Unexpected item at index ${params.count}`,
|
|
90
|
+
MIN_PROPERTIES: (params) => `${labelFor(params, "Object")} must have at least ${params.minimum} properties`,
|
|
91
|
+
MAX_PROPERTIES: (params) => `${labelFor(params, "Object")} must have at most ${params.maximum} properties`,
|
|
92
|
+
INVALID_KEY: (params) => `Invalid record key "${params.key}"`,
|
|
93
|
+
UNION: () => "Value does not match any union variant",
|
|
94
|
+
ENUM: (params) => `Value must be one of: ${formatList(params.values)}`,
|
|
95
|
+
UNRESOLVED_REF: () => "Unresolved schema reference",
|
|
96
|
+
EXCLUDE: () => "Value matched an excluded schema",
|
|
97
|
+
EXTRACT: () => "Value did not match the extracted schema",
|
|
98
|
+
NEVER: () => "Value is not allowed",
|
|
99
|
+
NOT: () => "Value matches a negated schema",
|
|
100
|
+
KEYOF: (params) => `Value must be one of: ${formatList(params.values)}`,
|
|
101
|
+
CONDITIONAL: () => "Value does not match any conditional branch",
|
|
102
|
+
INDEX: () => "Value does not match any indexed schema",
|
|
103
|
+
IDENTIFIER: () => "Expected valid identifier string",
|
|
104
|
+
BASE: () => "Base validation failed",
|
|
105
|
+
REFINE: (params) => params.customMessage ?? "Refinement failed",
|
|
106
|
+
CALL: () => "Unable to instantiate call schema",
|
|
107
|
+
PARAMETERS_LENGTH: (params) => `Expected ${params.count} parameters`,
|
|
108
|
+
CUSTOM_TYPE: (params) => `Custom type validation failed for kind "${params.kind}"`
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
// src/error/locales/es.ts
|
|
112
|
+
var esESCatalog = {
|
|
113
|
+
INVALID_TYPE: (params) => params.actual === undefined ? `Se esperaba ${params.expected ?? "un valor"}` : `Se esperaba ${params.expected ?? "un valor"}, se recibi\xF3 ${params.actual}`,
|
|
114
|
+
MIN_LENGTH: (params) => `${labelFor(params, "El valor")} debe ser al menos ${params.minimum}`,
|
|
115
|
+
MAX_LENGTH: (params) => `${labelFor(params, "El valor")} debe ser como m\xE1ximo ${params.maximum}`,
|
|
116
|
+
PATTERN: (params) => params.patterns !== undefined ? `${labelFor(params, "El valor")} debe coincidir con uno de: ${formatList(params.patterns)}` : `${labelFor(params, "El valor")} debe coincidir con el patr\xF3n ${params.pattern}`,
|
|
117
|
+
FORMAT: (params) => `${labelFor(params, "El valor")} debe coincidir con el formato ${params.format}`,
|
|
118
|
+
MINIMUM: (params) => `${labelFor(params, "El valor")} debe ser >= ${params.minimum}`,
|
|
119
|
+
MAXIMUM: (params) => `${labelFor(params, "El valor")} debe ser <= ${params.maximum}`,
|
|
120
|
+
EXCLUSIVE_MINIMUM: (params) => `${labelFor(params, "El valor")} debe ser > ${params.minimum}`,
|
|
121
|
+
EXCLUSIVE_MAXIMUM: (params) => `${labelFor(params, "El valor")} debe ser < ${params.maximum}`,
|
|
122
|
+
MULTIPLE_OF: (params) => `${labelFor(params, "El valor")} debe ser m\xFAltiplo de ${params.divisor}`,
|
|
123
|
+
INVALID_CONST: (params) => `Se esperaba ${params.expectedValue}`,
|
|
124
|
+
MIN_ITEMS: (params) => `${labelFor(params, "El arreglo")} debe tener al menos ${params.minimum} elementos`,
|
|
125
|
+
MAX_ITEMS: (params) => `${labelFor(params, "El arreglo")} debe tener como m\xE1ximo ${params.maximum} elementos`,
|
|
126
|
+
UNIQUE_ITEMS: (params) => `Los elementos de ${labelFor(params, "este arreglo")} deben ser \xFAnicos`,
|
|
127
|
+
CONTAINS: (params) => `${labelFor(params, "El arreglo")} debe contener al menos un elemento coincidente`,
|
|
128
|
+
MIN_CONTAINS: (params) => `${labelFor(params, "El arreglo")} debe contener al menos ${params.minimum} elementos coincidentes`,
|
|
129
|
+
MAX_CONTAINS: (params) => `${labelFor(params, "El arreglo")} debe contener como m\xE1ximo ${params.maximum} elementos coincidentes`,
|
|
130
|
+
MISSING_REQUIRED: (params) => `Falta la propiedad requerida "${params.property}"`,
|
|
131
|
+
ADDITIONAL_PROPERTY: (params) => `Propiedad inesperada "${params.property}"`,
|
|
132
|
+
ADDITIONAL_ITEMS: (params) => `Elemento inesperado en el \xEDndice ${params.count}`,
|
|
133
|
+
MIN_PROPERTIES: (params) => `${labelFor(params, "El objeto")} debe tener al menos ${params.minimum} propiedades`,
|
|
134
|
+
MAX_PROPERTIES: (params) => `${labelFor(params, "El objeto")} debe tener como m\xE1ximo ${params.maximum} propiedades`,
|
|
135
|
+
INVALID_KEY: (params) => `Clave de registro no v\xE1lida "${params.key}"`,
|
|
136
|
+
UNION: () => "El valor no coincide con ninguna variante de la uni\xF3n",
|
|
137
|
+
ENUM: (params) => `El valor debe ser uno de: ${formatList(params.values)}`,
|
|
138
|
+
UNRESOLVED_REF: () => "Referencia de esquema no resuelta",
|
|
139
|
+
EXCLUDE: () => "El valor coincidi\xF3 con un esquema excluido",
|
|
140
|
+
EXTRACT: () => "El valor no coincidi\xF3 con el esquema extra\xEDdo",
|
|
141
|
+
NEVER: () => "El valor no est\xE1 permitido",
|
|
142
|
+
NOT: () => "El valor coincide con un esquema negado",
|
|
143
|
+
KEYOF: (params) => `El valor debe ser uno de: ${formatList(params.values)}`,
|
|
144
|
+
CONDITIONAL: () => "El valor no coincide con ninguna rama condicional",
|
|
145
|
+
INDEX: () => "El valor no coincide con ning\xFAn esquema indexado",
|
|
146
|
+
IDENTIFIER: () => "Se esperaba una cadena identificadora v\xE1lida",
|
|
147
|
+
BASE: () => "La validaci\xF3n base fall\xF3",
|
|
148
|
+
REFINE: (params) => params.customMessage ?? "La validaci\xF3n refinada fall\xF3",
|
|
149
|
+
CALL: () => "No se pudo instanciar el esquema de llamada",
|
|
150
|
+
PARAMETERS_LENGTH: (params) => `Se esperaban ${params.count} par\xE1metros`,
|
|
151
|
+
CUSTOM_TYPE: (params) => `La validaci\xF3n del tipo personalizado "${params.kind}" fall\xF3`
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// src/error/locales/fr.ts
|
|
155
|
+
var frFRCatalog = {
|
|
156
|
+
INVALID_TYPE: (params) => params.actual === undefined ? `Valeur attendue: ${params.expected ?? "valeur"}` : `Valeur attendue: ${params.expected ?? "valeur"}, re\xE7u: ${params.actual}`,
|
|
157
|
+
MIN_LENGTH: (params) => `${labelFor(params, "La valeur")} doit \xEAtre au moins ${params.minimum}`,
|
|
158
|
+
MAX_LENGTH: (params) => `${labelFor(params, "La valeur")} doit \xEAtre au plus ${params.maximum}`,
|
|
159
|
+
PATTERN: (params) => params.patterns !== undefined ? `${labelFor(params, "La valeur")} doit correspondre \xE0 l'un de: ${formatList(params.patterns)}` : `${labelFor(params, "La valeur")} doit correspondre au motif ${params.pattern}`,
|
|
160
|
+
FORMAT: (params) => `${labelFor(params, "La valeur")} doit respecter le format ${params.format}`,
|
|
161
|
+
MINIMUM: (params) => `${labelFor(params, "La valeur")} doit \xEAtre >= ${params.minimum}`,
|
|
162
|
+
MAXIMUM: (params) => `${labelFor(params, "La valeur")} doit \xEAtre <= ${params.maximum}`,
|
|
163
|
+
EXCLUSIVE_MINIMUM: (params) => `${labelFor(params, "La valeur")} doit \xEAtre > ${params.minimum}`,
|
|
164
|
+
EXCLUSIVE_MAXIMUM: (params) => `${labelFor(params, "La valeur")} doit \xEAtre < ${params.maximum}`,
|
|
165
|
+
MULTIPLE_OF: (params) => `${labelFor(params, "La valeur")} doit \xEAtre un multiple de ${params.divisor}`,
|
|
166
|
+
INVALID_CONST: (params) => `Valeur attendue: ${params.expectedValue}`,
|
|
167
|
+
MIN_ITEMS: (params) => `${labelFor(params, "Le tableau")} doit contenir au moins ${params.minimum} \xE9l\xE9ments`,
|
|
168
|
+
MAX_ITEMS: (params) => `${labelFor(params, "Le tableau")} doit contenir au plus ${params.maximum} \xE9l\xE9ments`,
|
|
169
|
+
UNIQUE_ITEMS: (params) => `Les \xE9l\xE9ments de ${labelFor(params, "ce tableau")} doivent \xEAtre uniques`,
|
|
170
|
+
CONTAINS: (params) => `${labelFor(params, "Le tableau")} doit contenir au moins un \xE9l\xE9ment correspondant`,
|
|
171
|
+
MIN_CONTAINS: (params) => `${labelFor(params, "Le tableau")} doit contenir au moins ${params.minimum} \xE9l\xE9ments correspondants`,
|
|
172
|
+
MAX_CONTAINS: (params) => `${labelFor(params, "Le tableau")} doit contenir au plus ${params.maximum} \xE9l\xE9ments correspondants`,
|
|
173
|
+
MISSING_REQUIRED: (params) => `Propri\xE9t\xE9 requise manquante "${params.property}"`,
|
|
174
|
+
ADDITIONAL_PROPERTY: (params) => `Propri\xE9t\xE9 inattendue "${params.property}"`,
|
|
175
|
+
ADDITIONAL_ITEMS: (params) => `\xC9l\xE9ment inattendu \xE0 l'index ${params.count}`,
|
|
176
|
+
MIN_PROPERTIES: (params) => `${labelFor(params, "L\u2019objet")} doit avoir au moins ${params.minimum} propri\xE9t\xE9s`,
|
|
177
|
+
MAX_PROPERTIES: (params) => `${labelFor(params, "L\u2019objet")} doit avoir au plus ${params.maximum} propri\xE9t\xE9s`,
|
|
178
|
+
INVALID_KEY: (params) => `Cl\xE9 d\u2019enregistrement invalide "${params.key}"`,
|
|
179
|
+
UNION: () => "La valeur ne correspond \xE0 aucune variante de l\u2019union",
|
|
180
|
+
ENUM: (params) => `La valeur doit \xEAtre l\u2019une de: ${formatList(params.values)}`,
|
|
181
|
+
UNRESOLVED_REF: () => "R\xE9f\xE9rence de sch\xE9ma non r\xE9solue",
|
|
182
|
+
EXCLUDE: () => "La valeur correspond \xE0 un sch\xE9ma exclu",
|
|
183
|
+
EXTRACT: () => "La valeur ne correspond pas au sch\xE9ma extrait",
|
|
184
|
+
NEVER: () => "La valeur n\u2019est pas autoris\xE9e",
|
|
185
|
+
NOT: () => "La valeur correspond \xE0 un sch\xE9ma n\xE9gatif",
|
|
186
|
+
KEYOF: (params) => `La valeur doit \xEAtre l\u2019une de: ${formatList(params.values)}`,
|
|
187
|
+
CONDITIONAL: () => "La valeur ne correspond \xE0 aucune branche conditionnelle",
|
|
188
|
+
INDEX: () => "La valeur ne correspond \xE0 aucun sch\xE9ma index\xE9",
|
|
189
|
+
IDENTIFIER: () => "Identifiant attendu valide",
|
|
190
|
+
BASE: () => "La validation de base a \xE9chou\xE9",
|
|
191
|
+
REFINE: (params) => params.customMessage ?? "Le raffinement a \xE9chou\xE9",
|
|
192
|
+
CALL: () => "Impossible d\u2019instancier le sch\xE9ma d\u2019appel",
|
|
193
|
+
PARAMETERS_LENGTH: (params) => `${params.count} param\xE8tres attendus`,
|
|
194
|
+
CUSTOM_TYPE: (params) => `La validation du type personnalis\xE9 "${params.kind}" a \xE9chou\xE9`
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
// src/error/locales/ja.ts
|
|
198
|
+
var jaJPCatalog = {
|
|
199
|
+
INVALID_TYPE: (params) => params.actual === undefined ? `${params.expected ?? "\u5024"}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059` : `${params.expected ?? "\u5024"}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002\u5B9F\u969B\u306E\u578B: ${params.actual}`,
|
|
200
|
+
MIN_LENGTH: (params) => `${labelFor(params, "\u5024")}\u306F\u5C11\u306A\u304F\u3068\u3082${params.minimum}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`,
|
|
201
|
+
MAX_LENGTH: (params) => `${labelFor(params, "\u5024")}\u306F\u6700\u5927\u3067${params.maximum}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`,
|
|
202
|
+
PATTERN: (params) => params.patterns !== undefined ? `${labelFor(params, "\u5024")}\u306F\u6B21\u306E\u3044\u305A\u308C\u304B\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059: ${formatList(params.patterns)}` : `${labelFor(params, "\u5024")}\u306F\u30D1\u30BF\u30FC\u30F3${params.pattern}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`,
|
|
203
|
+
FORMAT: (params) => `${labelFor(params, "\u5024")}\u306F\u5F62\u5F0F${params.format}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`,
|
|
204
|
+
MINIMUM: (params) => `${labelFor(params, "\u5024")}\u306F${params.minimum}\u4EE5\u4E0A\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`,
|
|
205
|
+
MAXIMUM: (params) => `${labelFor(params, "\u5024")}\u306F${params.maximum}\u4EE5\u4E0B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`,
|
|
206
|
+
EXCLUSIVE_MINIMUM: (params) => `${labelFor(params, "\u5024")}\u306F${params.minimum}\u3088\u308A\u5927\u304D\u3044\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`,
|
|
207
|
+
EXCLUSIVE_MAXIMUM: (params) => `${labelFor(params, "\u5024")}\u306F${params.maximum}\u3088\u308A\u5C0F\u3055\u3044\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`,
|
|
208
|
+
MULTIPLE_OF: (params) => `${labelFor(params, "\u5024")}\u306F${params.divisor}\u306E\u500D\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`,
|
|
209
|
+
INVALID_CONST: (params) => `${params.expectedValue}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`,
|
|
210
|
+
MIN_ITEMS: (params) => `${labelFor(params, "\u914D\u5217")}\u306B\u306F\u5C11\u306A\u304F\u3068\u3082${params.minimum}\u500B\u306E\u9805\u76EE\u304C\u5FC5\u8981\u3067\u3059`,
|
|
211
|
+
MAX_ITEMS: (params) => `${labelFor(params, "\u914D\u5217")}\u306B\u306F\u6700\u5927${params.maximum}\u500B\u306E\u9805\u76EE\u307E\u3067\u8A31\u53EF\u3055\u308C\u307E\u3059`,
|
|
212
|
+
UNIQUE_ITEMS: (params) => `${labelFor(params, "\u914D\u5217")}\u306E\u9805\u76EE\u306F\u4E00\u610F\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`,
|
|
213
|
+
CONTAINS: (params) => `${labelFor(params, "\u914D\u5217")}\u306B\u306F\u4E00\u81F4\u3059\u308B\u9805\u76EE\u304C\u5C11\u306A\u304F\u3068\u30821\u3064\u5FC5\u8981\u3067\u3059`,
|
|
214
|
+
MIN_CONTAINS: (params) => `${labelFor(params, "\u914D\u5217")}\u306B\u306F\u4E00\u81F4\u3059\u308B\u9805\u76EE\u304C\u5C11\u306A\u304F\u3068\u3082${params.minimum}\u500B\u5FC5\u8981\u3067\u3059`,
|
|
215
|
+
MAX_CONTAINS: (params) => `${labelFor(params, "\u914D\u5217")}\u306B\u306F\u4E00\u81F4\u3059\u308B\u9805\u76EE\u3092\u6700\u5927${params.maximum}\u500B\u307E\u3067\u542B\u3081\u3089\u308C\u307E\u3059`,
|
|
216
|
+
MISSING_REQUIRED: (params) => `\u5FC5\u9808\u30D7\u30ED\u30D1\u30C6\u30A3"${params.property}"\u304C\u3042\u308A\u307E\u305B\u3093`,
|
|
217
|
+
ADDITIONAL_PROPERTY: (params) => `\u4E88\u671F\u3057\u306A\u3044\u30D7\u30ED\u30D1\u30C6\u30A3"${params.property}"\u3067\u3059`,
|
|
218
|
+
ADDITIONAL_ITEMS: (params) => `\u30A4\u30F3\u30C7\u30C3\u30AF\u30B9${params.count}\u306B\u4E88\u671F\u3057\u306A\u3044\u9805\u76EE\u304C\u3042\u308A\u307E\u3059`,
|
|
219
|
+
MIN_PROPERTIES: (params) => `${labelFor(params, "\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8")}\u306B\u306F\u5C11\u306A\u304F\u3068\u3082${params.minimum}\u500B\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u304C\u5FC5\u8981\u3067\u3059`,
|
|
220
|
+
MAX_PROPERTIES: (params) => `${labelFor(params, "\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8")}\u306B\u306F\u6700\u5927${params.maximum}\u500B\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u307E\u3067\u8A31\u53EF\u3055\u308C\u307E\u3059`,
|
|
221
|
+
INVALID_KEY: (params) => `\u7121\u52B9\u306A\u30EC\u30B3\u30FC\u30C9\u30AD\u30FC"${params.key}"\u3067\u3059`,
|
|
222
|
+
UNION: () => "\u5024\u304C\u3069\u306E\u30E6\u30CB\u30AA\u30F3\u5206\u5C90\u306B\u3082\u4E00\u81F4\u3057\u307E\u305B\u3093",
|
|
223
|
+
ENUM: (params) => `\u5024\u306F\u6B21\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059: ${formatList(params.values)}`,
|
|
224
|
+
UNRESOLVED_REF: () => "\u89E3\u6C7A\u3067\u304D\u306A\u3044\u30B9\u30AD\u30FC\u30DE\u53C2\u7167\u3067\u3059",
|
|
225
|
+
EXCLUDE: () => "\u5024\u304C\u9664\u5916\u3055\u308C\u305F\u30B9\u30AD\u30FC\u30DE\u306B\u4E00\u81F4\u3057\u307E\u3057\u305F",
|
|
226
|
+
EXTRACT: () => "\u5024\u304C\u62BD\u51FA\u3055\u308C\u305F\u30B9\u30AD\u30FC\u30DE\u306B\u4E00\u81F4\u3057\u307E\u305B\u3093",
|
|
227
|
+
NEVER: () => "\u5024\u306F\u8A31\u53EF\u3055\u308C\u3066\u3044\u307E\u305B\u3093",
|
|
228
|
+
NOT: () => "\u5024\u304C\u5426\u5B9A\u30B9\u30AD\u30FC\u30DE\u306B\u4E00\u81F4\u3057\u3066\u3044\u307E\u3059",
|
|
229
|
+
KEYOF: (params) => `\u5024\u306F\u6B21\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059: ${formatList(params.values)}`,
|
|
230
|
+
CONDITIONAL: () => "\u5024\u304C\u3069\u306E\u6761\u4EF6\u5206\u5C90\u306B\u3082\u4E00\u81F4\u3057\u307E\u305B\u3093",
|
|
231
|
+
INDEX: () => "\u5024\u304C\u3069\u306E\u30A4\u30F3\u30C7\u30C3\u30AF\u30B9\u5019\u88DC\u30B9\u30AD\u30FC\u30DE\u306B\u3082\u4E00\u81F4\u3057\u307E\u305B\u3093",
|
|
232
|
+
IDENTIFIER: () => "\u6709\u52B9\u306A\u8B58\u5225\u5B50\u6587\u5B57\u5217\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059",
|
|
233
|
+
BASE: () => "\u57FA\u672C\u691C\u8A3C\u306B\u5931\u6557\u3057\u307E\u3057\u305F",
|
|
234
|
+
REFINE: (params) => params.customMessage ?? "\u8FFD\u52A0\u6761\u4EF6\u306E\u691C\u8A3C\u306B\u5931\u6557\u3057\u307E\u3057\u305F",
|
|
235
|
+
CALL: () => "\u547C\u3073\u51FA\u3057\u30B9\u30AD\u30FC\u30DE\u3092\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u5316\u3067\u304D\u307E\u305B\u3093",
|
|
236
|
+
PARAMETERS_LENGTH: (params) => `\u30D1\u30E9\u30E1\u30FC\u30BF\u306F${params.count}\u500B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`,
|
|
237
|
+
CUSTOM_TYPE: (params) => `\u30AB\u30B9\u30BF\u30E0\u578B"${params.kind}"\u306E\u691C\u8A3C\u306B\u5931\u6557\u3057\u307E\u3057\u305F`
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
// src/error/locales/ko.ts
|
|
241
|
+
var koKRCatalog = {
|
|
242
|
+
INVALID_TYPE: (params) => params.actual === undefined ? `${params.expected ?? "\uAC12"}\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4` : `${params.expected ?? "\uAC12"}\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4. \uD604\uC7AC \uAC12 \uC720\uD615: ${params.actual}`,
|
|
243
|
+
MIN_LENGTH: (params) => `${labelFor(params, "\uAC12")}\uC740(\uB294) \uCD5C\uC18C ${params.minimum}\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`,
|
|
244
|
+
MAX_LENGTH: (params) => `${labelFor(params, "\uAC12")}\uC740(\uB294) \uCD5C\uB300 ${params.maximum}\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`,
|
|
245
|
+
PATTERN: (params) => params.patterns !== undefined ? `${labelFor(params, "\uAC12")}\uC740(\uB294) \uB2E4\uC74C \uC911 \uD558\uB098\uC640 \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4: ${formatList(params.patterns)}` : `${labelFor(params, "\uAC12")}\uC740(\uB294) \uD328\uD134 ${params.pattern}\uACFC \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4`,
|
|
246
|
+
FORMAT: (params) => `${labelFor(params, "\uAC12")}\uC740(\uB294) ${params.format} \uD615\uC2DD\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`,
|
|
247
|
+
MINIMUM: (params) => `${labelFor(params, "\uAC12")}\uC740(\uB294) ${params.minimum} \uC774\uC0C1\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`,
|
|
248
|
+
MAXIMUM: (params) => `${labelFor(params, "\uAC12")}\uC740(\uB294) ${params.maximum} \uC774\uD558\uC5EC\uC57C \uD569\uB2C8\uB2E4`,
|
|
249
|
+
EXCLUSIVE_MINIMUM: (params) => `${labelFor(params, "\uAC12")}\uC740(\uB294) ${params.minimum}\uBCF4\uB2E4 \uCEE4\uC57C \uD569\uB2C8\uB2E4`,
|
|
250
|
+
EXCLUSIVE_MAXIMUM: (params) => `${labelFor(params, "\uAC12")}\uC740(\uB294) ${params.maximum}\uBCF4\uB2E4 \uC791\uC544\uC57C \uD569\uB2C8\uB2E4`,
|
|
251
|
+
MULTIPLE_OF: (params) => `${labelFor(params, "\uAC12")}\uC740(\uB294) ${params.divisor}\uC758 \uBC30\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4`,
|
|
252
|
+
INVALID_CONST: (params) => `${params.expectedValue}\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`,
|
|
253
|
+
MIN_ITEMS: (params) => `${labelFor(params, "\uBC30\uC5F4")}\uC740(\uB294) \uCD5C\uC18C ${params.minimum}\uAC1C \uD56D\uBAA9\uC774 \uD544\uC694\uD569\uB2C8\uB2E4`,
|
|
254
|
+
MAX_ITEMS: (params) => `${labelFor(params, "\uBC30\uC5F4")}\uC740(\uB294) \uCD5C\uB300 ${params.maximum}\uAC1C \uD56D\uBAA9\uB9CC \uD5C8\uC6A9\uB429\uB2C8\uB2E4`,
|
|
255
|
+
UNIQUE_ITEMS: (params) => `${labelFor(params, "\uBC30\uC5F4")} \uD56D\uBAA9\uC740 \uACE0\uC720\uD574\uC57C \uD569\uB2C8\uB2E4`,
|
|
256
|
+
CONTAINS: (params) => `${labelFor(params, "\uBC30\uC5F4")}\uC5D0 \uC77C\uCE58\uD558\uB294 \uD56D\uBAA9\uC774 \uD558\uB098 \uC774\uC0C1 \uC788\uC5B4\uC57C \uD569\uB2C8\uB2E4`,
|
|
257
|
+
MIN_CONTAINS: (params) => `${labelFor(params, "\uBC30\uC5F4")}\uC5D0 \uC77C\uCE58\uD558\uB294 \uD56D\uBAA9\uC774 \uCD5C\uC18C ${params.minimum}\uAC1C \uC788\uC5B4\uC57C \uD569\uB2C8\uB2E4`,
|
|
258
|
+
MAX_CONTAINS: (params) => `${labelFor(params, "\uBC30\uC5F4")}\uC5D0 \uC77C\uCE58\uD558\uB294 \uD56D\uBAA9\uC774 \uCD5C\uB300 ${params.maximum}\uAC1C\uAE4C\uC9C0\uB9CC \uD5C8\uC6A9\uB429\uB2C8\uB2E4`,
|
|
259
|
+
MISSING_REQUIRED: (params) => `\uD544\uC218 \uC18D\uC131 "${params.property}"\uC774(\uAC00) \uC5C6\uC2B5\uB2C8\uB2E4`,
|
|
260
|
+
ADDITIONAL_PROPERTY: (params) => `\uC608\uC0C1\uD558\uC9C0 \uBABB\uD55C \uC18D\uC131 "${params.property}"\uC785\uB2C8\uB2E4`,
|
|
261
|
+
ADDITIONAL_ITEMS: (params) => `\uC778\uB371\uC2A4 ${params.count}\uC758 \uD56D\uBAA9\uC740 \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4`,
|
|
262
|
+
MIN_PROPERTIES: (params) => `${labelFor(params, "\uAC1D\uCCB4")}\uC5D0\uB294 \uCD5C\uC18C ${params.minimum}\uAC1C\uC758 \uC18D\uC131\uC774 \uD544\uC694\uD569\uB2C8\uB2E4`,
|
|
263
|
+
MAX_PROPERTIES: (params) => `${labelFor(params, "\uAC1D\uCCB4")}\uC5D0\uB294 \uCD5C\uB300 ${params.maximum}\uAC1C\uC758 \uC18D\uC131\uB9CC \uD5C8\uC6A9\uB429\uB2C8\uB2E4`,
|
|
264
|
+
INVALID_KEY: (params) => `\uB808\uCF54\uB4DC \uD0A4 "${params.key}"\uAC00 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4`,
|
|
265
|
+
UNION: () => "\uAC12\uC774 \uC5B4\uB5A4 \uC720\uB2C8\uC5B8 \uBD84\uAE30\uC640\uB3C4 \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4",
|
|
266
|
+
ENUM: (params) => `\uAC12\uC740 \uB2E4\uC74C \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4: ${formatList(params.values)}`,
|
|
267
|
+
UNRESOLVED_REF: () => "\uC2A4\uD0A4\uB9C8 \uCC38\uC870\uB97C \uD655\uC778\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4",
|
|
268
|
+
EXCLUDE: () => "\uAC12\uC774 \uC81C\uC678\uB41C \uC2A4\uD0A4\uB9C8\uC640 \uC77C\uCE58\uD588\uC2B5\uB2C8\uB2E4",
|
|
269
|
+
EXTRACT: () => "\uAC12\uC774 \uCD94\uCD9C\uB41C \uC2A4\uD0A4\uB9C8\uC640 \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4",
|
|
270
|
+
NEVER: () => "\uAC12\uC774 \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4",
|
|
271
|
+
NOT: () => "\uAC12\uC774 \uBD80\uC815 \uC2A4\uD0A4\uB9C8\uC640 \uC77C\uCE58\uD569\uB2C8\uB2E4",
|
|
272
|
+
KEYOF: (params) => `\uAC12\uC740 \uB2E4\uC74C \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4: ${formatList(params.values)}`,
|
|
273
|
+
CONDITIONAL: () => "\uAC12\uC774 \uC5B4\uB5A4 \uC870\uAC74 \uBD84\uAE30\uC640\uB3C4 \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4",
|
|
274
|
+
INDEX: () => "\uAC12\uC774 \uC5B4\uB5A4 \uC778\uB371\uC2A4 \uD6C4\uBCF4 \uC2A4\uD0A4\uB9C8\uC640\uB3C4 \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4",
|
|
275
|
+
IDENTIFIER: () => "\uC62C\uBC14\uB978 \uC2DD\uBCC4\uC790 \uBB38\uC790\uC5F4\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4",
|
|
276
|
+
BASE: () => "\uAE30\uBCF8 \uAC80\uC99D\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4",
|
|
277
|
+
REFINE: (params) => params.customMessage ?? "\uC138\uBD80 \uC870\uAC74 \uAC80\uC99D\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4",
|
|
278
|
+
CALL: () => "\uD638\uCD9C \uC2A4\uD0A4\uB9C8\uB97C \uC778\uC2A4\uD134\uC2A4\uD654\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4",
|
|
279
|
+
PARAMETERS_LENGTH: (params) => `\uB9E4\uAC1C\uBCC0\uC218\uB294 ${params.count}\uAC1C\uC5EC\uC57C \uD569\uB2C8\uB2E4`,
|
|
280
|
+
CUSTOM_TYPE: (params) => `\uC0AC\uC6A9\uC790 \uC815\uC758 \uD0C0\uC785 "${params.kind}" \uAC80\uC99D\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4`
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
// src/error/locales/pt.ts
|
|
284
|
+
var ptBRCatalog = {
|
|
285
|
+
INVALID_TYPE: (params) => params.actual === undefined ? `Esperado ${params.expected ?? "valor"}` : `Esperado ${params.expected ?? "valor"}, recebido ${params.actual}`,
|
|
286
|
+
MIN_LENGTH: (params) => `${labelFor(params, "O valor")} deve ser no m\xEDnimo ${params.minimum}`,
|
|
287
|
+
MAX_LENGTH: (params) => `${labelFor(params, "O valor")} deve ser no m\xE1ximo ${params.maximum}`,
|
|
288
|
+
PATTERN: (params) => params.patterns !== undefined ? `${labelFor(params, "O valor")} deve corresponder a um destes padr\xF5es: ${formatList(params.patterns)}` : `${labelFor(params, "O valor")} deve corresponder ao padr\xE3o ${params.pattern}`,
|
|
289
|
+
FORMAT: (params) => `${labelFor(params, "O valor")} deve corresponder ao formato ${params.format}`,
|
|
290
|
+
MINIMUM: (params) => `${labelFor(params, "O valor")} deve ser >= ${params.minimum}`,
|
|
291
|
+
MAXIMUM: (params) => `${labelFor(params, "O valor")} deve ser <= ${params.maximum}`,
|
|
292
|
+
EXCLUSIVE_MINIMUM: (params) => `${labelFor(params, "O valor")} deve ser > ${params.minimum}`,
|
|
293
|
+
EXCLUSIVE_MAXIMUM: (params) => `${labelFor(params, "O valor")} deve ser < ${params.maximum}`,
|
|
294
|
+
MULTIPLE_OF: (params) => `${labelFor(params, "O valor")} deve ser m\xFAltiplo de ${params.divisor}`,
|
|
295
|
+
INVALID_CONST: (params) => `Esperado ${params.expectedValue}`,
|
|
296
|
+
MIN_ITEMS: (params) => `${labelFor(params, "O array")} deve ter pelo menos ${params.minimum} itens`,
|
|
297
|
+
MAX_ITEMS: (params) => `${labelFor(params, "O array")} deve ter no m\xE1ximo ${params.maximum} itens`,
|
|
298
|
+
UNIQUE_ITEMS: (params) => `Os itens de ${labelFor(params, "este array")} devem ser \xFAnicos`,
|
|
299
|
+
CONTAINS: (params) => `${labelFor(params, "O array")} deve conter ao menos um item correspondente`,
|
|
300
|
+
MIN_CONTAINS: (params) => `${labelFor(params, "O array")} deve conter pelo menos ${params.minimum} itens correspondentes`,
|
|
301
|
+
MAX_CONTAINS: (params) => `${labelFor(params, "O array")} deve conter no m\xE1ximo ${params.maximum} itens correspondentes`,
|
|
302
|
+
MISSING_REQUIRED: (params) => `Propriedade obrigat\xF3ria ausente "${params.property}"`,
|
|
303
|
+
ADDITIONAL_PROPERTY: (params) => `Propriedade inesperada "${params.property}"`,
|
|
304
|
+
ADDITIONAL_ITEMS: (params) => `Item inesperado no \xEDndice ${params.count}`,
|
|
305
|
+
MIN_PROPERTIES: (params) => `${labelFor(params, "O objeto")} deve ter pelo menos ${params.minimum} propriedades`,
|
|
306
|
+
MAX_PROPERTIES: (params) => `${labelFor(params, "O objeto")} deve ter no m\xE1ximo ${params.maximum} propriedades`,
|
|
307
|
+
INVALID_KEY: (params) => `Chave inv\xE1lida "${params.key}"`,
|
|
308
|
+
UNION: () => "O valor n\xE3o corresponde a nenhuma variante da uni\xE3o",
|
|
309
|
+
ENUM: (params) => `O valor deve ser um destes: ${formatList(params.values)}`,
|
|
310
|
+
UNRESOLVED_REF: () => "Refer\xEAncia de esquema n\xE3o resolvida",
|
|
311
|
+
EXCLUDE: () => "O valor correspondeu a um esquema exclu\xEDdo",
|
|
312
|
+
EXTRACT: () => "O valor n\xE3o correspondeu ao esquema extra\xEDdo",
|
|
313
|
+
NEVER: () => "O valor n\xE3o \xE9 permitido",
|
|
314
|
+
NOT: () => "O valor corresponde a um esquema negado",
|
|
315
|
+
KEYOF: (params) => `O valor deve ser um destes: ${formatList(params.values)}`,
|
|
316
|
+
CONDITIONAL: () => "O valor n\xE3o corresponde a nenhum ramo condicional",
|
|
317
|
+
INDEX: () => "O valor n\xE3o corresponde a nenhum esquema indexado",
|
|
318
|
+
IDENTIFIER: () => "Era esperado um identificador v\xE1lido",
|
|
319
|
+
BASE: () => "A valida\xE7\xE3o base falhou",
|
|
320
|
+
REFINE: (params) => params.customMessage ?? "A valida\xE7\xE3o refinada falhou",
|
|
321
|
+
CALL: () => "N\xE3o foi poss\xEDvel instanciar o esquema de chamada",
|
|
322
|
+
PARAMETERS_LENGTH: (params) => `Esperados ${params.count} par\xE2metros`,
|
|
323
|
+
CUSTOM_TYPE: (params) => `A valida\xE7\xE3o do tipo personalizado "${params.kind}" falhou`
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
// src/error/locales/zh.ts
|
|
327
|
+
var zhHansCatalog = {
|
|
328
|
+
INVALID_TYPE: (params) => params.actual === undefined ? `\u5E94\u4E3A${params.expected ?? "\u503C"}` : `\u5E94\u4E3A${params.expected ?? "\u503C"}\uFF0C\u5B9E\u9645\u7C7B\u578B\u4E3A${params.actual}`,
|
|
329
|
+
MIN_LENGTH: (params) => `${labelFor(params, "\u503C")}\u5FC5\u987B\u81F3\u5C11\u4E3A${params.minimum}`,
|
|
330
|
+
MAX_LENGTH: (params) => `${labelFor(params, "\u503C")}\u6700\u591A\u53EA\u80FD\u4E3A${params.maximum}`,
|
|
331
|
+
PATTERN: (params) => params.patterns !== undefined ? `${labelFor(params, "\u503C")}\u5FC5\u987B\u5339\u914D\u4EE5\u4E0B\u4E4B\u4E00\uFF1A${formatList(params.patterns)}` : `${labelFor(params, "\u503C")}\u5FC5\u987B\u5339\u914D\u6A21\u5F0F${params.pattern}`,
|
|
332
|
+
FORMAT: (params) => `${labelFor(params, "\u503C")}\u5FC5\u987B\u5339\u914D\u683C\u5F0F${params.format}`,
|
|
333
|
+
MINIMUM: (params) => `${labelFor(params, "\u503C")}\u5FC5\u987B >= ${params.minimum}`,
|
|
334
|
+
MAXIMUM: (params) => `${labelFor(params, "\u503C")}\u5FC5\u987B <= ${params.maximum}`,
|
|
335
|
+
EXCLUSIVE_MINIMUM: (params) => `${labelFor(params, "\u503C")}\u5FC5\u987B > ${params.minimum}`,
|
|
336
|
+
EXCLUSIVE_MAXIMUM: (params) => `${labelFor(params, "\u503C")}\u5FC5\u987B < ${params.maximum}`,
|
|
337
|
+
MULTIPLE_OF: (params) => `${labelFor(params, "\u503C")}\u5FC5\u987B\u662F${params.divisor}\u7684\u500D\u6570`,
|
|
338
|
+
INVALID_CONST: (params) => `\u5E94\u4E3A${params.expectedValue}`,
|
|
339
|
+
MIN_ITEMS: (params) => `${labelFor(params, "\u6570\u7EC4")}\u81F3\u5C11\u9700\u8981${params.minimum}\u4E2A\u9879\u76EE`,
|
|
340
|
+
MAX_ITEMS: (params) => `${labelFor(params, "\u6570\u7EC4")}\u6700\u591A\u53EA\u80FD\u6709${params.maximum}\u4E2A\u9879\u76EE`,
|
|
341
|
+
UNIQUE_ITEMS: (params) => `${labelFor(params, "\u6570\u7EC4")}\u4E2D\u7684\u9879\u76EE\u5FC5\u987B\u552F\u4E00`,
|
|
342
|
+
CONTAINS: (params) => `${labelFor(params, "\u6570\u7EC4")}\u81F3\u5C11\u8981\u5305\u542B\u4E00\u4E2A\u5339\u914D\u9879\u76EE`,
|
|
343
|
+
MIN_CONTAINS: (params) => `${labelFor(params, "\u6570\u7EC4")}\u81F3\u5C11\u8981\u5305\u542B${params.minimum}\u4E2A\u5339\u914D\u9879\u76EE`,
|
|
344
|
+
MAX_CONTAINS: (params) => `${labelFor(params, "\u6570\u7EC4")}\u6700\u591A\u53EA\u80FD\u5305\u542B${params.maximum}\u4E2A\u5339\u914D\u9879\u76EE`,
|
|
345
|
+
MISSING_REQUIRED: (params) => `\u7F3A\u5C11\u5FC5\u586B\u5C5E\u6027"${params.property}"`,
|
|
346
|
+
ADDITIONAL_PROPERTY: (params) => `\u5B58\u5728\u672A\u9884\u671F\u7684\u5C5E\u6027"${params.property}"`,
|
|
347
|
+
ADDITIONAL_ITEMS: (params) => `\u7D22\u5F15${params.count}\u5904\u5B58\u5728\u672A\u9884\u671F\u7684\u9879\u76EE`,
|
|
348
|
+
MIN_PROPERTIES: (params) => `${labelFor(params, "\u5BF9\u8C61")}\u81F3\u5C11\u9700\u8981${params.minimum}\u4E2A\u5C5E\u6027`,
|
|
349
|
+
MAX_PROPERTIES: (params) => `${labelFor(params, "\u5BF9\u8C61")}\u6700\u591A\u53EA\u80FD\u6709${params.maximum}\u4E2A\u5C5E\u6027`,
|
|
350
|
+
INVALID_KEY: (params) => `\u65E0\u6548\u7684\u8BB0\u5F55\u952E"${params.key}"`,
|
|
351
|
+
UNION: () => "\u503C\u4E0D\u7B26\u5408\u4EFB\u4F55\u8054\u5408\u5206\u652F",
|
|
352
|
+
ENUM: (params) => `\u503C\u5FC5\u987B\u662F\u4EE5\u4E0B\u4E4B\u4E00\uFF1A${formatList(params.values)}`,
|
|
353
|
+
UNRESOLVED_REF: () => "\u65E0\u6CD5\u89E3\u6790\u7684\u6A21\u5F0F\u5F15\u7528",
|
|
354
|
+
EXCLUDE: () => "\u503C\u5339\u914D\u4E86\u88AB\u6392\u9664\u7684\u6A21\u5F0F",
|
|
355
|
+
EXTRACT: () => "\u503C\u4E0D\u5339\u914D\u63D0\u53D6\u540E\u7684\u6A21\u5F0F",
|
|
356
|
+
NEVER: () => "\u4E0D\u5141\u8BB8\u8BE5\u503C",
|
|
357
|
+
NOT: () => "\u503C\u5339\u914D\u4E86\u5426\u5B9A\u6A21\u5F0F",
|
|
358
|
+
KEYOF: (params) => `\u503C\u5FC5\u987B\u662F\u4EE5\u4E0B\u4E4B\u4E00\uFF1A${formatList(params.values)}`,
|
|
359
|
+
CONDITIONAL: () => "\u503C\u4E0D\u5339\u914D\u4EFB\u4F55\u6761\u4EF6\u5206\u652F",
|
|
360
|
+
INDEX: () => "\u503C\u4E0D\u5339\u914D\u4EFB\u4F55\u7D22\u5F15\u6A21\u5F0F",
|
|
361
|
+
IDENTIFIER: () => "\u5FC5\u987B\u662F\u6709\u6548\u7684\u6807\u8BC6\u7B26\u5B57\u7B26\u4E32",
|
|
362
|
+
BASE: () => "\u57FA\u7840\u9A8C\u8BC1\u5931\u8D25",
|
|
363
|
+
REFINE: (params) => params.customMessage ?? "\u7EC6\u5316\u9A8C\u8BC1\u5931\u8D25",
|
|
364
|
+
CALL: () => "\u65E0\u6CD5\u5B9E\u4F8B\u5316\u8C03\u7528\u6A21\u5F0F",
|
|
365
|
+
PARAMETERS_LENGTH: (params) => `\u53C2\u6570\u6570\u91CF\u5FC5\u987B\u4E3A${params.count}`,
|
|
366
|
+
CUSTOM_TYPE: (params) => `\u81EA\u5B9A\u4E49\u7C7B\u578B"${params.kind}"\u9A8C\u8BC1\u5931\u8D25`
|
|
367
|
+
};
|
|
368
|
+
var zhHantCatalog = {
|
|
369
|
+
...zhHansCatalog,
|
|
370
|
+
INVALID_TYPE: (params) => params.actual === undefined ? `\u61C9\u70BA${params.expected ?? "\u503C"}` : `\u61C9\u70BA${params.expected ?? "\u503C"}\uFF0C\u5BE6\u969B\u985E\u578B\u70BA${params.actual}`,
|
|
371
|
+
PATTERN: (params) => params.patterns !== undefined ? `${labelFor(params, "\u503C")}\u5FC5\u9808\u7B26\u5408\u4EE5\u4E0B\u5176\u4E2D\u4E4B\u4E00\uFF1A${formatList(params.patterns)}` : `${labelFor(params, "\u503C")}\u5FC5\u9808\u7B26\u5408\u6A21\u5F0F${params.pattern}`,
|
|
372
|
+
MISSING_REQUIRED: (params) => `\u7F3A\u5C11\u5FC5\u8981\u5C6C\u6027"${params.property}"`,
|
|
373
|
+
ADDITIONAL_PROPERTY: (params) => `\u5B58\u5728\u672A\u9810\u671F\u7684\u5C6C\u6027"${params.property}"`,
|
|
374
|
+
ADDITIONAL_ITEMS: (params) => `\u7D22\u5F15${params.count}\u8655\u5B58\u5728\u672A\u9810\u671F\u7684\u9805\u76EE`,
|
|
375
|
+
MIN_PROPERTIES: (params) => `${labelFor(params, "\u7269\u4EF6")}\u81F3\u5C11\u9700\u8981${params.minimum}\u500B\u5C6C\u6027`,
|
|
376
|
+
MAX_PROPERTIES: (params) => `${labelFor(params, "\u7269\u4EF6")}\u6700\u591A\u53EA\u80FD\u6709${params.maximum}\u500B\u5C6C\u6027`,
|
|
377
|
+
INVALID_KEY: (params) => `\u7121\u6548\u7684\u8A18\u9304\u9375"${params.key}"`,
|
|
378
|
+
UNRESOLVED_REF: () => "\u7121\u6CD5\u89E3\u6790\u7684\u7D50\u69CB\u53C3\u7167",
|
|
379
|
+
EXCLUDE: () => "\u503C\u7B26\u5408\u88AB\u6392\u9664\u7684\u7D50\u69CB",
|
|
380
|
+
EXTRACT: () => "\u503C\u4E0D\u7B26\u5408\u63D0\u53D6\u5F8C\u7684\u7D50\u69CB",
|
|
381
|
+
NEVER: () => "\u4E0D\u5141\u8A31\u6B64\u503C",
|
|
382
|
+
CONDITIONAL: () => "\u503C\u4E0D\u7B26\u5408\u4EFB\u4F55\u689D\u4EF6\u5206\u652F",
|
|
383
|
+
INDEX: () => "\u503C\u4E0D\u7B26\u5408\u4EFB\u4F55\u7D22\u5F15\u7D50\u69CB",
|
|
384
|
+
IDENTIFIER: () => "\u5FC5\u9808\u662F\u6709\u6548\u7684\u8B58\u5225\u5B57\u4E32",
|
|
385
|
+
BASE: () => "\u57FA\u790E\u9A57\u8B49\u5931\u6557",
|
|
386
|
+
REFINE: (params) => params.customMessage ?? "\u7D30\u5316\u9A57\u8B49\u5931\u6557",
|
|
387
|
+
CALL: () => "\u7121\u6CD5\u5BE6\u4F8B\u5316\u547C\u53EB\u7D50\u69CB",
|
|
388
|
+
PARAMETERS_LENGTH: (params) => `\u53C3\u6578\u6578\u91CF\u5FC5\u9808\u70BA${params.count}`,
|
|
389
|
+
CUSTOM_TYPE: (params) => `\u81EA\u8A02\u985E\u578B"${params.kind}"\u9A57\u8B49\u5931\u6557`
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
// src/shared/locale.ts
|
|
393
|
+
var LocaleCodes = {
|
|
394
|
+
ar_001: "ar_001",
|
|
395
|
+
bn_BD: "bn_BD",
|
|
396
|
+
cs_CZ: "cs_CZ",
|
|
397
|
+
de_DE: "de_DE",
|
|
398
|
+
el_GR: "el_GR",
|
|
399
|
+
en_US: "en_US",
|
|
400
|
+
es_419: "es_419",
|
|
401
|
+
es_AR: "es_AR",
|
|
402
|
+
es_ES: "es_ES",
|
|
403
|
+
es_MX: "es_MX",
|
|
404
|
+
fa_IR: "fa_IR",
|
|
405
|
+
fil_PH: "fil_PH",
|
|
406
|
+
fr_CA: "fr_CA",
|
|
407
|
+
fr_FR: "fr_FR",
|
|
408
|
+
ha_NG: "ha_NG",
|
|
409
|
+
hi_IN: "hi_IN",
|
|
410
|
+
hu_HU: "hu_HU",
|
|
411
|
+
id_ID: "id_ID",
|
|
412
|
+
it_IT: "it_IT",
|
|
413
|
+
ja_JP: "ja_JP",
|
|
414
|
+
ko_KR: "ko_KR",
|
|
415
|
+
ms_MY: "ms_MY",
|
|
416
|
+
nl_NL: "nl_NL",
|
|
417
|
+
pl_PL: "pl_PL",
|
|
418
|
+
pt_BR: "pt_BR",
|
|
419
|
+
pt_PT: "pt_PT",
|
|
420
|
+
ro_RO: "ro_RO",
|
|
421
|
+
ru_RU: "ru_RU",
|
|
422
|
+
sv_SE: "sv_SE",
|
|
423
|
+
sw_TZ: "sw_TZ",
|
|
424
|
+
th_TH: "th_TH",
|
|
425
|
+
tr_TR: "tr_TR",
|
|
426
|
+
uk_UA: "uk_UA",
|
|
427
|
+
ur_PK: "ur_PK",
|
|
428
|
+
vi_VN: "vi_VN",
|
|
429
|
+
yo_NG: "yo_NG",
|
|
430
|
+
zh_Hans: "zh_Hans",
|
|
431
|
+
zh_Hant: "zh_Hant"
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
// src/locale/index.ts
|
|
435
|
+
var ar_001 = enUSCatalog;
|
|
436
|
+
var bn_BD = enUSCatalog;
|
|
437
|
+
var cs_CZ = enUSCatalog;
|
|
438
|
+
var de_DE = deDECatalog;
|
|
439
|
+
var el_GR = enUSCatalog;
|
|
440
|
+
var en_US = enUSCatalog;
|
|
441
|
+
var es_419 = esESCatalog;
|
|
442
|
+
var es_AR = esESCatalog;
|
|
443
|
+
var es_ES = esESCatalog;
|
|
444
|
+
var es_MX = esESCatalog;
|
|
445
|
+
var fa_IR = enUSCatalog;
|
|
446
|
+
var fil_PH = enUSCatalog;
|
|
447
|
+
var fr_CA = frFRCatalog;
|
|
448
|
+
var fr_FR = frFRCatalog;
|
|
449
|
+
var ha_NG = enUSCatalog;
|
|
450
|
+
var hi_IN = enUSCatalog;
|
|
451
|
+
var hu_HU = enUSCatalog;
|
|
452
|
+
var id_ID = enUSCatalog;
|
|
453
|
+
var it_IT = enUSCatalog;
|
|
454
|
+
var ja_JP = jaJPCatalog;
|
|
455
|
+
var ko_KR = koKRCatalog;
|
|
456
|
+
var ms_MY = enUSCatalog;
|
|
457
|
+
var nl_NL = enUSCatalog;
|
|
458
|
+
var pl_PL = enUSCatalog;
|
|
459
|
+
var pt_BR = ptBRCatalog;
|
|
460
|
+
var pt_PT = ptBRCatalog;
|
|
461
|
+
var ro_RO = enUSCatalog;
|
|
462
|
+
var ru_RU = enUSCatalog;
|
|
463
|
+
var sv_SE = enUSCatalog;
|
|
464
|
+
var sw_TZ = enUSCatalog;
|
|
465
|
+
var th_TH = enUSCatalog;
|
|
466
|
+
var tr_TR = enUSCatalog;
|
|
467
|
+
var uk_UA = enUSCatalog;
|
|
468
|
+
var ur_PK = enUSCatalog;
|
|
469
|
+
var vi_VN = enUSCatalog;
|
|
470
|
+
var yo_NG = enUSCatalog;
|
|
471
|
+
var zh_Hans = zhHansCatalog;
|
|
472
|
+
var zh_Hant = zhHantCatalog;
|
|
473
|
+
var OfficialLocaleCatalogs = {
|
|
474
|
+
[LocaleCodes.ar_001]: ar_001,
|
|
475
|
+
[LocaleCodes.bn_BD]: bn_BD,
|
|
476
|
+
[LocaleCodes.cs_CZ]: cs_CZ,
|
|
477
|
+
[LocaleCodes.de_DE]: de_DE,
|
|
478
|
+
[LocaleCodes.el_GR]: el_GR,
|
|
479
|
+
[LocaleCodes.en_US]: en_US,
|
|
480
|
+
[LocaleCodes.es_419]: es_419,
|
|
481
|
+
[LocaleCodes.es_AR]: es_AR,
|
|
482
|
+
[LocaleCodes.es_ES]: es_ES,
|
|
483
|
+
[LocaleCodes.es_MX]: es_MX,
|
|
484
|
+
[LocaleCodes.fa_IR]: fa_IR,
|
|
485
|
+
[LocaleCodes.fil_PH]: fil_PH,
|
|
486
|
+
[LocaleCodes.fr_CA]: fr_CA,
|
|
487
|
+
[LocaleCodes.fr_FR]: fr_FR,
|
|
488
|
+
[LocaleCodes.ha_NG]: ha_NG,
|
|
489
|
+
[LocaleCodes.hi_IN]: hi_IN,
|
|
490
|
+
[LocaleCodes.hu_HU]: hu_HU,
|
|
491
|
+
[LocaleCodes.id_ID]: id_ID,
|
|
492
|
+
[LocaleCodes.it_IT]: it_IT,
|
|
493
|
+
[LocaleCodes.ja_JP]: ja_JP,
|
|
494
|
+
[LocaleCodes.ko_KR]: ko_KR,
|
|
495
|
+
[LocaleCodes.ms_MY]: ms_MY,
|
|
496
|
+
[LocaleCodes.nl_NL]: nl_NL,
|
|
497
|
+
[LocaleCodes.pl_PL]: pl_PL,
|
|
498
|
+
[LocaleCodes.pt_BR]: pt_BR,
|
|
499
|
+
[LocaleCodes.pt_PT]: pt_PT,
|
|
500
|
+
[LocaleCodes.ro_RO]: ro_RO,
|
|
501
|
+
[LocaleCodes.ru_RU]: ru_RU,
|
|
502
|
+
[LocaleCodes.sv_SE]: sv_SE,
|
|
503
|
+
[LocaleCodes.sw_TZ]: sw_TZ,
|
|
504
|
+
[LocaleCodes.th_TH]: th_TH,
|
|
505
|
+
[LocaleCodes.tr_TR]: tr_TR,
|
|
506
|
+
[LocaleCodes.uk_UA]: uk_UA,
|
|
507
|
+
[LocaleCodes.ur_PK]: ur_PK,
|
|
508
|
+
[LocaleCodes.vi_VN]: vi_VN,
|
|
509
|
+
[LocaleCodes.yo_NG]: yo_NG,
|
|
510
|
+
[LocaleCodes.zh_Hans]: zh_Hans,
|
|
511
|
+
[LocaleCodes.zh_Hant]: zh_Hant
|
|
512
|
+
};
|
|
513
|
+
function LocaleCatalogEntries() {
|
|
514
|
+
return Object.values(LocaleCodes).map((locale) => [locale, OfficialLocaleCatalogs[locale]]);
|
|
515
|
+
}
|
|
516
|
+
var LocalePacks = OfficialLocaleCatalogs;
|
|
517
|
+
var locale_default = LocalePacks;
|
|
518
|
+
|
|
519
|
+
// src/shared/object-utils.ts
|
|
520
|
+
function deriveObjectSchema(object, options = {}) {
|
|
521
|
+
const pickSet = options.pickKeys ? new Set(options.pickKeys) : undefined;
|
|
522
|
+
const omitSet = options.omitKeys ? new Set(options.omitKeys) : undefined;
|
|
523
|
+
const originalOptional = new Set((object.optional ?? []).map(String));
|
|
524
|
+
const originalRequired = new Set((object.required ?? []).map(String));
|
|
525
|
+
const originalProperties = object.properties;
|
|
526
|
+
const properties = {};
|
|
527
|
+
for (const [key, schema] of Object.entries(originalProperties)) {
|
|
528
|
+
if (pickSet && !pickSet.has(key))
|
|
529
|
+
continue;
|
|
530
|
+
if (omitSet && omitSet.has(key))
|
|
531
|
+
continue;
|
|
532
|
+
properties[key] = schema;
|
|
533
|
+
}
|
|
534
|
+
const keys = Object.keys(properties);
|
|
535
|
+
const required = options.requiredMode === "all" ? keys : options.requiredMode === "none" ? [] : keys.filter((key) => originalRequired.has(key));
|
|
536
|
+
const optional = keys.filter((key) => originalOptional.has(key) && !required.includes(key));
|
|
537
|
+
return {
|
|
538
|
+
"~kind": "Object",
|
|
539
|
+
properties,
|
|
540
|
+
...required.length > 0 ? { required } : {},
|
|
541
|
+
...optional.length > 0 ? { optional } : {},
|
|
542
|
+
...object.patternProperties !== undefined ? { patternProperties: object.patternProperties } : {},
|
|
543
|
+
...options.additionalProperties !== undefined ? { additionalProperties: options.additionalProperties } : object.additionalProperties !== undefined ? { additionalProperties: object.additionalProperties } : {}
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
function getPatternPropertySchemas(patternProperties, key) {
|
|
547
|
+
if (!patternProperties)
|
|
548
|
+
return [];
|
|
549
|
+
const matches = [];
|
|
550
|
+
for (const [pattern, schema] of Object.entries(patternProperties)) {
|
|
551
|
+
if (new RegExp(pattern).test(key)) {
|
|
552
|
+
matches.push(schema);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
return matches;
|
|
556
|
+
}
|
|
557
|
+
function deriveIndexSchemas(object, keySchema, checkFn) {
|
|
558
|
+
const candidates = [];
|
|
559
|
+
const properties = object.properties;
|
|
560
|
+
for (const [key, schema] of Object.entries(properties)) {
|
|
561
|
+
if (checkFn(keySchema, key)) {
|
|
562
|
+
candidates.push(schema);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
return candidates;
|
|
566
|
+
}
|
|
567
|
+
function deriveIndexSchemasForEmission(object, keySchema) {
|
|
568
|
+
const candidates = [];
|
|
569
|
+
const properties = object.properties;
|
|
570
|
+
const keySchemaRecord = keySchema;
|
|
571
|
+
for (const [key, schema] of Object.entries(properties)) {
|
|
572
|
+
const keyValidationSchema = {
|
|
573
|
+
"~kind": "String",
|
|
574
|
+
...typeof keySchemaRecord.format === "string" ? { format: keySchemaRecord.format } : {},
|
|
575
|
+
...typeof keySchemaRecord.pattern === "string" ? { pattern: keySchemaRecord.pattern } : {}
|
|
576
|
+
};
|
|
577
|
+
if (keySchemaRecord["~kind"] === "String" ? stringMatchesKeySchema(keyValidationSchema, key) : true) {
|
|
578
|
+
candidates.push(schema);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
return candidates;
|
|
582
|
+
}
|
|
583
|
+
function stringMatchesKeySchema(schema, value) {
|
|
584
|
+
return schema.pattern === undefined || new RegExp(schema.pattern).test(value);
|
|
585
|
+
}
|
|
586
|
+
function transformStringLiteralValue(kind, value) {
|
|
587
|
+
switch (kind) {
|
|
588
|
+
case "Capitalize":
|
|
589
|
+
return value.length === 0 ? value : value.charAt(0).toUpperCase() + value.slice(1);
|
|
590
|
+
case "Lowercase":
|
|
591
|
+
return value.toLowerCase();
|
|
592
|
+
case "Uppercase":
|
|
593
|
+
return value.toUpperCase();
|
|
594
|
+
case "Uncapitalize":
|
|
595
|
+
return value.length === 0 ? value : value.charAt(0).toLowerCase() + value.slice(1);
|
|
596
|
+
default:
|
|
597
|
+
return value;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
function resolveStringActionSchema(schema) {
|
|
601
|
+
const value = schema;
|
|
602
|
+
const kind = value["~kind"];
|
|
603
|
+
if (kind !== "Capitalize" && kind !== "Lowercase" && kind !== "Uppercase" && kind !== "Uncapitalize") {
|
|
604
|
+
return schema;
|
|
605
|
+
}
|
|
606
|
+
const item = value["item"];
|
|
607
|
+
if (typeof item !== "object" || item === null) {
|
|
608
|
+
return schema;
|
|
609
|
+
}
|
|
610
|
+
const target = item;
|
|
611
|
+
const targetKind = target["~kind"];
|
|
612
|
+
if (targetKind === "Literal" && typeof target["const"] === "string") {
|
|
613
|
+
return { "~kind": "Literal", const: transformStringLiteralValue(String(kind), target["const"]) };
|
|
614
|
+
}
|
|
615
|
+
if (targetKind === "Enum" && Array.isArray(target["values"]) && target["values"].every((entry) => typeof entry === "string")) {
|
|
616
|
+
return {
|
|
617
|
+
"~kind": "Enum",
|
|
618
|
+
values: target["values"].map((entry) => transformStringLiteralValue(String(kind), entry))
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
return item;
|
|
622
|
+
}
|
|
623
|
+
// src/shared/runtime-guards.ts
|
|
624
|
+
function isPromiseLike(value) {
|
|
625
|
+
return (typeof value === "object" || typeof value === "function") && value !== null && "then" in value && typeof value.then === "function";
|
|
626
|
+
}
|
|
627
|
+
function isIteratorLike(value) {
|
|
628
|
+
return typeof value === "object" && value !== null && "next" in value && typeof value.next === "function" && Symbol.iterator in value && typeof value[Symbol.iterator] === "function";
|
|
629
|
+
}
|
|
630
|
+
function isAsyncIteratorLike(value) {
|
|
631
|
+
return typeof value === "object" && value !== null && "next" in value && typeof value.next === "function" && Symbol.asyncIterator in value && typeof value[Symbol.asyncIterator] === "function";
|
|
632
|
+
}
|
|
633
|
+
// src/shared/format-constants.ts
|
|
634
|
+
var EMAIL_RE = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
|
635
|
+
var URI_RE = /^[a-zA-Z][a-zA-Z0-9+.-]*:/;
|
|
636
|
+
var HOSTNAME_RE = /^(?!-)[a-zA-Z0-9-]{0,63}(?<!-)(.(?!-)[a-zA-Z0-9-]{0,63}(?<!-))*$/;
|
|
637
|
+
var IPV4_RE = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
|
|
638
|
+
var IPV6_RE = /^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$|^::(?:[0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4}$|^([0-9a-fA-F]{1,4}:){1,6}::$/;
|
|
639
|
+
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
640
|
+
var ISO_DATE_RE = /^\d{4}-(0[1-9]|1[0-2])-([0-2]\d|3[01])$/;
|
|
641
|
+
var ISO_DT_RE = /^\d{4}-(0[1-9]|1[0-2])-([0-2]\d|3[01])T([01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-][01]\d:[0-5]\d)$/;
|
|
642
|
+
var ISO_TIME_RE = /^([01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?$/;
|
|
643
|
+
var ISO_DUR_RE = /^P(?:\d+Y)?(?:\d+M)?(?:\d+D)?(?:T(?:\d+H)?(?:\d+M)?(?:\d+S)?)?$/;
|
|
644
|
+
var BASE64_RE = /^[a-zA-Z0-9+/]*={0,2}$/;
|
|
645
|
+
var HEX_RE = /^[0-9a-fA-F]+$/;
|
|
646
|
+
var HEXCLR_RE = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
|
|
647
|
+
var LUHN_DIGITS_RE = /^\d{13,19}$/;
|
|
648
|
+
var KNOWN_FORMATS = new Set([
|
|
649
|
+
"email",
|
|
650
|
+
"uri",
|
|
651
|
+
"hostname",
|
|
652
|
+
"ip",
|
|
653
|
+
"ipv4",
|
|
654
|
+
"ipv6",
|
|
655
|
+
"uuid",
|
|
656
|
+
"date",
|
|
657
|
+
"datetime",
|
|
658
|
+
"time",
|
|
659
|
+
"duration",
|
|
660
|
+
"base64",
|
|
661
|
+
"hex",
|
|
662
|
+
"hexcolor",
|
|
663
|
+
"creditcard",
|
|
664
|
+
"regex",
|
|
665
|
+
"uint8array",
|
|
666
|
+
"json"
|
|
667
|
+
]);
|
|
668
|
+
// src/shared/regex-json.ts
|
|
669
|
+
function isAsciiDigit(value) {
|
|
670
|
+
return value >= "0" && value <= "9";
|
|
671
|
+
}
|
|
672
|
+
function consumeRegexQuantifier(pattern, start) {
|
|
673
|
+
let index = start;
|
|
674
|
+
const first = pattern[index];
|
|
675
|
+
if (first === undefined || !isAsciiDigit(first)) {
|
|
676
|
+
return -1;
|
|
677
|
+
}
|
|
678
|
+
while (index < pattern.length) {
|
|
679
|
+
const character = pattern[index];
|
|
680
|
+
if (character === undefined || !isAsciiDigit(character)) {
|
|
681
|
+
break;
|
|
682
|
+
}
|
|
683
|
+
index += 1;
|
|
684
|
+
}
|
|
685
|
+
if (pattern[index] === ",") {
|
|
686
|
+
index += 1;
|
|
687
|
+
while (index < pattern.length) {
|
|
688
|
+
const character = pattern[index];
|
|
689
|
+
if (character === undefined || !isAsciiDigit(character)) {
|
|
690
|
+
break;
|
|
691
|
+
}
|
|
692
|
+
index += 1;
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
return pattern[index] === "}" ? index : -1;
|
|
696
|
+
}
|
|
697
|
+
function isValidRegex(value) {
|
|
698
|
+
let escaped = false;
|
|
699
|
+
let inCharacterClass = false;
|
|
700
|
+
let groupDepth = 0;
|
|
701
|
+
let hasToken = false;
|
|
702
|
+
let groupPrefixAllowed = false;
|
|
703
|
+
for (let index = 0;index < value.length; index += 1) {
|
|
704
|
+
const character = value[index];
|
|
705
|
+
if (character === undefined)
|
|
706
|
+
return false;
|
|
707
|
+
if (escaped) {
|
|
708
|
+
escaped = false;
|
|
709
|
+
hasToken = true;
|
|
710
|
+
groupPrefixAllowed = false;
|
|
711
|
+
continue;
|
|
712
|
+
}
|
|
713
|
+
if (character === "\\") {
|
|
714
|
+
escaped = true;
|
|
715
|
+
continue;
|
|
716
|
+
}
|
|
717
|
+
if (inCharacterClass) {
|
|
718
|
+
if (character === "]") {
|
|
719
|
+
inCharacterClass = false;
|
|
720
|
+
hasToken = true;
|
|
721
|
+
}
|
|
722
|
+
continue;
|
|
723
|
+
}
|
|
724
|
+
if (groupPrefixAllowed && character === "?") {
|
|
725
|
+
groupPrefixAllowed = false;
|
|
726
|
+
continue;
|
|
727
|
+
}
|
|
728
|
+
groupPrefixAllowed = false;
|
|
729
|
+
switch (character) {
|
|
730
|
+
case "[":
|
|
731
|
+
inCharacterClass = true;
|
|
732
|
+
hasToken = true;
|
|
733
|
+
break;
|
|
734
|
+
case "(":
|
|
735
|
+
groupDepth += 1;
|
|
736
|
+
hasToken = false;
|
|
737
|
+
groupPrefixAllowed = true;
|
|
738
|
+
break;
|
|
739
|
+
case ")":
|
|
740
|
+
if (groupDepth === 0)
|
|
741
|
+
return false;
|
|
742
|
+
groupDepth -= 1;
|
|
743
|
+
hasToken = true;
|
|
744
|
+
break;
|
|
745
|
+
case "{": {
|
|
746
|
+
if (!hasToken)
|
|
747
|
+
return false;
|
|
748
|
+
const quantifierEnd = consumeRegexQuantifier(value, index + 1);
|
|
749
|
+
if (quantifierEnd < 0)
|
|
750
|
+
return false;
|
|
751
|
+
index = quantifierEnd;
|
|
752
|
+
hasToken = true;
|
|
753
|
+
break;
|
|
754
|
+
}
|
|
755
|
+
case "*":
|
|
756
|
+
case "+":
|
|
757
|
+
case "?":
|
|
758
|
+
if (!hasToken)
|
|
759
|
+
return false;
|
|
760
|
+
hasToken = true;
|
|
761
|
+
break;
|
|
762
|
+
case "]":
|
|
763
|
+
case "}":
|
|
764
|
+
return false;
|
|
765
|
+
case "|":
|
|
766
|
+
hasToken = false;
|
|
767
|
+
break;
|
|
768
|
+
default:
|
|
769
|
+
hasToken = true;
|
|
770
|
+
break;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
return !escaped && !inCharacterClass && groupDepth === 0;
|
|
774
|
+
}
|
|
775
|
+
function skipWhitespace(state) {
|
|
776
|
+
while (state.index < state.text.length) {
|
|
777
|
+
const character = state.text[state.index];
|
|
778
|
+
if (character !== " " && character !== `
|
|
779
|
+
` && character !== "\r" && character !== "\t") {
|
|
780
|
+
break;
|
|
781
|
+
}
|
|
782
|
+
state.index += 1;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
function consumeLiteral(state, literal) {
|
|
786
|
+
if (state.text.slice(state.index, state.index + literal.length) !== literal) {
|
|
787
|
+
return false;
|
|
788
|
+
}
|
|
789
|
+
state.index += literal.length;
|
|
790
|
+
return true;
|
|
791
|
+
}
|
|
792
|
+
function parseString(state) {
|
|
793
|
+
if (state.text[state.index] !== '"')
|
|
794
|
+
return false;
|
|
795
|
+
state.index += 1;
|
|
796
|
+
while (state.index < state.text.length) {
|
|
797
|
+
const character = state.text[state.index];
|
|
798
|
+
if (character === undefined)
|
|
799
|
+
return false;
|
|
800
|
+
if (character === '"') {
|
|
801
|
+
state.index += 1;
|
|
802
|
+
return true;
|
|
803
|
+
}
|
|
804
|
+
if (character === "\\") {
|
|
805
|
+
const escape = state.text[state.index + 1];
|
|
806
|
+
if (escape === undefined)
|
|
807
|
+
return false;
|
|
808
|
+
if (escape === "u") {
|
|
809
|
+
for (let offset = 2;offset < 6; offset += 1) {
|
|
810
|
+
const hex = state.text[state.index + offset];
|
|
811
|
+
if (hex === undefined || !/[0-9a-fA-F]/.test(hex))
|
|
812
|
+
return false;
|
|
813
|
+
}
|
|
814
|
+
state.index += 6;
|
|
815
|
+
continue;
|
|
816
|
+
}
|
|
817
|
+
if (!'"\\/bfnrt'.includes(escape))
|
|
818
|
+
return false;
|
|
819
|
+
state.index += 2;
|
|
820
|
+
continue;
|
|
821
|
+
}
|
|
822
|
+
if (character < " ")
|
|
823
|
+
return false;
|
|
824
|
+
state.index += 1;
|
|
825
|
+
}
|
|
826
|
+
return false;
|
|
827
|
+
}
|
|
828
|
+
function parseNumber(state) {
|
|
829
|
+
const start = state.index;
|
|
830
|
+
if (state.text[state.index] === "-") {
|
|
831
|
+
state.index += 1;
|
|
832
|
+
}
|
|
833
|
+
const firstDigit = state.text[state.index];
|
|
834
|
+
if (firstDigit === undefined || !isAsciiDigit(firstDigit))
|
|
835
|
+
return false;
|
|
836
|
+
if (firstDigit === "0") {
|
|
837
|
+
state.index += 1;
|
|
838
|
+
} else {
|
|
839
|
+
while (state.index < state.text.length) {
|
|
840
|
+
const digit = state.text[state.index];
|
|
841
|
+
if (digit === undefined || !isAsciiDigit(digit))
|
|
842
|
+
break;
|
|
843
|
+
state.index += 1;
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
if (state.text[state.index] === ".") {
|
|
847
|
+
state.index += 1;
|
|
848
|
+
const fractionDigit = state.text[state.index];
|
|
849
|
+
if (fractionDigit === undefined || !isAsciiDigit(fractionDigit))
|
|
850
|
+
return false;
|
|
851
|
+
while (state.index < state.text.length) {
|
|
852
|
+
const digit = state.text[state.index];
|
|
853
|
+
if (digit === undefined || !isAsciiDigit(digit))
|
|
854
|
+
break;
|
|
855
|
+
state.index += 1;
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
const exponent = state.text[state.index];
|
|
859
|
+
if (exponent === "e" || exponent === "E") {
|
|
860
|
+
state.index += 1;
|
|
861
|
+
const sign = state.text[state.index];
|
|
862
|
+
if (sign === "+" || sign === "-")
|
|
863
|
+
state.index += 1;
|
|
864
|
+
const exponentDigit = state.text[state.index];
|
|
865
|
+
if (exponentDigit === undefined || !isAsciiDigit(exponentDigit))
|
|
866
|
+
return false;
|
|
867
|
+
while (state.index < state.text.length) {
|
|
868
|
+
const digit = state.text[state.index];
|
|
869
|
+
if (digit === undefined || !isAsciiDigit(digit))
|
|
870
|
+
break;
|
|
871
|
+
state.index += 1;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
return state.index > start;
|
|
875
|
+
}
|
|
876
|
+
function parseArray(state) {
|
|
877
|
+
if (state.text[state.index] !== "[")
|
|
878
|
+
return false;
|
|
879
|
+
state.index += 1;
|
|
880
|
+
skipWhitespace(state);
|
|
881
|
+
if (state.text[state.index] === "]") {
|
|
882
|
+
state.index += 1;
|
|
883
|
+
return true;
|
|
884
|
+
}
|
|
885
|
+
while (state.index < state.text.length) {
|
|
886
|
+
if (!parseValue(state))
|
|
887
|
+
return false;
|
|
888
|
+
skipWhitespace(state);
|
|
889
|
+
const separator = state.text[state.index];
|
|
890
|
+
if (separator === ",") {
|
|
891
|
+
state.index += 1;
|
|
892
|
+
skipWhitespace(state);
|
|
893
|
+
continue;
|
|
894
|
+
}
|
|
895
|
+
if (separator === "]") {
|
|
896
|
+
state.index += 1;
|
|
897
|
+
return true;
|
|
898
|
+
}
|
|
899
|
+
return false;
|
|
900
|
+
}
|
|
901
|
+
return false;
|
|
902
|
+
}
|
|
903
|
+
function parseObject(state) {
|
|
904
|
+
if (state.text[state.index] !== "{")
|
|
905
|
+
return false;
|
|
906
|
+
state.index += 1;
|
|
907
|
+
skipWhitespace(state);
|
|
908
|
+
if (state.text[state.index] === "}") {
|
|
909
|
+
state.index += 1;
|
|
910
|
+
return true;
|
|
911
|
+
}
|
|
912
|
+
while (state.index < state.text.length) {
|
|
913
|
+
if (!parseString(state))
|
|
914
|
+
return false;
|
|
915
|
+
skipWhitespace(state);
|
|
916
|
+
if (state.text[state.index] !== ":")
|
|
917
|
+
return false;
|
|
918
|
+
state.index += 1;
|
|
919
|
+
if (!parseValue(state))
|
|
920
|
+
return false;
|
|
921
|
+
skipWhitespace(state);
|
|
922
|
+
const separator = state.text[state.index];
|
|
923
|
+
if (separator === ",") {
|
|
924
|
+
state.index += 1;
|
|
925
|
+
skipWhitespace(state);
|
|
926
|
+
continue;
|
|
927
|
+
}
|
|
928
|
+
if (separator === "}") {
|
|
929
|
+
state.index += 1;
|
|
930
|
+
return true;
|
|
931
|
+
}
|
|
932
|
+
return false;
|
|
933
|
+
}
|
|
934
|
+
return false;
|
|
935
|
+
}
|
|
936
|
+
function parseValue(state) {
|
|
937
|
+
skipWhitespace(state);
|
|
938
|
+
const character = state.text[state.index];
|
|
939
|
+
switch (character) {
|
|
940
|
+
case '"':
|
|
941
|
+
return parseString(state);
|
|
942
|
+
case "{":
|
|
943
|
+
return parseObject(state);
|
|
944
|
+
case "[":
|
|
945
|
+
return parseArray(state);
|
|
946
|
+
case "t":
|
|
947
|
+
return consumeLiteral(state, "true");
|
|
948
|
+
case "f":
|
|
949
|
+
return consumeLiteral(state, "false");
|
|
950
|
+
case "n":
|
|
951
|
+
return consumeLiteral(state, "null");
|
|
952
|
+
default:
|
|
953
|
+
return character === "-" || character !== undefined && isAsciiDigit(character) ? parseNumber(state) : false;
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
function isValidJson(value) {
|
|
957
|
+
const state = { index: 0, text: value };
|
|
958
|
+
if (!parseValue(state))
|
|
959
|
+
return false;
|
|
960
|
+
skipWhitespace(state);
|
|
961
|
+
return state.index === state.text.length;
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
// src/shared/runtime-context.ts
|
|
965
|
+
var builtinLocaleCatalogEntries = LocaleCatalogEntries();
|
|
966
|
+
var defaultTypePolicy = {
|
|
967
|
+
AllowNaN: false,
|
|
968
|
+
AllowArrayObject: false,
|
|
969
|
+
AllowNullVoid: true
|
|
970
|
+
};
|
|
971
|
+
var defaultSettings = {
|
|
972
|
+
correctiveParse: false
|
|
973
|
+
};
|
|
974
|
+
var runtimeContextCounter = 0;
|
|
975
|
+
function cloneEntries(entries) {
|
|
976
|
+
return Array.from(entries, ([key, value]) => [key, value]);
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
class RuntimeContext {
|
|
980
|
+
id = ++runtimeContextCounter;
|
|
981
|
+
revision = 0;
|
|
982
|
+
activeLocale;
|
|
983
|
+
formatValidators = new Map;
|
|
984
|
+
localeCatalogs = new Map;
|
|
985
|
+
settings;
|
|
986
|
+
typeValidators = new Map;
|
|
987
|
+
typePolicy;
|
|
988
|
+
FormatRegistry = {
|
|
989
|
+
Clear: () => {
|
|
990
|
+
this.formatValidators.clear();
|
|
991
|
+
this.touch();
|
|
992
|
+
},
|
|
993
|
+
Delete: (name) => {
|
|
994
|
+
const deleted = this.formatValidators.delete(name);
|
|
995
|
+
if (deleted) {
|
|
996
|
+
this.touch();
|
|
997
|
+
}
|
|
998
|
+
return deleted;
|
|
999
|
+
},
|
|
1000
|
+
Entries: () => Array.from(this.formatValidators.entries()),
|
|
1001
|
+
Get: (name) => this.formatValidators.get(name),
|
|
1002
|
+
Has: (name) => this.formatValidators.has(name),
|
|
1003
|
+
Set: (name, validator) => {
|
|
1004
|
+
this.formatValidators.set(name, validator);
|
|
1005
|
+
this.touch();
|
|
1006
|
+
}
|
|
1007
|
+
};
|
|
1008
|
+
Locale = {
|
|
1009
|
+
...LocaleCodes,
|
|
1010
|
+
Entries: () => Array.from(this.localeCatalogs.entries()),
|
|
1011
|
+
Get: () => this.activeLocale,
|
|
1012
|
+
GetCatalog: (locale = this.activeLocale) => this.localeCatalogs.get(locale) ?? this.localeCatalogs.get(LocaleCodes.en_US) ?? enUSCatalog,
|
|
1013
|
+
Has: (locale) => this.localeCatalogs.has(locale),
|
|
1014
|
+
Register: (locale, catalog) => {
|
|
1015
|
+
this.localeCatalogs.set(locale, catalog);
|
|
1016
|
+
this.touch();
|
|
1017
|
+
},
|
|
1018
|
+
Reset: () => {
|
|
1019
|
+
this.activeLocale = LocaleCodes.en_US;
|
|
1020
|
+
this.touch();
|
|
1021
|
+
},
|
|
1022
|
+
Set: (locale) => {
|
|
1023
|
+
this.activeLocale = locale;
|
|
1024
|
+
this.touch();
|
|
1025
|
+
}
|
|
1026
|
+
};
|
|
1027
|
+
Settings = {
|
|
1028
|
+
Get: () => this.settings,
|
|
1029
|
+
Reset: () => {
|
|
1030
|
+
this.settings = { ...defaultSettings };
|
|
1031
|
+
this.touch();
|
|
1032
|
+
},
|
|
1033
|
+
Set: (options) => {
|
|
1034
|
+
this.settings = { ...this.settings, ...options };
|
|
1035
|
+
this.touch();
|
|
1036
|
+
}
|
|
1037
|
+
};
|
|
1038
|
+
TypeRegistry = {
|
|
1039
|
+
Clear: () => {
|
|
1040
|
+
this.typeValidators.clear();
|
|
1041
|
+
this.touch();
|
|
1042
|
+
},
|
|
1043
|
+
Delete: (kind) => {
|
|
1044
|
+
const deleted = this.typeValidators.delete(kind);
|
|
1045
|
+
if (deleted) {
|
|
1046
|
+
this.touch();
|
|
1047
|
+
}
|
|
1048
|
+
return deleted;
|
|
1049
|
+
},
|
|
1050
|
+
Entries: () => Array.from(this.typeValidators.entries()),
|
|
1051
|
+
Get: (kind) => this.typeValidators.get(kind),
|
|
1052
|
+
Has: (kind) => this.typeValidators.has(kind),
|
|
1053
|
+
Set: (kind, validator) => {
|
|
1054
|
+
this.typeValidators.set(kind, validator);
|
|
1055
|
+
this.touch();
|
|
1056
|
+
}
|
|
1057
|
+
};
|
|
1058
|
+
TypeSystemPolicy = {
|
|
1059
|
+
Get: () => this.typePolicy,
|
|
1060
|
+
Reset: () => {
|
|
1061
|
+
this.typePolicy = { ...defaultTypePolicy };
|
|
1062
|
+
this.touch();
|
|
1063
|
+
},
|
|
1064
|
+
Set: (options) => {
|
|
1065
|
+
this.typePolicy = { ...this.typePolicy, ...options };
|
|
1066
|
+
this.touch();
|
|
1067
|
+
}
|
|
1068
|
+
};
|
|
1069
|
+
constructor(options = {}) {
|
|
1070
|
+
this.activeLocale = options.locale ?? LocaleCodes.en_US;
|
|
1071
|
+
this.settings = { ...defaultSettings, ...options.settings };
|
|
1072
|
+
this.typePolicy = { ...defaultTypePolicy, ...options.typePolicy };
|
|
1073
|
+
for (const [locale, catalog] of builtinLocaleCatalogEntries) {
|
|
1074
|
+
this.localeCatalogs.set(locale, catalog);
|
|
1075
|
+
}
|
|
1076
|
+
for (const [locale, catalog] of options.localeCatalogs ?? []) {
|
|
1077
|
+
this.localeCatalogs.set(locale, catalog);
|
|
1078
|
+
}
|
|
1079
|
+
for (const [name, validator] of options.formats ?? []) {
|
|
1080
|
+
this.formatValidators.set(name, validator);
|
|
1081
|
+
}
|
|
1082
|
+
for (const [kind, validator] of options.types ?? []) {
|
|
1083
|
+
this.typeValidators.set(kind, validator);
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
Clone(options = {}) {
|
|
1087
|
+
return new RuntimeContext({
|
|
1088
|
+
formats: [...cloneEntries(this.formatValidators.entries()), ...options.formats ?? []],
|
|
1089
|
+
locale: options.locale ?? this.activeLocale,
|
|
1090
|
+
localeCatalogs: [...cloneEntries(this.localeCatalogs.entries()), ...options.localeCatalogs ?? []],
|
|
1091
|
+
settings: { ...this.settings, ...options.settings },
|
|
1092
|
+
typePolicy: { ...this.typePolicy, ...options.typePolicy },
|
|
1093
|
+
types: [...cloneEntries(this.typeValidators.entries()), ...options.types ?? []]
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
1096
|
+
CacheKey(namespace = "runtime") {
|
|
1097
|
+
return `${namespace}:${this.id}:${this.revision}`;
|
|
1098
|
+
}
|
|
1099
|
+
touch() {
|
|
1100
|
+
this.revision += 1;
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
var defaultRuntimeContext = new RuntimeContext;
|
|
1104
|
+
function CreateRuntimeContext(options = {}) {
|
|
1105
|
+
return new RuntimeContext(options);
|
|
1106
|
+
}
|
|
1107
|
+
function getDefaultRuntimeContext() {
|
|
1108
|
+
return defaultRuntimeContext;
|
|
1109
|
+
}
|
|
1110
|
+
function resolveRuntimeContext(context) {
|
|
1111
|
+
if (context instanceof RuntimeContext) {
|
|
1112
|
+
return context;
|
|
1113
|
+
}
|
|
1114
|
+
return context?.context ?? defaultRuntimeContext;
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
// src/shared/format-validators.ts
|
|
1118
|
+
function luhnCheck(digits) {
|
|
1119
|
+
if (!LUHN_DIGITS_RE.test(digits))
|
|
1120
|
+
return false;
|
|
1121
|
+
let sum = 0;
|
|
1122
|
+
let alternate = false;
|
|
1123
|
+
for (let index = digits.length - 1;index >= 0; index -= 1) {
|
|
1124
|
+
let digit = Number.parseInt(digits.charAt(index), 10);
|
|
1125
|
+
if (alternate) {
|
|
1126
|
+
digit *= 2;
|
|
1127
|
+
if (digit > 9)
|
|
1128
|
+
digit -= 9;
|
|
1129
|
+
}
|
|
1130
|
+
sum += digit;
|
|
1131
|
+
alternate = !alternate;
|
|
1132
|
+
}
|
|
1133
|
+
return sum % 10 === 0;
|
|
1134
|
+
}
|
|
1135
|
+
function isValidISODate(value) {
|
|
1136
|
+
const parts = value.split("-").map(Number);
|
|
1137
|
+
const year = parts[0];
|
|
1138
|
+
const month = parts[1];
|
|
1139
|
+
const day = parts[2];
|
|
1140
|
+
if (year === undefined || month === undefined || day === undefined)
|
|
1141
|
+
return false;
|
|
1142
|
+
const date = new globalThis.Date(year, month - 1, day);
|
|
1143
|
+
return date.getFullYear() === year && date.getMonth() === month - 1 && date.getDate() === day;
|
|
1144
|
+
}
|
|
1145
|
+
function validateFormat(value, format, context) {
|
|
1146
|
+
const runtimeContext = resolveRuntimeContext(context);
|
|
1147
|
+
const custom = runtimeContext.FormatRegistry.Get(format);
|
|
1148
|
+
if (custom !== undefined)
|
|
1149
|
+
return custom(value);
|
|
1150
|
+
switch (format) {
|
|
1151
|
+
case "email":
|
|
1152
|
+
return EMAIL_RE.test(value);
|
|
1153
|
+
case "uri":
|
|
1154
|
+
return URI_RE.test(value);
|
|
1155
|
+
case "ip":
|
|
1156
|
+
return IPV4_RE.test(value) || IPV6_RE.test(value);
|
|
1157
|
+
case "hostname":
|
|
1158
|
+
return HOSTNAME_RE.test(value);
|
|
1159
|
+
case "ipv4":
|
|
1160
|
+
return IPV4_RE.test(value);
|
|
1161
|
+
case "ipv6":
|
|
1162
|
+
return IPV6_RE.test(value);
|
|
1163
|
+
case "uuid":
|
|
1164
|
+
return UUID_RE.test(value);
|
|
1165
|
+
case "date":
|
|
1166
|
+
return ISO_DATE_RE.test(value) && isValidISODate(value);
|
|
1167
|
+
case "datetime":
|
|
1168
|
+
return ISO_DT_RE.test(value);
|
|
1169
|
+
case "time":
|
|
1170
|
+
return ISO_TIME_RE.test(value);
|
|
1171
|
+
case "duration":
|
|
1172
|
+
return ISO_DUR_RE.test(value);
|
|
1173
|
+
case "base64":
|
|
1174
|
+
return BASE64_RE.test(value);
|
|
1175
|
+
case "hex":
|
|
1176
|
+
return HEX_RE.test(value);
|
|
1177
|
+
case "hexcolor":
|
|
1178
|
+
return HEXCLR_RE.test(value);
|
|
1179
|
+
case "creditcard":
|
|
1180
|
+
return luhnCheck(value.replace(/\D/g, ""));
|
|
1181
|
+
case "regex":
|
|
1182
|
+
return isValidRegex(value);
|
|
1183
|
+
case "json":
|
|
1184
|
+
return isValidJson(value);
|
|
1185
|
+
case "uint8array":
|
|
1186
|
+
return BASE64_RE.test(value);
|
|
1187
|
+
default:
|
|
1188
|
+
return true;
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
function checkStringConstraints(schema, value, context) {
|
|
1192
|
+
if (schema.minLength !== undefined && value.length < schema.minLength)
|
|
1193
|
+
return false;
|
|
1194
|
+
if (schema.maxLength !== undefined && value.length > schema.maxLength)
|
|
1195
|
+
return false;
|
|
1196
|
+
if (schema.pattern !== undefined) {
|
|
1197
|
+
const regex = new RegExp(schema.pattern);
|
|
1198
|
+
if (!regex.test(value))
|
|
1199
|
+
return false;
|
|
1200
|
+
}
|
|
1201
|
+
return schema.format === undefined || validateFormat(value, schema.format, context);
|
|
1202
|
+
}
|
|
1203
|
+
function checkNumberConstraints(schema, value) {
|
|
1204
|
+
if (schema.minimum !== undefined && value < schema.minimum)
|
|
1205
|
+
return false;
|
|
1206
|
+
if (schema.maximum !== undefined && value > schema.maximum)
|
|
1207
|
+
return false;
|
|
1208
|
+
if (schema.exclusiveMinimum !== undefined && value <= schema.exclusiveMinimum)
|
|
1209
|
+
return false;
|
|
1210
|
+
if (schema.exclusiveMaximum !== undefined && value >= schema.exclusiveMaximum)
|
|
1211
|
+
return false;
|
|
1212
|
+
return schema.multipleOf === undefined || value % schema.multipleOf === 0;
|
|
1213
|
+
}
|
|
1214
|
+
// src/shared/registries.ts
|
|
1215
|
+
var FormatRegistry = {
|
|
1216
|
+
Clear() {
|
|
1217
|
+
getDefaultRuntimeContext().FormatRegistry.Clear();
|
|
1218
|
+
},
|
|
1219
|
+
Delete(name) {
|
|
1220
|
+
return getDefaultRuntimeContext().FormatRegistry.Delete(name);
|
|
1221
|
+
},
|
|
1222
|
+
Entries() {
|
|
1223
|
+
return getDefaultRuntimeContext().FormatRegistry.Entries();
|
|
1224
|
+
},
|
|
1225
|
+
Get(name) {
|
|
1226
|
+
return getDefaultRuntimeContext().FormatRegistry.Get(name);
|
|
1227
|
+
},
|
|
1228
|
+
Has(name) {
|
|
1229
|
+
return getDefaultRuntimeContext().FormatRegistry.Has(name);
|
|
1230
|
+
},
|
|
1231
|
+
Set(name, validator) {
|
|
1232
|
+
getDefaultRuntimeContext().FormatRegistry.Set(name, validator);
|
|
1233
|
+
}
|
|
1234
|
+
};
|
|
1235
|
+
var TypeRegistry = {
|
|
1236
|
+
Clear() {
|
|
1237
|
+
getDefaultRuntimeContext().TypeRegistry.Clear();
|
|
1238
|
+
},
|
|
1239
|
+
Delete(kind) {
|
|
1240
|
+
return getDefaultRuntimeContext().TypeRegistry.Delete(kind);
|
|
1241
|
+
},
|
|
1242
|
+
Entries() {
|
|
1243
|
+
return getDefaultRuntimeContext().TypeRegistry.Entries();
|
|
1244
|
+
},
|
|
1245
|
+
Get(kind) {
|
|
1246
|
+
return getDefaultRuntimeContext().TypeRegistry.Get(kind);
|
|
1247
|
+
},
|
|
1248
|
+
Has(kind) {
|
|
1249
|
+
return getDefaultRuntimeContext().TypeRegistry.Has(kind);
|
|
1250
|
+
},
|
|
1251
|
+
Set(kind, validator) {
|
|
1252
|
+
getDefaultRuntimeContext().TypeRegistry.Set(kind, validator);
|
|
1253
|
+
}
|
|
1254
|
+
};
|
|
1255
|
+
var TypeSystemPolicy = {
|
|
1256
|
+
Get() {
|
|
1257
|
+
return getDefaultRuntimeContext().TypeSystemPolicy.Get();
|
|
1258
|
+
},
|
|
1259
|
+
Reset() {
|
|
1260
|
+
getDefaultRuntimeContext().TypeSystemPolicy.Reset();
|
|
1261
|
+
},
|
|
1262
|
+
Set(options) {
|
|
1263
|
+
getDefaultRuntimeContext().TypeSystemPolicy.Set(options);
|
|
1264
|
+
}
|
|
1265
|
+
};
|
|
1266
|
+
var Settings = {
|
|
1267
|
+
Get() {
|
|
1268
|
+
return getDefaultRuntimeContext().Settings.Get();
|
|
1269
|
+
},
|
|
1270
|
+
Reset() {
|
|
1271
|
+
getDefaultRuntimeContext().Settings.Reset();
|
|
1272
|
+
},
|
|
1273
|
+
Set(options) {
|
|
1274
|
+
getDefaultRuntimeContext().Settings.Set(options);
|
|
1275
|
+
}
|
|
1276
|
+
};
|
|
1277
|
+
// src/schema/schema.ts
|
|
1278
|
+
var exports_schema = {};
|
|
1279
|
+
__export(exports_schema, {
|
|
1280
|
+
Validator: () => Validator,
|
|
1281
|
+
TryParse: () => TryParse,
|
|
1282
|
+
To: () => To,
|
|
1283
|
+
Stack: () => Stack,
|
|
1284
|
+
Set: () => Set2,
|
|
1285
|
+
Schema: () => Schema,
|
|
1286
|
+
Resolve: () => Resolve,
|
|
1287
|
+
ResetFunctions: () => ResetFunctions,
|
|
1288
|
+
ResetExternal: () => ResetExternal,
|
|
1289
|
+
Ref: () => Ref,
|
|
1290
|
+
Reducer: () => Reducer,
|
|
1291
|
+
Pointer: () => Pointer,
|
|
1292
|
+
ParseError: () => ParseError,
|
|
1293
|
+
Parse: () => Parse,
|
|
1294
|
+
IsUniqueItems: () => IsUniqueItems,
|
|
1295
|
+
IsUnevaluatedProperties: () => IsUnevaluatedProperties,
|
|
1296
|
+
IsUnevaluatedItems: () => IsUnevaluatedItems,
|
|
1297
|
+
IsType: () => IsType,
|
|
1298
|
+
IsThen: () => IsThen,
|
|
1299
|
+
IsSchemaObject: () => IsSchemaObject2,
|
|
1300
|
+
IsSchema: () => IsSchema2,
|
|
1301
|
+
IsRequired: () => IsRequired,
|
|
1302
|
+
IsRefine: () => IsRefine,
|
|
1303
|
+
IsRef: () => IsRef,
|
|
1304
|
+
IsRecursiveRef: () => IsRecursiveRef,
|
|
1305
|
+
IsRecursiveAnchorTrue: () => IsRecursiveAnchorTrue,
|
|
1306
|
+
IsRecursiveAnchor: () => IsRecursiveAnchor,
|
|
1307
|
+
IsPropertyNames: () => IsPropertyNames,
|
|
1308
|
+
IsProperties: () => IsProperties,
|
|
1309
|
+
IsPrefixItems: () => IsPrefixItems,
|
|
1310
|
+
IsPatternProperties: () => IsPatternProperties,
|
|
1311
|
+
IsPattern: () => IsPattern,
|
|
1312
|
+
IsOneOf: () => IsOneOf,
|
|
1313
|
+
IsNot: () => IsNot,
|
|
1314
|
+
IsMultipleOf: () => IsMultipleOf,
|
|
1315
|
+
IsMinimum: () => IsMinimum,
|
|
1316
|
+
IsMinProperties: () => IsMinProperties,
|
|
1317
|
+
IsMinLength: () => IsMinLength,
|
|
1318
|
+
IsMinItems: () => IsMinItems,
|
|
1319
|
+
IsMinContains: () => IsMinContains,
|
|
1320
|
+
IsMaximum: () => IsMaximum,
|
|
1321
|
+
IsMaxProperties: () => IsMaxProperties,
|
|
1322
|
+
IsMaxLength: () => IsMaxLength,
|
|
1323
|
+
IsMaxItems: () => IsMaxItems,
|
|
1324
|
+
IsMaxContains: () => IsMaxContains,
|
|
1325
|
+
IsItemsUnsized: () => IsItemsUnsized,
|
|
1326
|
+
IsItemsSized: () => IsItemsSized,
|
|
1327
|
+
IsItems: () => IsItems,
|
|
1328
|
+
IsIf: () => IsIf,
|
|
1329
|
+
IsId: () => IsId,
|
|
1330
|
+
IsGuardInterface: () => IsGuardInterface,
|
|
1331
|
+
IsGuard: () => IsGuard,
|
|
1332
|
+
IsFormat: () => IsFormat,
|
|
1333
|
+
IsExclusiveMinimum: () => IsExclusiveMinimum,
|
|
1334
|
+
IsExclusiveMaximum: () => IsExclusiveMaximum,
|
|
1335
|
+
IsEnum: () => IsEnum,
|
|
1336
|
+
IsElse: () => IsElse,
|
|
1337
|
+
IsDynamicRef: () => IsDynamicRef,
|
|
1338
|
+
IsDynamicAnchor: () => IsDynamicAnchor,
|
|
1339
|
+
IsDependentSchemas: () => IsDependentSchemas,
|
|
1340
|
+
IsDependentRequired: () => IsDependentRequired,
|
|
1341
|
+
IsDependencies: () => IsDependencies,
|
|
1342
|
+
IsDefs: () => IsDefs,
|
|
1343
|
+
IsDefault: () => IsDefault,
|
|
1344
|
+
IsContentMediaType: () => IsContentMediaType,
|
|
1345
|
+
IsContentEncoding: () => IsContentEncoding,
|
|
1346
|
+
IsContains: () => IsContains,
|
|
1347
|
+
IsConst: () => IsConst,
|
|
1348
|
+
IsBooleanSchema: () => IsBooleanSchema,
|
|
1349
|
+
IsAnyOf: () => IsAnyOf,
|
|
1350
|
+
IsAnchor: () => IsAnchor,
|
|
1351
|
+
IsAllOf: () => IsAllOf,
|
|
1352
|
+
IsAdditionalProperties: () => IsAdditionalProperties,
|
|
1353
|
+
IsAdditionalItems: () => IsAdditionalItems,
|
|
1354
|
+
Indices: () => Indices,
|
|
1355
|
+
HasUnevaluated: () => HasUnevaluated,
|
|
1356
|
+
Has: () => Has,
|
|
1357
|
+
GetFunctions: () => GetFunctions,
|
|
1358
|
+
GetExternal: () => GetExternal,
|
|
1359
|
+
Get: () => Get,
|
|
1360
|
+
Errors: () => Errors,
|
|
1361
|
+
ErrorUniqueItems: () => ErrorUniqueItems,
|
|
1362
|
+
ErrorUnevaluatedProperties: () => ErrorUnevaluatedProperties,
|
|
1363
|
+
ErrorUnevaluatedItems: () => ErrorUnevaluatedItems,
|
|
1364
|
+
ErrorType: () => ErrorType,
|
|
1365
|
+
ErrorSchema: () => ErrorSchema,
|
|
1366
|
+
ErrorRequired: () => ErrorRequired,
|
|
1367
|
+
ErrorRefine: () => ErrorRefine,
|
|
1368
|
+
ErrorRef: () => ErrorRef,
|
|
1369
|
+
ErrorRecursiveRef: () => ErrorRecursiveRef,
|
|
1370
|
+
ErrorPropertyNames: () => ErrorPropertyNames,
|
|
1371
|
+
ErrorProperties: () => ErrorProperties,
|
|
1372
|
+
ErrorPrefixItems: () => ErrorPrefixItems,
|
|
1373
|
+
ErrorPatternProperties: () => ErrorPatternProperties,
|
|
1374
|
+
ErrorPattern: () => ErrorPattern,
|
|
1375
|
+
ErrorOneOf: () => ErrorOneOf,
|
|
1376
|
+
ErrorNot: () => ErrorNot,
|
|
1377
|
+
ErrorMultipleOf: () => ErrorMultipleOf,
|
|
1378
|
+
ErrorMinimum: () => ErrorMinimum,
|
|
1379
|
+
ErrorMinProperties: () => ErrorMinProperties,
|
|
1380
|
+
ErrorMinLength: () => ErrorMinLength,
|
|
1381
|
+
ErrorMinItems: () => ErrorMinItems,
|
|
1382
|
+
ErrorMinContains: () => ErrorMinContains,
|
|
1383
|
+
ErrorMaximum: () => ErrorMaximum,
|
|
1384
|
+
ErrorMaxProperties: () => ErrorMaxProperties,
|
|
1385
|
+
ErrorMaxLength: () => ErrorMaxLength,
|
|
1386
|
+
ErrorMaxItems: () => ErrorMaxItems,
|
|
1387
|
+
ErrorMaxContains: () => ErrorMaxContains,
|
|
1388
|
+
ErrorItems: () => ErrorItems,
|
|
1389
|
+
ErrorIf: () => ErrorIf,
|
|
1390
|
+
ErrorGuard: () => ErrorGuard,
|
|
1391
|
+
ErrorFormat: () => ErrorFormat,
|
|
1392
|
+
ErrorExclusiveMinimum: () => ErrorExclusiveMinimum,
|
|
1393
|
+
ErrorExclusiveMaximum: () => ErrorExclusiveMaximum,
|
|
1394
|
+
ErrorEnum: () => ErrorEnum,
|
|
1395
|
+
ErrorDependentSchemas: () => ErrorDependentSchemas,
|
|
1396
|
+
ErrorDependentRequired: () => ErrorDependentRequired,
|
|
1397
|
+
ErrorDependencies: () => ErrorDependencies,
|
|
1398
|
+
ErrorContext: () => ErrorContext,
|
|
1399
|
+
ErrorContains: () => ErrorContains,
|
|
1400
|
+
ErrorConst: () => ErrorConst,
|
|
1401
|
+
ErrorBooleanSchema: () => ErrorBooleanSchema,
|
|
1402
|
+
ErrorAnyOf: () => ErrorAnyOf,
|
|
1403
|
+
ErrorAllOf: () => ErrorAllOf,
|
|
1404
|
+
ErrorAdditionalProperties: () => ErrorAdditionalProperties,
|
|
1405
|
+
ErrorAdditionalItems: () => ErrorAdditionalItems,
|
|
1406
|
+
Delete: () => Delete,
|
|
1407
|
+
CreateVariable: () => CreateVariable,
|
|
1408
|
+
CreateFunction: () => CreateFunction,
|
|
1409
|
+
Compile: () => Compile,
|
|
1410
|
+
CheckUniqueItems: () => CheckUniqueItems,
|
|
1411
|
+
CheckUnevaluatedProperties: () => CheckUnevaluatedProperties,
|
|
1412
|
+
CheckUnevaluatedItems: () => CheckUnevaluatedItems,
|
|
1413
|
+
CheckType: () => CheckType,
|
|
1414
|
+
CheckSchema: () => CheckSchema,
|
|
1415
|
+
CheckRequired: () => CheckRequired,
|
|
1416
|
+
CheckRefine: () => CheckRefine,
|
|
1417
|
+
CheckRef: () => CheckRef,
|
|
1418
|
+
CheckRecursiveRef: () => CheckRecursiveRef,
|
|
1419
|
+
CheckPropertyNames: () => CheckPropertyNames,
|
|
1420
|
+
CheckProperties: () => CheckProperties,
|
|
1421
|
+
CheckPrefixItems: () => CheckPrefixItems,
|
|
1422
|
+
CheckPatternProperties: () => CheckPatternProperties,
|
|
1423
|
+
CheckPattern: () => CheckPattern,
|
|
1424
|
+
CheckOneOf: () => CheckOneOf,
|
|
1425
|
+
CheckNot: () => CheckNot,
|
|
1426
|
+
CheckMultipleOf: () => CheckMultipleOf,
|
|
1427
|
+
CheckMinimum: () => CheckMinimum,
|
|
1428
|
+
CheckMinProperties: () => CheckMinProperties,
|
|
1429
|
+
CheckMinLength: () => CheckMinLength,
|
|
1430
|
+
CheckMinItems: () => CheckMinItems,
|
|
1431
|
+
CheckMinContains: () => CheckMinContains,
|
|
1432
|
+
CheckMaximum: () => CheckMaximum,
|
|
1433
|
+
CheckMaxProperties: () => CheckMaxProperties,
|
|
1434
|
+
CheckMaxLength: () => CheckMaxLength,
|
|
1435
|
+
CheckMaxItems: () => CheckMaxItems,
|
|
1436
|
+
CheckMaxContains: () => CheckMaxContains,
|
|
1437
|
+
CheckItems: () => CheckItems,
|
|
1438
|
+
CheckIf: () => CheckIf,
|
|
1439
|
+
CheckGuard: () => CheckGuard,
|
|
1440
|
+
CheckFormat: () => CheckFormat,
|
|
1441
|
+
CheckExclusiveMinimum: () => CheckExclusiveMinimum,
|
|
1442
|
+
CheckExclusiveMaximum: () => CheckExclusiveMaximum,
|
|
1443
|
+
CheckEnum: () => CheckEnum,
|
|
1444
|
+
CheckDependentSchemas: () => CheckDependentSchemas,
|
|
1445
|
+
CheckDependentRequired: () => CheckDependentRequired,
|
|
1446
|
+
CheckDependencies: () => CheckDependencies,
|
|
1447
|
+
CheckContext: () => CheckContext,
|
|
1448
|
+
CheckContains: () => CheckContains,
|
|
1449
|
+
CheckConst: () => CheckConst,
|
|
1450
|
+
CheckBooleanSchema: () => CheckBooleanSchema,
|
|
1451
|
+
CheckAnyOf: () => CheckAnyOf,
|
|
1452
|
+
CheckAllOf: () => CheckAllOf,
|
|
1453
|
+
CheckAdditionalProperties: () => CheckAdditionalProperties,
|
|
1454
|
+
CheckAdditionalItems: () => CheckAdditionalItems,
|
|
1455
|
+
Check: () => Check,
|
|
1456
|
+
CanAdditionalPropertiesFast: () => CanAdditionalPropertiesFast,
|
|
1457
|
+
BuildUniqueItems: () => BuildUniqueItems,
|
|
1458
|
+
BuildUnevaluatedProperties: () => BuildUnevaluatedProperties,
|
|
1459
|
+
BuildUnevaluatedItems: () => BuildUnevaluatedItems,
|
|
1460
|
+
BuildType: () => BuildType,
|
|
1461
|
+
BuildSchema: () => BuildSchema,
|
|
1462
|
+
BuildResult: () => BuildResult,
|
|
1463
|
+
BuildRequired: () => BuildRequired,
|
|
1464
|
+
BuildRefine: () => BuildRefine,
|
|
1465
|
+
BuildRef: () => BuildRef,
|
|
1466
|
+
BuildRecursiveRef: () => BuildRecursiveRef,
|
|
1467
|
+
BuildPropertyNames: () => BuildPropertyNames,
|
|
1468
|
+
BuildProperties: () => BuildProperties,
|
|
1469
|
+
BuildPrefixItems: () => BuildPrefixItems,
|
|
1470
|
+
BuildPatternProperties: () => BuildPatternProperties,
|
|
1471
|
+
BuildPattern: () => BuildPattern,
|
|
1472
|
+
BuildOneOf: () => BuildOneOf,
|
|
1473
|
+
BuildNot: () => BuildNot,
|
|
1474
|
+
BuildMultipleOf: () => BuildMultipleOf,
|
|
1475
|
+
BuildMinimum: () => BuildMinimum,
|
|
1476
|
+
BuildMinProperties: () => BuildMinProperties,
|
|
1477
|
+
BuildMinLength: () => BuildMinLength,
|
|
1478
|
+
BuildMinItems: () => BuildMinItems,
|
|
1479
|
+
BuildMinContains: () => BuildMinContains,
|
|
1480
|
+
BuildMaximum: () => BuildMaximum,
|
|
1481
|
+
BuildMaxProperties: () => BuildMaxProperties,
|
|
1482
|
+
BuildMaxLength: () => BuildMaxLength,
|
|
1483
|
+
BuildMaxItems: () => BuildMaxItems,
|
|
1484
|
+
BuildMaxContains: () => BuildMaxContains,
|
|
1485
|
+
BuildItems: () => BuildItems,
|
|
1486
|
+
BuildIf: () => BuildIf,
|
|
1487
|
+
BuildGuard: () => BuildGuard,
|
|
1488
|
+
BuildFormat: () => BuildFormat,
|
|
1489
|
+
BuildExclusiveMinimum: () => BuildExclusiveMinimum,
|
|
1490
|
+
BuildExclusiveMaximum: () => BuildExclusiveMaximum,
|
|
1491
|
+
BuildEnum: () => BuildEnum,
|
|
1492
|
+
BuildDependentSchemas: () => BuildDependentSchemas,
|
|
1493
|
+
BuildDependentRequired: () => BuildDependentRequired,
|
|
1494
|
+
BuildDependencies: () => BuildDependencies,
|
|
1495
|
+
BuildContext: () => BuildContext,
|
|
1496
|
+
BuildContains: () => BuildContains,
|
|
1497
|
+
BuildConst: () => BuildConst,
|
|
1498
|
+
BuildBooleanSchema: () => BuildBooleanSchema,
|
|
1499
|
+
BuildAnyOf: () => BuildAnyOf,
|
|
1500
|
+
BuildAllOf: () => BuildAllOf,
|
|
1501
|
+
BuildAdditionalPropertiesStandard: () => BuildAdditionalPropertiesStandard,
|
|
1502
|
+
BuildAdditionalPropertiesFast: () => BuildAdditionalPropertiesFast,
|
|
1503
|
+
BuildAdditionalProperties: () => BuildAdditionalProperties,
|
|
1504
|
+
BuildAdditionalItems: () => BuildAdditionalItems,
|
|
1505
|
+
Build: () => Build,
|
|
1506
|
+
AccumulatedErrorContext: () => AccumulatedErrorContext
|
|
1507
|
+
});
|
|
1508
|
+
|
|
1509
|
+
// src/schema/shared.ts
|
|
1510
|
+
function IsArray(value) {
|
|
1511
|
+
return Array.isArray(value);
|
|
1512
|
+
}
|
|
1513
|
+
function IsObject(value) {
|
|
1514
|
+
return typeof value === "object" && value !== null;
|
|
1515
|
+
}
|
|
1516
|
+
function IsPlainObject(value) {
|
|
1517
|
+
return IsObject(value) && !Array.isArray(value);
|
|
1518
|
+
}
|
|
1519
|
+
function IsSchemaObject(value) {
|
|
1520
|
+
return IsObject(value);
|
|
1521
|
+
}
|
|
1522
|
+
function IsSchema(value) {
|
|
1523
|
+
return typeof value === "boolean" || IsSchemaObject(value);
|
|
1524
|
+
}
|
|
1525
|
+
function HasPropertyKey(value, key) {
|
|
1526
|
+
return key in value;
|
|
1527
|
+
}
|
|
1528
|
+
function HasString(value, key) {
|
|
1529
|
+
return typeof value[key] === "string";
|
|
1530
|
+
}
|
|
1531
|
+
function HasBoolean(value, key) {
|
|
1532
|
+
return typeof value[key] === "boolean";
|
|
1533
|
+
}
|
|
1534
|
+
function HasArray(value, key) {
|
|
1535
|
+
return Array.isArray(value[key]);
|
|
1536
|
+
}
|
|
1537
|
+
function HasObject(value, key) {
|
|
1538
|
+
return IsObject(value[key]);
|
|
1539
|
+
}
|
|
1540
|
+
function Keys(value) {
|
|
1541
|
+
return Object.keys(value);
|
|
1542
|
+
}
|
|
1543
|
+
function Entries(value) {
|
|
1544
|
+
return Object.entries(value);
|
|
1545
|
+
}
|
|
1546
|
+
function NormalizeArgs(args) {
|
|
1547
|
+
return args.length === 2 ? [{}, args[0], args[1]] : [args[0], args[1], args[2]];
|
|
1548
|
+
}
|
|
1549
|
+
function DecodePointerToken(token) {
|
|
1550
|
+
return token.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
1551
|
+
}
|
|
1552
|
+
function ProjectSchema(schema, keys, defaults = {}) {
|
|
1553
|
+
if (typeof schema === "boolean") {
|
|
1554
|
+
return schema;
|
|
1555
|
+
}
|
|
1556
|
+
const projected = { ...defaults };
|
|
1557
|
+
for (const key of keys) {
|
|
1558
|
+
if (key in schema) {
|
|
1559
|
+
projected[key] = schema[key];
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
return projected;
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
// src/schema/pointer.ts
|
|
1566
|
+
function assertNotRoot(indices) {
|
|
1567
|
+
if (indices.length === 0) {
|
|
1568
|
+
throw new Error("Cannot set root");
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
function assertIndexable(value) {
|
|
1572
|
+
if (!IsObject(value)) {
|
|
1573
|
+
throw new Error("Cannot set value");
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
function hasIndex(index, value) {
|
|
1577
|
+
return IsObject(value) && index in value;
|
|
1578
|
+
}
|
|
1579
|
+
function getIndex(index, value) {
|
|
1580
|
+
return IsObject(value) ? value[index] : undefined;
|
|
1581
|
+
}
|
|
1582
|
+
function takeIndexRight(indices) {
|
|
1583
|
+
return [indices.slice(0, indices.length - 1), indices[indices.length - 1] ?? ""];
|
|
1584
|
+
}
|
|
1585
|
+
function getIndices(indices, value) {
|
|
1586
|
+
return indices.reduce((current, index) => getIndex(index, current), value);
|
|
1587
|
+
}
|
|
1588
|
+
function isNumericIndex(index) {
|
|
1589
|
+
return /^(0|[1-9]\d*)$/.test(index);
|
|
1590
|
+
}
|
|
1591
|
+
function Indices(pointer) {
|
|
1592
|
+
if (pointer.length === 0) {
|
|
1593
|
+
return [];
|
|
1594
|
+
}
|
|
1595
|
+
const indices = pointer.split("/").map(DecodePointerToken);
|
|
1596
|
+
return indices.length > 0 && indices[0] === "" ? indices.slice(1) : indices;
|
|
1597
|
+
}
|
|
1598
|
+
function Has(value, pointer) {
|
|
1599
|
+
let current = value;
|
|
1600
|
+
return Indices(pointer).every((index) => {
|
|
1601
|
+
if (!hasIndex(index, current)) {
|
|
1602
|
+
return false;
|
|
1603
|
+
}
|
|
1604
|
+
current = getIndex(index, current);
|
|
1605
|
+
return true;
|
|
1606
|
+
});
|
|
1607
|
+
}
|
|
1608
|
+
function Get(value, pointer) {
|
|
1609
|
+
return getIndices(Indices(pointer), value);
|
|
1610
|
+
}
|
|
1611
|
+
function Set2(value, pointer, next) {
|
|
1612
|
+
const indices = Indices(pointer);
|
|
1613
|
+
assertNotRoot(indices);
|
|
1614
|
+
const [head, index] = takeIndexRight(indices);
|
|
1615
|
+
const parent = getIndices(head, value);
|
|
1616
|
+
assertIndexable(parent);
|
|
1617
|
+
if (Array.isArray(parent) && isNumericIndex(index)) {
|
|
1618
|
+
parent[Number(index)] = next;
|
|
1619
|
+
} else if (IsObject(parent)) {
|
|
1620
|
+
parent[index] = next;
|
|
1621
|
+
}
|
|
1622
|
+
return value;
|
|
1623
|
+
}
|
|
1624
|
+
function Delete(value, pointer) {
|
|
1625
|
+
const indices = Indices(pointer);
|
|
1626
|
+
assertNotRoot(indices);
|
|
1627
|
+
const [head, index] = takeIndexRight(indices);
|
|
1628
|
+
const parent = getIndices(head, value);
|
|
1629
|
+
assertIndexable(parent);
|
|
1630
|
+
if (IsArray(parent) && isNumericIndex(index)) {
|
|
1631
|
+
parent.splice(Number(index), 1);
|
|
1632
|
+
} else {
|
|
1633
|
+
delete parent[index];
|
|
1634
|
+
}
|
|
1635
|
+
return value;
|
|
1636
|
+
}
|
|
1637
|
+
var Pointer = {
|
|
1638
|
+
Delete,
|
|
1639
|
+
Get,
|
|
1640
|
+
Has,
|
|
1641
|
+
Indices,
|
|
1642
|
+
Set: Set2
|
|
1643
|
+
};
|
|
1644
|
+
// src/schema/resolve.ts
|
|
1645
|
+
function matchHash(schema, ref) {
|
|
1646
|
+
if (ref.href.endsWith("#")) {
|
|
1647
|
+
return schema;
|
|
1648
|
+
}
|
|
1649
|
+
if (!ref.hash.startsWith("#")) {
|
|
1650
|
+
return;
|
|
1651
|
+
}
|
|
1652
|
+
const value = Get(schema, decodeURIComponent(DecodePointerToken(ref.hash.slice(1))));
|
|
1653
|
+
return IsSchema(value) ? value : undefined;
|
|
1654
|
+
}
|
|
1655
|
+
function matchId(schema, base, ref) {
|
|
1656
|
+
const id = schema["$id"];
|
|
1657
|
+
if (typeof id !== "string") {
|
|
1658
|
+
return;
|
|
1659
|
+
}
|
|
1660
|
+
if (id === ref.hash) {
|
|
1661
|
+
return schema;
|
|
1662
|
+
}
|
|
1663
|
+
const absoluteId = new URL(id, base.href);
|
|
1664
|
+
const absoluteRef = new URL(ref.href, base.href);
|
|
1665
|
+
if (absoluteId.pathname === absoluteRef.pathname) {
|
|
1666
|
+
return ref.hash.startsWith("#") ? matchHash(schema, ref) : schema;
|
|
1667
|
+
}
|
|
1668
|
+
return;
|
|
1669
|
+
}
|
|
1670
|
+
function matchAnchor(schema, base, ref) {
|
|
1671
|
+
const anchor = schema["$anchor"];
|
|
1672
|
+
if (typeof anchor !== "string") {
|
|
1673
|
+
return;
|
|
1674
|
+
}
|
|
1675
|
+
const absoluteAnchor = new URL(`#${anchor}`, base.href);
|
|
1676
|
+
const absoluteRef = new URL(ref.href, base.href);
|
|
1677
|
+
return absoluteAnchor.href === absoluteRef.href ? schema : undefined;
|
|
1678
|
+
}
|
|
1679
|
+
function match(schema, base, ref) {
|
|
1680
|
+
return matchId(schema, base, ref) ?? matchAnchor(schema, base, ref) ?? matchHash(schema, ref);
|
|
1681
|
+
}
|
|
1682
|
+
function fromArray(values, base, ref) {
|
|
1683
|
+
for (const value of values) {
|
|
1684
|
+
const found = fromValue(value, base, ref);
|
|
1685
|
+
if (found !== undefined) {
|
|
1686
|
+
return found;
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
return;
|
|
1690
|
+
}
|
|
1691
|
+
function fromObject(schema, base, ref) {
|
|
1692
|
+
for (const key of Keys(schema)) {
|
|
1693
|
+
const found = fromValue(schema[key], base, ref);
|
|
1694
|
+
if (found !== undefined) {
|
|
1695
|
+
return found;
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
return;
|
|
1699
|
+
}
|
|
1700
|
+
function fromValue(value, base, ref) {
|
|
1701
|
+
const nextId = IsSchemaObject(value) ? value["$id"] : undefined;
|
|
1702
|
+
const nextBase = typeof nextId === "string" ? new URL(nextId, base.href) : base;
|
|
1703
|
+
if (IsSchemaObject(value)) {
|
|
1704
|
+
const found = match(value, nextBase, ref);
|
|
1705
|
+
if (found !== undefined) {
|
|
1706
|
+
return found;
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
if (IsArray(value)) {
|
|
1710
|
+
return fromArray(value, nextBase, ref);
|
|
1711
|
+
}
|
|
1712
|
+
if (IsObject(value)) {
|
|
1713
|
+
return fromObject(value, nextBase, ref);
|
|
1714
|
+
}
|
|
1715
|
+
return;
|
|
1716
|
+
}
|
|
1717
|
+
function Ref(schema, ref) {
|
|
1718
|
+
const defaultBase = new URL("http://unknown");
|
|
1719
|
+
const initialId = IsSchemaObject(schema) ? schema["$id"] : undefined;
|
|
1720
|
+
const initialBase = typeof initialId === "string" ? new URL(initialId, defaultBase.href) : defaultBase;
|
|
1721
|
+
const targetRef = new URL(ref, initialBase.href);
|
|
1722
|
+
return fromValue(schema, initialBase, targetRef);
|
|
1723
|
+
}
|
|
1724
|
+
var Resolve = {
|
|
1725
|
+
Ref
|
|
1726
|
+
};
|
|
1727
|
+
// src/schema/predicates.ts
|
|
1728
|
+
function hasKeyword(keyword) {
|
|
1729
|
+
return (schema) => IsSchemaObject(schema) && HasPropertyKey(schema, keyword);
|
|
1730
|
+
}
|
|
1731
|
+
var IsSchemaObject2 = (schema) => IsSchemaObject(schema);
|
|
1732
|
+
var IsBooleanSchema = (schema) => typeof schema === "boolean";
|
|
1733
|
+
var IsSchema2 = (schema) => IsSchema(schema);
|
|
1734
|
+
var IsAdditionalItems = hasKeyword("additionalItems");
|
|
1735
|
+
var IsAdditionalProperties = hasKeyword("additionalProperties");
|
|
1736
|
+
var IsAllOf = hasKeyword("allOf");
|
|
1737
|
+
var IsAnchor = (schema) => IsSchemaObject(schema) && HasString(schema, "$anchor");
|
|
1738
|
+
var IsAnyOf = hasKeyword("anyOf");
|
|
1739
|
+
var IsConst = hasKeyword("const");
|
|
1740
|
+
var IsContains = hasKeyword("contains");
|
|
1741
|
+
var IsContentEncoding = hasKeyword("contentEncoding");
|
|
1742
|
+
var IsContentMediaType = hasKeyword("contentMediaType");
|
|
1743
|
+
var IsDefault = hasKeyword("default");
|
|
1744
|
+
var IsDefs = hasKeyword("$defs");
|
|
1745
|
+
var IsDependencies = hasKeyword("dependencies");
|
|
1746
|
+
var IsDependentRequired = hasKeyword("dependentRequired");
|
|
1747
|
+
var IsDependentSchemas = hasKeyword("dependentSchemas");
|
|
1748
|
+
var IsDynamicAnchor = (schema) => IsSchemaObject(schema) && HasString(schema, "$dynamicAnchor");
|
|
1749
|
+
var IsDynamicRef = (schema) => IsSchemaObject(schema) && HasString(schema, "$dynamicRef");
|
|
1750
|
+
var IsElse = hasKeyword("else");
|
|
1751
|
+
var IsEnum = hasKeyword("enum");
|
|
1752
|
+
var IsExclusiveMaximum = hasKeyword("exclusiveMaximum");
|
|
1753
|
+
var IsExclusiveMinimum = hasKeyword("exclusiveMinimum");
|
|
1754
|
+
var IsFormat = hasKeyword("format");
|
|
1755
|
+
var IsGuard = (schema) => IsSchemaObject(schema) && HasObject(schema, "~guard");
|
|
1756
|
+
var IsGuardInterface = IsGuard;
|
|
1757
|
+
var IsId = (schema) => IsSchemaObject(schema) && HasString(schema, "$id");
|
|
1758
|
+
var IsIf = hasKeyword("if");
|
|
1759
|
+
var IsItems = hasKeyword("items");
|
|
1760
|
+
var IsItemsSized = (schema) => IsSchemaObject(schema) && HasArray(schema, "prefixItems");
|
|
1761
|
+
var IsItemsUnsized = (schema) => IsSchemaObject(schema) && HasPropertyKey(schema, "items") && !HasArray(schema, "prefixItems");
|
|
1762
|
+
var IsMaxContains = hasKeyword("maxContains");
|
|
1763
|
+
var IsMaxItems = hasKeyword("maxItems");
|
|
1764
|
+
var IsMaxLength = hasKeyword("maxLength");
|
|
1765
|
+
var IsMaxProperties = hasKeyword("maxProperties");
|
|
1766
|
+
var IsMaximum = hasKeyword("maximum");
|
|
1767
|
+
var IsMinContains = hasKeyword("minContains");
|
|
1768
|
+
var IsMinItems = hasKeyword("minItems");
|
|
1769
|
+
var IsMinLength = hasKeyword("minLength");
|
|
1770
|
+
var IsMinProperties = hasKeyword("minProperties");
|
|
1771
|
+
var IsMinimum = hasKeyword("minimum");
|
|
1772
|
+
var IsMultipleOf = hasKeyword("multipleOf");
|
|
1773
|
+
var IsNot = hasKeyword("not");
|
|
1774
|
+
var IsOneOf = hasKeyword("oneOf");
|
|
1775
|
+
var IsPattern = hasKeyword("pattern");
|
|
1776
|
+
var IsPatternProperties = hasKeyword("patternProperties");
|
|
1777
|
+
var IsPrefixItems = hasKeyword("prefixItems");
|
|
1778
|
+
var IsProperties = hasKeyword("properties");
|
|
1779
|
+
var IsPropertyNames = hasKeyword("propertyNames");
|
|
1780
|
+
var IsRecursiveAnchor = hasKeyword("$recursiveAnchor");
|
|
1781
|
+
var IsRecursiveAnchorTrue = (schema) => IsSchemaObject(schema) && HasBoolean(schema, "$recursiveAnchor") && schema.$recursiveAnchor === true;
|
|
1782
|
+
var IsRecursiveRef = hasKeyword("$recursiveRef");
|
|
1783
|
+
var IsRef = hasKeyword("$ref");
|
|
1784
|
+
var IsRefine = (schema) => IsSchemaObject(schema) && HasArray(schema, "~refine");
|
|
1785
|
+
var IsRequired = hasKeyword("required");
|
|
1786
|
+
var IsThen = hasKeyword("then");
|
|
1787
|
+
var IsType = hasKeyword("type");
|
|
1788
|
+
var IsUnevaluatedItems = hasKeyword("unevaluatedItems");
|
|
1789
|
+
var IsUnevaluatedProperties = hasKeyword("unevaluatedProperties");
|
|
1790
|
+
var IsUniqueItems = hasKeyword("uniqueItems");
|
|
1791
|
+
// src/schema/core-keywords.ts
|
|
1792
|
+
function MatchesType(type, value) {
|
|
1793
|
+
if (Array.isArray(type)) {
|
|
1794
|
+
return type.some((entry) => MatchesType(entry, value));
|
|
1795
|
+
}
|
|
1796
|
+
if (typeof type !== "string") {
|
|
1797
|
+
return true;
|
|
1798
|
+
}
|
|
1799
|
+
switch (type) {
|
|
1800
|
+
case "array":
|
|
1801
|
+
return Array.isArray(value);
|
|
1802
|
+
case "boolean":
|
|
1803
|
+
return typeof value === "boolean";
|
|
1804
|
+
case "integer":
|
|
1805
|
+
return typeof value === "number" && Number.isInteger(value);
|
|
1806
|
+
case "null":
|
|
1807
|
+
return value === null;
|
|
1808
|
+
case "number":
|
|
1809
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
1810
|
+
case "object":
|
|
1811
|
+
return IsPlainObject(value);
|
|
1812
|
+
case "string":
|
|
1813
|
+
return typeof value === "string";
|
|
1814
|
+
default:
|
|
1815
|
+
return true;
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
function uniqueItems(items) {
|
|
1819
|
+
const seen = new Set;
|
|
1820
|
+
for (const item of items) {
|
|
1821
|
+
const signature = JSON.stringify(item);
|
|
1822
|
+
if (seen.has(signature)) {
|
|
1823
|
+
return false;
|
|
1824
|
+
}
|
|
1825
|
+
seen.add(signature);
|
|
1826
|
+
}
|
|
1827
|
+
return true;
|
|
1828
|
+
}
|
|
1829
|
+
function CheckStringKeywords(record, value) {
|
|
1830
|
+
if (typeof value !== "string") {
|
|
1831
|
+
return true;
|
|
1832
|
+
}
|
|
1833
|
+
const minLength = record["minLength"];
|
|
1834
|
+
if (typeof minLength === "number" && value.length < minLength) {
|
|
1835
|
+
return false;
|
|
1836
|
+
}
|
|
1837
|
+
const maxLength = record["maxLength"];
|
|
1838
|
+
if (typeof maxLength === "number" && value.length > maxLength) {
|
|
1839
|
+
return false;
|
|
1840
|
+
}
|
|
1841
|
+
const pattern = record["pattern"];
|
|
1842
|
+
if (typeof pattern === "string" && !new RegExp(pattern).test(value)) {
|
|
1843
|
+
return false;
|
|
1844
|
+
}
|
|
1845
|
+
const format = record["format"];
|
|
1846
|
+
if (typeof format === "string") {
|
|
1847
|
+
const validator = FormatRegistry.Get(format);
|
|
1848
|
+
if (validator !== undefined && !validator(value)) {
|
|
1849
|
+
return false;
|
|
1850
|
+
}
|
|
1851
|
+
}
|
|
1852
|
+
return true;
|
|
1853
|
+
}
|
|
1854
|
+
function CheckNumberKeywords(record, value) {
|
|
1855
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
1856
|
+
return true;
|
|
1857
|
+
}
|
|
1858
|
+
const minimum = record["minimum"];
|
|
1859
|
+
if (typeof minimum === "number" && value < minimum) {
|
|
1860
|
+
return false;
|
|
1861
|
+
}
|
|
1862
|
+
const maximum = record["maximum"];
|
|
1863
|
+
if (typeof maximum === "number" && value > maximum) {
|
|
1864
|
+
return false;
|
|
1865
|
+
}
|
|
1866
|
+
const exclusiveMinimum = record["exclusiveMinimum"];
|
|
1867
|
+
if (typeof exclusiveMinimum === "number" && value <= exclusiveMinimum) {
|
|
1868
|
+
return false;
|
|
1869
|
+
}
|
|
1870
|
+
const exclusiveMaximum = record["exclusiveMaximum"];
|
|
1871
|
+
if (typeof exclusiveMaximum === "number" && value >= exclusiveMaximum) {
|
|
1872
|
+
return false;
|
|
1873
|
+
}
|
|
1874
|
+
const multipleOf = record["multipleOf"];
|
|
1875
|
+
if (typeof multipleOf === "number" && value % multipleOf !== 0) {
|
|
1876
|
+
return false;
|
|
1877
|
+
}
|
|
1878
|
+
return true;
|
|
1879
|
+
}
|
|
1880
|
+
function CheckArrayKeywords(check, context, record, value, root) {
|
|
1881
|
+
if (!Array.isArray(value)) {
|
|
1882
|
+
return true;
|
|
1883
|
+
}
|
|
1884
|
+
const minItems = record["minItems"];
|
|
1885
|
+
if (typeof minItems === "number" && value.length < minItems) {
|
|
1886
|
+
return false;
|
|
1887
|
+
}
|
|
1888
|
+
const maxItems = record["maxItems"];
|
|
1889
|
+
if (typeof maxItems === "number" && value.length > maxItems) {
|
|
1890
|
+
return false;
|
|
1891
|
+
}
|
|
1892
|
+
if (record["uniqueItems"] === true && !uniqueItems(value)) {
|
|
1893
|
+
return false;
|
|
1894
|
+
}
|
|
1895
|
+
const prefixItems = Array.isArray(record["prefixItems"]) ? record["prefixItems"] : undefined;
|
|
1896
|
+
if (prefixItems !== undefined) {
|
|
1897
|
+
for (let index = 0;index < prefixItems.length; index += 1) {
|
|
1898
|
+
const itemSchema = prefixItems[index];
|
|
1899
|
+
if (IsSchema(itemSchema) && !check(context, itemSchema, value[index], root)) {
|
|
1900
|
+
return false;
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
const items = IsSchema(record["items"]) ? record["items"] : undefined;
|
|
1905
|
+
if (items !== undefined) {
|
|
1906
|
+
const start = prefixItems?.length ?? 0;
|
|
1907
|
+
for (let index = start;index < value.length; index += 1) {
|
|
1908
|
+
if (!check(context, items, value[index], root)) {
|
|
1909
|
+
return false;
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
const additionalItems = IsSchema(record["additionalItems"]) ? record["additionalItems"] : undefined;
|
|
1914
|
+
if (additionalItems !== undefined && prefixItems !== undefined && items === undefined) {
|
|
1915
|
+
for (let index = prefixItems.length;index < value.length; index += 1) {
|
|
1916
|
+
if (!check(context, additionalItems, value[index], root)) {
|
|
1917
|
+
return false;
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
const unevaluatedItems = IsSchema(record["unevaluatedItems"]) ? record["unevaluatedItems"] : undefined;
|
|
1922
|
+
if (unevaluatedItems !== undefined && prefixItems !== undefined && items === undefined) {
|
|
1923
|
+
for (let index = prefixItems.length;index < value.length; index += 1) {
|
|
1924
|
+
if (!check(context, unevaluatedItems, value[index], root)) {
|
|
1925
|
+
return false;
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
const contains = IsSchema(record["contains"]) ? record["contains"] : undefined;
|
|
1930
|
+
if (contains !== undefined) {
|
|
1931
|
+
const count = value.filter((entry) => check(context, contains, entry, root)).length;
|
|
1932
|
+
if (count === 0) {
|
|
1933
|
+
return false;
|
|
1934
|
+
}
|
|
1935
|
+
const minContains = record["minContains"];
|
|
1936
|
+
if (typeof minContains === "number" && count < minContains) {
|
|
1937
|
+
return false;
|
|
1938
|
+
}
|
|
1939
|
+
const maxContains = record["maxContains"];
|
|
1940
|
+
if (typeof maxContains === "number" && count > maxContains) {
|
|
1941
|
+
return false;
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
return true;
|
|
1945
|
+
}
|
|
1946
|
+
function CheckObjectKeywords(check, context, record, value, root) {
|
|
1947
|
+
if (!IsPlainObject(value)) {
|
|
1948
|
+
return true;
|
|
1949
|
+
}
|
|
1950
|
+
const keys = Object.keys(value);
|
|
1951
|
+
const minProperties = record["minProperties"];
|
|
1952
|
+
if (typeof minProperties === "number" && keys.length < minProperties) {
|
|
1953
|
+
return false;
|
|
1954
|
+
}
|
|
1955
|
+
const maxProperties = record["maxProperties"];
|
|
1956
|
+
if (typeof maxProperties === "number" && keys.length > maxProperties) {
|
|
1957
|
+
return false;
|
|
1958
|
+
}
|
|
1959
|
+
const required = Array.isArray(record["required"]) ? record["required"] : undefined;
|
|
1960
|
+
if (required !== undefined && !required.every((entry) => typeof entry === "string" && (entry in value))) {
|
|
1961
|
+
return false;
|
|
1962
|
+
}
|
|
1963
|
+
const propertyNames = IsSchema(record["propertyNames"]) ? record["propertyNames"] : undefined;
|
|
1964
|
+
if (propertyNames !== undefined && !keys.every((key) => check(context, propertyNames, key, root))) {
|
|
1965
|
+
return false;
|
|
1966
|
+
}
|
|
1967
|
+
const properties = IsObject(record["properties"]) ? record["properties"] : undefined;
|
|
1968
|
+
const patternProperties = IsObject(record["patternProperties"]) ? record["patternProperties"] : undefined;
|
|
1969
|
+
for (const key of keys) {
|
|
1970
|
+
const propertySchema = properties?.[key];
|
|
1971
|
+
const matchedPatterns = patternProperties === undefined ? [] : Entries(patternProperties).filter(([pattern, schema]) => new RegExp(pattern).test(key) && IsSchema(schema)).map(([, schema]) => schema);
|
|
1972
|
+
if (IsSchema(propertySchema) && !check(context, propertySchema, value[key], root)) {
|
|
1973
|
+
return false;
|
|
1974
|
+
}
|
|
1975
|
+
if (matchedPatterns.some((schema) => !check(context, schema, value[key], root))) {
|
|
1976
|
+
return false;
|
|
1977
|
+
}
|
|
1978
|
+
if (propertySchema === undefined && matchedPatterns.length === 0) {
|
|
1979
|
+
const additionalProperties = record["additionalProperties"];
|
|
1980
|
+
if (additionalProperties === false) {
|
|
1981
|
+
return false;
|
|
1982
|
+
}
|
|
1983
|
+
if (IsSchema(additionalProperties) && !check(context, additionalProperties, value[key], root)) {
|
|
1984
|
+
return false;
|
|
1985
|
+
}
|
|
1986
|
+
const unevaluatedProperties = record["unevaluatedProperties"];
|
|
1987
|
+
if (unevaluatedProperties === false) {
|
|
1988
|
+
return false;
|
|
1989
|
+
}
|
|
1990
|
+
if (IsSchema(unevaluatedProperties) && !check(context, unevaluatedProperties, value[key], root)) {
|
|
1991
|
+
return false;
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
return true;
|
|
1996
|
+
}
|
|
1997
|
+
function CheckDependentKeywords(check, context, record, value, root) {
|
|
1998
|
+
if (!IsPlainObject(value)) {
|
|
1999
|
+
return true;
|
|
2000
|
+
}
|
|
2001
|
+
const dependentRequired = IsObject(record["dependentRequired"]) ? record["dependentRequired"] : undefined;
|
|
2002
|
+
if (dependentRequired !== undefined) {
|
|
2003
|
+
for (const [key, dependency] of Entries(dependentRequired)) {
|
|
2004
|
+
if (key in value && Array.isArray(dependency) && !dependency.every((entry) => typeof entry === "string" && (entry in value))) {
|
|
2005
|
+
return false;
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
const dependentSchemas = IsObject(record["dependentSchemas"]) ? record["dependentSchemas"] : undefined;
|
|
2010
|
+
if (dependentSchemas !== undefined) {
|
|
2011
|
+
for (const [key, dependency] of Entries(dependentSchemas)) {
|
|
2012
|
+
if (key in value && IsSchema(dependency) && !check(context, dependency, value, root)) {
|
|
2013
|
+
return false;
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
const dependencies = IsObject(record["dependencies"]) ? record["dependencies"] : undefined;
|
|
2018
|
+
if (dependencies !== undefined) {
|
|
2019
|
+
for (const [key, dependency] of Entries(dependencies)) {
|
|
2020
|
+
if (!(key in value)) {
|
|
2021
|
+
continue;
|
|
2022
|
+
}
|
|
2023
|
+
if (Array.isArray(dependency) && !dependency.every((entry) => typeof entry === "string" && (entry in value))) {
|
|
2024
|
+
return false;
|
|
2025
|
+
}
|
|
2026
|
+
if (IsSchema(dependency) && !check(context, dependency, value, root)) {
|
|
2027
|
+
return false;
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
return true;
|
|
2032
|
+
}
|
|
2033
|
+
|
|
2034
|
+
// src/schema/core.ts
|
|
2035
|
+
function resolveReferencedSchema(context, schema, root) {
|
|
2036
|
+
const schemaRecord = schema;
|
|
2037
|
+
const refKeys = ["$ref", "$recursiveRef", "$dynamicRef"];
|
|
2038
|
+
for (const key of refKeys) {
|
|
2039
|
+
const value = schemaRecord[key];
|
|
2040
|
+
const ref = typeof value === "string" ? value : undefined;
|
|
2041
|
+
if (ref !== undefined) {
|
|
2042
|
+
return context[ref] ?? Ref(root, ref);
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
return;
|
|
2046
|
+
}
|
|
2047
|
+
function checkCoreKeywords(context, schema, value, root) {
|
|
2048
|
+
if ("const" in schema && !Object.is(schema["const"], value)) {
|
|
2049
|
+
return false;
|
|
2050
|
+
}
|
|
2051
|
+
const enumValues = Array.isArray(schema["enum"]) ? schema["enum"] : undefined;
|
|
2052
|
+
if (enumValues !== undefined && !enumValues.some((entry) => Object.is(entry, value))) {
|
|
2053
|
+
return false;
|
|
2054
|
+
}
|
|
2055
|
+
if ("type" in schema && !MatchesType(schema["type"], value)) {
|
|
2056
|
+
return false;
|
|
2057
|
+
}
|
|
2058
|
+
if (!CheckStringKeywords(schema, value) || !CheckNumberKeywords(schema, value)) {
|
|
2059
|
+
return false;
|
|
2060
|
+
}
|
|
2061
|
+
if (!CheckArrayKeywords(CheckSchemaValue, context, schema, value, root) || !CheckObjectKeywords(CheckSchemaValue, context, schema, value, root)) {
|
|
2062
|
+
return false;
|
|
2063
|
+
}
|
|
2064
|
+
return CheckDependentKeywords(CheckSchemaValue, context, schema, value, root);
|
|
2065
|
+
}
|
|
2066
|
+
function checkCompositionKeywords(context, schema, value, root) {
|
|
2067
|
+
const allOf = Array.isArray(schema["allOf"]) ? schema["allOf"] : undefined;
|
|
2068
|
+
if (allOf !== undefined && !allOf.every((entry) => IsSchema(entry) && CheckSchemaValue(context, entry, value, root))) {
|
|
2069
|
+
return false;
|
|
2070
|
+
}
|
|
2071
|
+
const anyOf = Array.isArray(schema["anyOf"]) ? schema["anyOf"] : undefined;
|
|
2072
|
+
if (anyOf !== undefined && !anyOf.some((entry) => IsSchema(entry) && CheckSchemaValue(context, entry, value, root))) {
|
|
2073
|
+
return false;
|
|
2074
|
+
}
|
|
2075
|
+
const oneOf = Array.isArray(schema["oneOf"]) ? schema["oneOf"] : undefined;
|
|
2076
|
+
if (oneOf !== undefined) {
|
|
2077
|
+
const matches = oneOf.filter((entry) => IsSchema(entry) && CheckSchemaValue(context, entry, value, root));
|
|
2078
|
+
if (matches.length !== 1) {
|
|
2079
|
+
return false;
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
return true;
|
|
2083
|
+
}
|
|
2084
|
+
function checkConditionalKeywords(context, schema, value, root) {
|
|
2085
|
+
const notSchema = IsSchema(schema["not"]) ? schema["not"] : undefined;
|
|
2086
|
+
if (notSchema !== undefined && CheckSchemaValue(context, notSchema, value, root)) {
|
|
2087
|
+
return false;
|
|
2088
|
+
}
|
|
2089
|
+
const ifSchema = IsSchema(schema["if"]) ? schema["if"] : undefined;
|
|
2090
|
+
if (ifSchema !== undefined) {
|
|
2091
|
+
const matched = CheckSchemaValue(context, ifSchema, value, root);
|
|
2092
|
+
const thenSchema = IsSchema(schema["then"]) ? schema["then"] : undefined;
|
|
2093
|
+
const elseSchema = IsSchema(schema["else"]) ? schema["else"] : undefined;
|
|
2094
|
+
if (matched && thenSchema !== undefined) {
|
|
2095
|
+
return CheckSchemaValue(context, thenSchema, value, root);
|
|
2096
|
+
}
|
|
2097
|
+
if (!matched && elseSchema !== undefined) {
|
|
2098
|
+
return CheckSchemaValue(context, elseSchema, value, root);
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
return true;
|
|
2102
|
+
}
|
|
2103
|
+
function checkExtensionKeywords(context, schema, value, root) {
|
|
2104
|
+
const guard = IsObject(schema["~guard"]) ? schema["~guard"] : undefined;
|
|
2105
|
+
if (guard !== undefined && typeof guard["check"] === "function" && !guard["check"](value)) {
|
|
2106
|
+
return false;
|
|
2107
|
+
}
|
|
2108
|
+
const refine = Array.isArray(schema["~refine"]) ? schema["~refine"] : undefined;
|
|
2109
|
+
if (refine !== undefined && !refine.every((entry) => IsObject(entry) && typeof entry["refine"] === "function" && entry["refine"](value))) {
|
|
2110
|
+
return false;
|
|
2111
|
+
}
|
|
2112
|
+
return true;
|
|
2113
|
+
}
|
|
2114
|
+
function CheckSchemaValue(context, schema, value, root = schema) {
|
|
2115
|
+
if (typeof schema === "boolean") {
|
|
2116
|
+
return schema;
|
|
2117
|
+
}
|
|
2118
|
+
const resolved = resolveReferencedSchema(context, schema, root);
|
|
2119
|
+
if (resolved !== undefined) {
|
|
2120
|
+
return CheckSchemaValue(context, resolved, value, root);
|
|
2121
|
+
}
|
|
2122
|
+
return checkCoreKeywords(context, schema, value, root) && checkCompositionKeywords(context, schema, value, root) && checkConditionalKeywords(context, schema, value, root) && checkExtensionKeywords(context, schema, value, root);
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
// src/schema/engine.ts
|
|
2126
|
+
var externalState = {
|
|
2127
|
+
identifier: "external_0",
|
|
2128
|
+
variables: []
|
|
2129
|
+
};
|
|
2130
|
+
var resetCount = 1;
|
|
2131
|
+
var functions = new Map;
|
|
2132
|
+
function scanUnevaluated(value) {
|
|
2133
|
+
if (IsArray(value)) {
|
|
2134
|
+
return value.some((entry) => scanUnevaluated(entry));
|
|
2135
|
+
}
|
|
2136
|
+
if (IsObject(value)) {
|
|
2137
|
+
return Keys(value).some((key) => key === "unevaluatedItems" || key === "unevaluatedProperties" || scanUnevaluated(value[key]));
|
|
2138
|
+
}
|
|
2139
|
+
return false;
|
|
2140
|
+
}
|
|
2141
|
+
function HasUnevaluated(context, schema) {
|
|
2142
|
+
return scanUnevaluated(schema) || Object.keys(context).some((key) => scanUnevaluated(context[key]));
|
|
2143
|
+
}
|
|
2144
|
+
|
|
2145
|
+
class BuildContext {
|
|
2146
|
+
hasUnevaluated;
|
|
2147
|
+
constructor(hasUnevaluated) {
|
|
2148
|
+
this.hasUnevaluated = hasUnevaluated;
|
|
2149
|
+
}
|
|
2150
|
+
UseUnevaluated() {
|
|
2151
|
+
return this.hasUnevaluated;
|
|
2152
|
+
}
|
|
2153
|
+
AddIndex(index) {
|
|
2154
|
+
return `context.AddIndex(${index})`;
|
|
2155
|
+
}
|
|
2156
|
+
AddKey(key) {
|
|
2157
|
+
return `context.AddKey(${JSON.stringify(key)})`;
|
|
2158
|
+
}
|
|
2159
|
+
Merge(results) {
|
|
2160
|
+
return `context.Merge(${results})`;
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2163
|
+
|
|
2164
|
+
class CheckContext {
|
|
2165
|
+
indices = new Set;
|
|
2166
|
+
keys = new Set;
|
|
2167
|
+
AddIndex(index) {
|
|
2168
|
+
this.indices.add(index);
|
|
2169
|
+
return true;
|
|
2170
|
+
}
|
|
2171
|
+
AddKey(key) {
|
|
2172
|
+
this.keys.add(key);
|
|
2173
|
+
return true;
|
|
2174
|
+
}
|
|
2175
|
+
GetIndices() {
|
|
2176
|
+
return this.indices;
|
|
2177
|
+
}
|
|
2178
|
+
GetKeys() {
|
|
2179
|
+
return this.keys;
|
|
2180
|
+
}
|
|
2181
|
+
Merge(results) {
|
|
2182
|
+
results.forEach((result) => {
|
|
2183
|
+
result.indices.forEach((entry) => this.indices.add(entry));
|
|
2184
|
+
result.keys.forEach((entry) => this.keys.add(entry));
|
|
2185
|
+
});
|
|
2186
|
+
return true;
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
|
|
2190
|
+
class ErrorContext extends CheckContext {
|
|
2191
|
+
callback;
|
|
2192
|
+
constructor(callback) {
|
|
2193
|
+
super();
|
|
2194
|
+
this.callback = callback;
|
|
2195
|
+
}
|
|
2196
|
+
AddError(error) {
|
|
2197
|
+
this.callback(error);
|
|
2198
|
+
return false;
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2202
|
+
class AccumulatedErrorContext extends ErrorContext {
|
|
2203
|
+
errors = [];
|
|
2204
|
+
constructor() {
|
|
2205
|
+
super((error) => {
|
|
2206
|
+
this.errors.push(error);
|
|
2207
|
+
});
|
|
2208
|
+
}
|
|
2209
|
+
AddError(error) {
|
|
2210
|
+
this.errors.push(error);
|
|
2211
|
+
return false;
|
|
2212
|
+
}
|
|
2213
|
+
GetErrors() {
|
|
2214
|
+
return this.errors;
|
|
2215
|
+
}
|
|
2216
|
+
}
|
|
2217
|
+
function ResetExternal() {
|
|
2218
|
+
externalState.identifier = `external_${resetCount}`;
|
|
2219
|
+
externalState.variables = [];
|
|
2220
|
+
resetCount += 1;
|
|
2221
|
+
}
|
|
2222
|
+
function CreateVariable(value) {
|
|
2223
|
+
const call = `${externalState.identifier}[${externalState.variables.length}]`;
|
|
2224
|
+
externalState.variables.push(value);
|
|
2225
|
+
return call;
|
|
2226
|
+
}
|
|
2227
|
+
function GetExternal() {
|
|
2228
|
+
return externalState;
|
|
2229
|
+
}
|
|
2230
|
+
function ResetFunctions() {
|
|
2231
|
+
functions.clear();
|
|
2232
|
+
}
|
|
2233
|
+
function GetFunctions() {
|
|
2234
|
+
return Array.from(functions.values());
|
|
2235
|
+
}
|
|
2236
|
+
|
|
2237
|
+
class Stack {
|
|
2238
|
+
context;
|
|
2239
|
+
schema;
|
|
2240
|
+
ids = [];
|
|
2241
|
+
anchors = [];
|
|
2242
|
+
constructor(context, schema) {
|
|
2243
|
+
this.context = context;
|
|
2244
|
+
this.schema = schema;
|
|
2245
|
+
}
|
|
2246
|
+
BaseURL() {
|
|
2247
|
+
return this.ids.reduce((result, schema) => {
|
|
2248
|
+
const id = schema["$id"];
|
|
2249
|
+
return typeof id === "string" ? new URL(id, result.href) : result;
|
|
2250
|
+
}, new URL("http://unknown"));
|
|
2251
|
+
}
|
|
2252
|
+
Base() {
|
|
2253
|
+
return this.ids[this.ids.length - 1] ?? this.schema;
|
|
2254
|
+
}
|
|
2255
|
+
Push(schema) {
|
|
2256
|
+
if (!IsSchemaObject(schema)) {
|
|
2257
|
+
return;
|
|
2258
|
+
}
|
|
2259
|
+
if (HasString(schema, "$id")) {
|
|
2260
|
+
this.ids.push(schema);
|
|
2261
|
+
}
|
|
2262
|
+
if (HasString(schema, "$anchor")) {
|
|
2263
|
+
this.anchors.push(schema);
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
2266
|
+
Pop(schema) {
|
|
2267
|
+
if (!IsSchemaObject(schema)) {
|
|
2268
|
+
return;
|
|
2269
|
+
}
|
|
2270
|
+
if (HasString(schema, "$id")) {
|
|
2271
|
+
this.ids.pop();
|
|
2272
|
+
}
|
|
2273
|
+
if (HasString(schema, "$anchor")) {
|
|
2274
|
+
this.anchors.pop();
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
Ref(ref) {
|
|
2278
|
+
return this.context[ref] ?? Ref(this.Base(), ref);
|
|
2279
|
+
}
|
|
2280
|
+
RecursiveRef(ref) {
|
|
2281
|
+
return this.Ref(ref);
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2284
|
+
function CreateFunction(_stack, _context, schema, value) {
|
|
2285
|
+
const identifier = `check_${functions.size}`;
|
|
2286
|
+
if (!functions.has(identifier)) {
|
|
2287
|
+
functions.set(identifier, `const ${identifier} = (${value}) => ${JSON.stringify(schema)};`);
|
|
2288
|
+
}
|
|
2289
|
+
return `${identifier}(${value})`;
|
|
2290
|
+
}
|
|
2291
|
+
function Reducer(stack, context, schemas, value, check) {
|
|
2292
|
+
const results = schemas.map((schema) => {
|
|
2293
|
+
const next = new CheckContext;
|
|
2294
|
+
return CheckSchemaValue({}, schema, value, stack.Base()) ? next : undefined;
|
|
2295
|
+
}).filter((entry) => entry instanceof CheckContext);
|
|
2296
|
+
return check && context.Merge(results);
|
|
2297
|
+
}
|
|
2298
|
+
function BuildGuard(_stack, _context, _schema, value) {
|
|
2299
|
+
return `typeof ${value} !== 'undefined'`;
|
|
2300
|
+
}
|
|
2301
|
+
function CheckGuard(_stack, _context, schema, value) {
|
|
2302
|
+
if (!IsSchemaObject(schema) || !HasObject(schema, "~guard")) {
|
|
2303
|
+
return true;
|
|
2304
|
+
}
|
|
2305
|
+
const guard = schema["~guard"];
|
|
2306
|
+
if (!IsObject(guard)) {
|
|
2307
|
+
return true;
|
|
2308
|
+
}
|
|
2309
|
+
return typeof guard["check"] === "function" ? guard["check"](value) : true;
|
|
2310
|
+
}
|
|
2311
|
+
function ErrorGuard(stack, context, schemaPath, instancePath, schema, value) {
|
|
2312
|
+
if (CheckGuard(stack, context, schema, value)) {
|
|
2313
|
+
return true;
|
|
2314
|
+
}
|
|
2315
|
+
return context.AddError({ keyword: "~guard", schemaPath, instancePath, params: { value } });
|
|
2316
|
+
}
|
|
2317
|
+
function BuildRefine(_stack, _context, _schema, value) {
|
|
2318
|
+
return `typeof ${value} !== 'undefined'`;
|
|
2319
|
+
}
|
|
2320
|
+
function CheckRefine(_stack, _context, schema, value) {
|
|
2321
|
+
if (!IsSchemaObject(schema) || !Array.isArray(schema["~refine"])) {
|
|
2322
|
+
return true;
|
|
2323
|
+
}
|
|
2324
|
+
return schema["~refine"].every((entry) => IsObject(entry) && typeof entry["refine"] === "function" && entry["refine"](value));
|
|
2325
|
+
}
|
|
2326
|
+
function ErrorRefine(stack, context, schemaPath, instancePath, schema, value) {
|
|
2327
|
+
if (CheckRefine(stack, context, schema, value)) {
|
|
2328
|
+
return true;
|
|
2329
|
+
}
|
|
2330
|
+
return context.AddError({ keyword: "~refine", schemaPath, instancePath, params: { value } });
|
|
2331
|
+
}
|
|
2332
|
+
// src/schema/error-collector.ts
|
|
2333
|
+
function error(path, message, code) {
|
|
2334
|
+
return { path, message, code };
|
|
2335
|
+
}
|
|
2336
|
+
function collectReferenceErrors(context, schema, value, root, path) {
|
|
2337
|
+
const ref = typeof schema["$ref"] === "string" ? schema["$ref"] : undefined;
|
|
2338
|
+
if (ref !== undefined) {
|
|
2339
|
+
const resolved = context[ref] ?? Ref(root, ref);
|
|
2340
|
+
return resolved === undefined ? [error(path, `Unresolved reference ${ref}`, "UNRESOLVED_REF")] : CollectSchemaErrors(context, resolved, value, root, path);
|
|
2341
|
+
}
|
|
2342
|
+
return;
|
|
2343
|
+
}
|
|
2344
|
+
function collectPrimitiveErrors(schema, value, path) {
|
|
2345
|
+
const errors = [];
|
|
2346
|
+
if ("const" in schema && !Object.is(schema["const"], value)) {
|
|
2347
|
+
errors.push(error(path, "Value does not match const", "CONST"));
|
|
2348
|
+
}
|
|
2349
|
+
const enumValues = Array.isArray(schema["enum"]) ? schema["enum"] : undefined;
|
|
2350
|
+
if (enumValues !== undefined && !enumValues.some((entry) => Object.is(entry, value))) {
|
|
2351
|
+
errors.push(error(path, "Value does not match enum", "ENUM"));
|
|
2352
|
+
}
|
|
2353
|
+
if ("type" in schema) {
|
|
2354
|
+
errors.push(error(path, "Value does not match type", "TYPE"));
|
|
2355
|
+
}
|
|
2356
|
+
return errors;
|
|
2357
|
+
}
|
|
2358
|
+
function collectNestedErrors(context, schema, value, root, path) {
|
|
2359
|
+
const errors = [];
|
|
2360
|
+
if (Array.isArray(value)) {
|
|
2361
|
+
const items = IsSchema(schema["items"]) ? schema["items"] : undefined;
|
|
2362
|
+
if (items !== undefined) {
|
|
2363
|
+
value.forEach((entry, index) => {
|
|
2364
|
+
errors.push(...CollectSchemaErrors(context, items, entry, root, `${path}/${index}`));
|
|
2365
|
+
});
|
|
2366
|
+
}
|
|
2367
|
+
}
|
|
2368
|
+
if (IsPlainObject(value)) {
|
|
2369
|
+
const properties = IsObject(schema["properties"]) ? schema["properties"] : undefined;
|
|
2370
|
+
if (properties !== undefined) {
|
|
2371
|
+
for (const [key, propertySchema] of Entries(properties)) {
|
|
2372
|
+
if (IsSchema(propertySchema) && key in value) {
|
|
2373
|
+
errors.push(...CollectSchemaErrors(context, propertySchema, value[key], root, `${path}/${key}`));
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
return errors;
|
|
2379
|
+
}
|
|
2380
|
+
function collectCompositionErrors(schema, path) {
|
|
2381
|
+
const errors = [];
|
|
2382
|
+
if (Array.isArray(schema["allOf"])) {
|
|
2383
|
+
errors.push(error(path, "Value failed allOf", "ALL_OF"));
|
|
2384
|
+
}
|
|
2385
|
+
if (Array.isArray(schema["anyOf"])) {
|
|
2386
|
+
errors.push(error(path, "Value failed anyOf", "ANY_OF"));
|
|
2387
|
+
}
|
|
2388
|
+
if (Array.isArray(schema["oneOf"])) {
|
|
2389
|
+
errors.push(error(path, "Value failed oneOf", "ONE_OF"));
|
|
2390
|
+
}
|
|
2391
|
+
return errors;
|
|
2392
|
+
}
|
|
2393
|
+
function collectExtensionErrors(context, schema, value, root, path) {
|
|
2394
|
+
const errors = [];
|
|
2395
|
+
const notSchema = IsSchema(schema["not"]) ? schema["not"] : undefined;
|
|
2396
|
+
if (notSchema !== undefined && CheckSchemaValue(context, notSchema, value, root)) {
|
|
2397
|
+
errors.push(error(path, "Value matched a negated schema", "NOT"));
|
|
2398
|
+
}
|
|
2399
|
+
const guard = IsObject(schema["~guard"]) ? schema["~guard"] : undefined;
|
|
2400
|
+
if (guard !== undefined && typeof guard["check"] === "function" && !guard["check"](value)) {
|
|
2401
|
+
errors.push(error(path, "Guard validation failed", "GUARD"));
|
|
2402
|
+
}
|
|
2403
|
+
const refine = Array.isArray(schema["~refine"]) ? schema["~refine"] : undefined;
|
|
2404
|
+
if (refine !== undefined) {
|
|
2405
|
+
refine.forEach((entry, index) => {
|
|
2406
|
+
if (IsObject(entry) && typeof entry["refine"] === "function" && !entry["refine"](value)) {
|
|
2407
|
+
const message = typeof entry["message"] === "string" ? entry["message"] : `Refinement ${index} failed`;
|
|
2408
|
+
errors.push(error(path, message, "REFINE"));
|
|
2409
|
+
}
|
|
2410
|
+
});
|
|
2411
|
+
}
|
|
2412
|
+
return errors;
|
|
2413
|
+
}
|
|
2414
|
+
function CollectSchemaErrors(context, schema, value, root = schema, path = "/") {
|
|
2415
|
+
if (CheckSchemaValue(context, schema, value, root)) {
|
|
2416
|
+
return [];
|
|
2417
|
+
}
|
|
2418
|
+
if (typeof schema === "boolean") {
|
|
2419
|
+
return [error(path, "Boolean schema rejected the value", "BOOLEAN_SCHEMA")];
|
|
2420
|
+
}
|
|
2421
|
+
const referenceErrors = collectReferenceErrors(context, schema, value, root, path);
|
|
2422
|
+
if (referenceErrors !== undefined) {
|
|
2423
|
+
return referenceErrors;
|
|
2424
|
+
}
|
|
2425
|
+
const errors = [
|
|
2426
|
+
...collectPrimitiveErrors(schema, value, path),
|
|
2427
|
+
...collectNestedErrors(context, schema, value, root, path),
|
|
2428
|
+
...collectCompositionErrors(schema, path),
|
|
2429
|
+
...collectExtensionErrors(context, schema, value, root, path)
|
|
2430
|
+
];
|
|
2431
|
+
return errors.length > 0 ? errors : [error(path, "Schema validation failed", "SCHEMA")];
|
|
2432
|
+
}
|
|
2433
|
+
|
|
2434
|
+
// src/schema/runtime-keywords.ts
|
|
2435
|
+
function buildFromKeys(keys, defaults = {}) {
|
|
2436
|
+
return (_stack, _context, schema, _value) => JSON.stringify(ProjectSchema(schema, keys, defaults));
|
|
2437
|
+
}
|
|
2438
|
+
function checkFromKeys(keys, defaults = {}) {
|
|
2439
|
+
return (_stack, _context, schema, value) => CheckSchemaValue({}, ProjectSchema(schema, keys, defaults), value);
|
|
2440
|
+
}
|
|
2441
|
+
function errorFromKeys(keyword, check) {
|
|
2442
|
+
return (stack, context, schemaPath, instancePath, schema, value) => {
|
|
2443
|
+
if (check(stack, new CheckContext, schema, value)) {
|
|
2444
|
+
return true;
|
|
2445
|
+
}
|
|
2446
|
+
const projectedErrors = CollectSchemaErrors({}, schema, value);
|
|
2447
|
+
projectedErrors.forEach((error2) => {
|
|
2448
|
+
context.AddError({ keyword, schemaPath, instancePath, params: error2 });
|
|
2449
|
+
});
|
|
2450
|
+
return false;
|
|
2451
|
+
};
|
|
2452
|
+
}
|
|
2453
|
+
var CanAdditionalPropertiesFast = (schema) => typeof schema !== "boolean";
|
|
2454
|
+
var BuildBooleanSchema = buildFromKeys([]);
|
|
2455
|
+
var BuildConst = buildFromKeys(["const"]);
|
|
2456
|
+
var BuildEnum = buildFromKeys(["enum"]);
|
|
2457
|
+
var BuildType = buildFromKeys(["type"]);
|
|
2458
|
+
var BuildMinLength = buildFromKeys(["type", "minLength"], { type: "string" });
|
|
2459
|
+
var BuildMaxLength = buildFromKeys(["type", "maxLength"], { type: "string" });
|
|
2460
|
+
var BuildPattern = buildFromKeys(["type", "pattern"], { type: "string" });
|
|
2461
|
+
var BuildFormat = buildFromKeys(["type", "format"], { type: "string" });
|
|
2462
|
+
var BuildMinimum = buildFromKeys(["type", "minimum"], { type: "number" });
|
|
2463
|
+
var BuildMaximum = buildFromKeys(["type", "maximum"], { type: "number" });
|
|
2464
|
+
var BuildExclusiveMinimum = buildFromKeys(["type", "exclusiveMinimum"], { type: "number" });
|
|
2465
|
+
var BuildExclusiveMaximum = buildFromKeys(["type", "exclusiveMaximum"], { type: "number" });
|
|
2466
|
+
var BuildMultipleOf = buildFromKeys(["type", "multipleOf"], { type: "number" });
|
|
2467
|
+
var BuildMinItems = buildFromKeys(["type", "minItems"], { type: "array" });
|
|
2468
|
+
var BuildMaxItems = buildFromKeys(["type", "maxItems"], { type: "array" });
|
|
2469
|
+
var BuildUniqueItems = buildFromKeys(["type", "uniqueItems"], { type: "array" });
|
|
2470
|
+
var BuildItems = buildFromKeys(["type", "items", "prefixItems"], { type: "array" });
|
|
2471
|
+
var BuildPrefixItems = buildFromKeys(["type", "prefixItems"], { type: "array" });
|
|
2472
|
+
var BuildAdditionalItems = buildFromKeys(["type", "prefixItems", "items", "additionalItems"], { type: "array" });
|
|
2473
|
+
var BuildUnevaluatedItems = buildFromKeys(["type", "prefixItems", "items", "unevaluatedItems"], { type: "array" });
|
|
2474
|
+
var BuildContains = buildFromKeys(["type", "contains"], { type: "array" });
|
|
2475
|
+
var BuildMinContains = buildFromKeys(["type", "contains", "minContains"], { type: "array" });
|
|
2476
|
+
var BuildMaxContains = buildFromKeys(["type", "contains", "maxContains"], { type: "array" });
|
|
2477
|
+
var BuildMinProperties = buildFromKeys(["type", "minProperties"], { type: "object" });
|
|
2478
|
+
var BuildMaxProperties = buildFromKeys(["type", "maxProperties"], { type: "object" });
|
|
2479
|
+
var BuildRequired = buildFromKeys(["type", "properties", "required"], { type: "object" });
|
|
2480
|
+
var BuildProperties = buildFromKeys(["type", "properties", "required"], { type: "object" });
|
|
2481
|
+
var BuildPatternProperties = buildFromKeys(["type", "patternProperties"], { type: "object" });
|
|
2482
|
+
var BuildAdditionalProperties = buildFromKeys(["type", "properties", "patternProperties", "additionalProperties"], { type: "object" });
|
|
2483
|
+
var BuildAdditionalPropertiesFast = BuildAdditionalProperties;
|
|
2484
|
+
var BuildAdditionalPropertiesStandard = BuildAdditionalProperties;
|
|
2485
|
+
var BuildUnevaluatedProperties = buildFromKeys(["type", "properties", "patternProperties", "unevaluatedProperties"], { type: "object" });
|
|
2486
|
+
var BuildPropertyNames = buildFromKeys(["type", "propertyNames"], { type: "object" });
|
|
2487
|
+
var BuildDependencies = buildFromKeys(["type", "dependencies"], { type: "object" });
|
|
2488
|
+
var BuildDependentRequired = buildFromKeys(["type", "dependentRequired"], { type: "object" });
|
|
2489
|
+
var BuildDependentSchemas = buildFromKeys(["type", "dependentSchemas"], { type: "object" });
|
|
2490
|
+
var BuildAllOf = buildFromKeys(["allOf"]);
|
|
2491
|
+
var BuildAnyOf = buildFromKeys(["anyOf"]);
|
|
2492
|
+
var BuildOneOf = buildFromKeys(["oneOf"]);
|
|
2493
|
+
var BuildNot = buildFromKeys(["not"]);
|
|
2494
|
+
var BuildIf = buildFromKeys(["if", "then", "else"]);
|
|
2495
|
+
var BuildRef = buildFromKeys(["$ref"]);
|
|
2496
|
+
var BuildRecursiveRef = buildFromKeys(["$recursiveRef"]);
|
|
2497
|
+
var BuildSchema = (_stack, _context, schema, _value) => JSON.stringify(schema);
|
|
2498
|
+
var CheckBooleanSchema = (_stack, _context, schema, value) => CheckSchemaValue({}, schema, value);
|
|
2499
|
+
var CheckConst = checkFromKeys(["const"]);
|
|
2500
|
+
var CheckEnum = checkFromKeys(["enum"]);
|
|
2501
|
+
var CheckType = checkFromKeys(["type"]);
|
|
2502
|
+
var CheckMinLength = checkFromKeys(["type", "minLength"], { type: "string" });
|
|
2503
|
+
var CheckMaxLength = checkFromKeys(["type", "maxLength"], { type: "string" });
|
|
2504
|
+
var CheckPattern = checkFromKeys(["type", "pattern"], { type: "string" });
|
|
2505
|
+
var CheckFormat = checkFromKeys(["type", "format"], { type: "string" });
|
|
2506
|
+
var CheckMinimum = checkFromKeys(["type", "minimum"], { type: "number" });
|
|
2507
|
+
var CheckMaximum = checkFromKeys(["type", "maximum"], { type: "number" });
|
|
2508
|
+
var CheckExclusiveMinimum = checkFromKeys(["type", "exclusiveMinimum"], { type: "number" });
|
|
2509
|
+
var CheckExclusiveMaximum = checkFromKeys(["type", "exclusiveMaximum"], { type: "number" });
|
|
2510
|
+
var CheckMultipleOf = checkFromKeys(["type", "multipleOf"], { type: "number" });
|
|
2511
|
+
var CheckMinItems = checkFromKeys(["type", "minItems"], { type: "array" });
|
|
2512
|
+
var CheckMaxItems = checkFromKeys(["type", "maxItems"], { type: "array" });
|
|
2513
|
+
var CheckUniqueItems = checkFromKeys(["type", "uniqueItems"], { type: "array" });
|
|
2514
|
+
var CheckItems = checkFromKeys(["type", "items", "prefixItems"], { type: "array" });
|
|
2515
|
+
var CheckPrefixItems = checkFromKeys(["type", "prefixItems"], { type: "array" });
|
|
2516
|
+
var CheckAdditionalItems = checkFromKeys(["type", "prefixItems", "items", "additionalItems"], { type: "array" });
|
|
2517
|
+
var CheckUnevaluatedItems = checkFromKeys(["type", "prefixItems", "items", "unevaluatedItems"], { type: "array" });
|
|
2518
|
+
var CheckContains = checkFromKeys(["type", "contains"], { type: "array" });
|
|
2519
|
+
var CheckMinContains = checkFromKeys(["type", "contains", "minContains"], { type: "array" });
|
|
2520
|
+
var CheckMaxContains = checkFromKeys(["type", "contains", "maxContains"], { type: "array" });
|
|
2521
|
+
var CheckMinProperties = checkFromKeys(["type", "minProperties"], { type: "object" });
|
|
2522
|
+
var CheckMaxProperties = checkFromKeys(["type", "maxProperties"], { type: "object" });
|
|
2523
|
+
var CheckRequired = checkFromKeys(["type", "properties", "required"], { type: "object" });
|
|
2524
|
+
var CheckProperties = checkFromKeys(["type", "properties", "required"], { type: "object" });
|
|
2525
|
+
var CheckPatternProperties = checkFromKeys(["type", "patternProperties"], { type: "object" });
|
|
2526
|
+
var CheckAdditionalProperties = checkFromKeys(["type", "properties", "patternProperties", "additionalProperties"], { type: "object" });
|
|
2527
|
+
var CheckUnevaluatedProperties = checkFromKeys(["type", "properties", "patternProperties", "unevaluatedProperties"], { type: "object" });
|
|
2528
|
+
var CheckPropertyNames = checkFromKeys(["type", "propertyNames"], { type: "object" });
|
|
2529
|
+
var CheckDependencies = checkFromKeys(["type", "dependencies"], { type: "object" });
|
|
2530
|
+
var CheckDependentRequired = checkFromKeys(["type", "dependentRequired"], { type: "object" });
|
|
2531
|
+
var CheckDependentSchemas = checkFromKeys(["type", "dependentSchemas"], { type: "object" });
|
|
2532
|
+
var CheckAllOf = checkFromKeys(["allOf"]);
|
|
2533
|
+
var CheckAnyOf = checkFromKeys(["anyOf"]);
|
|
2534
|
+
var CheckOneOf = checkFromKeys(["oneOf"]);
|
|
2535
|
+
var CheckNot = checkFromKeys(["not"]);
|
|
2536
|
+
var CheckIf = checkFromKeys(["if", "then", "else"]);
|
|
2537
|
+
var CheckRef = (_stack, _context, schema, value) => CheckSchemaValue({}, schema, value);
|
|
2538
|
+
var CheckRecursiveRef = CheckRef;
|
|
2539
|
+
var CheckSchema = (_stack, _context, schema, value) => CheckSchemaValue({}, schema, value);
|
|
2540
|
+
var ErrorBooleanSchema = errorFromKeys("type", CheckBooleanSchema);
|
|
2541
|
+
var ErrorConst = errorFromKeys("const", CheckConst);
|
|
2542
|
+
var ErrorEnum = errorFromKeys("enum", CheckEnum);
|
|
2543
|
+
var ErrorType = errorFromKeys("type", CheckType);
|
|
2544
|
+
var ErrorMinLength = errorFromKeys("minLength", CheckMinLength);
|
|
2545
|
+
var ErrorMaxLength = errorFromKeys("maxLength", CheckMaxLength);
|
|
2546
|
+
var ErrorPattern = errorFromKeys("pattern", CheckPattern);
|
|
2547
|
+
var ErrorFormat = errorFromKeys("format", CheckFormat);
|
|
2548
|
+
var ErrorMinimum = errorFromKeys("minimum", CheckMinimum);
|
|
2549
|
+
var ErrorMaximum = errorFromKeys("maximum", CheckMaximum);
|
|
2550
|
+
var ErrorExclusiveMinimum = errorFromKeys("exclusiveMinimum", CheckExclusiveMinimum);
|
|
2551
|
+
var ErrorExclusiveMaximum = errorFromKeys("exclusiveMaximum", CheckExclusiveMaximum);
|
|
2552
|
+
var ErrorMultipleOf = errorFromKeys("multipleOf", CheckMultipleOf);
|
|
2553
|
+
var ErrorMinItems = errorFromKeys("minItems", CheckMinItems);
|
|
2554
|
+
var ErrorMaxItems = errorFromKeys("maxItems", CheckMaxItems);
|
|
2555
|
+
var ErrorUniqueItems = errorFromKeys("uniqueItems", CheckUniqueItems);
|
|
2556
|
+
var ErrorItems = errorFromKeys("items", CheckItems);
|
|
2557
|
+
var ErrorPrefixItems = errorFromKeys("prefixItems", CheckPrefixItems);
|
|
2558
|
+
var ErrorAdditionalItems = errorFromKeys("additionalItems", CheckAdditionalItems);
|
|
2559
|
+
var ErrorUnevaluatedItems = errorFromKeys("unevaluatedItems", CheckUnevaluatedItems);
|
|
2560
|
+
var ErrorContains = errorFromKeys("contains", CheckContains);
|
|
2561
|
+
var ErrorMinContains = errorFromKeys("minContains", CheckMinContains);
|
|
2562
|
+
var ErrorMaxContains = errorFromKeys("maxContains", CheckMaxContains);
|
|
2563
|
+
var ErrorMinProperties = errorFromKeys("minProperties", CheckMinProperties);
|
|
2564
|
+
var ErrorMaxProperties = errorFromKeys("maxProperties", CheckMaxProperties);
|
|
2565
|
+
var ErrorRequired = errorFromKeys("required", CheckRequired);
|
|
2566
|
+
var ErrorProperties = errorFromKeys("properties", CheckProperties);
|
|
2567
|
+
var ErrorPatternProperties = errorFromKeys("patternProperties", CheckPatternProperties);
|
|
2568
|
+
var ErrorAdditionalProperties = errorFromKeys("additionalProperties", CheckAdditionalProperties);
|
|
2569
|
+
var ErrorUnevaluatedProperties = errorFromKeys("unevaluatedProperties", CheckUnevaluatedProperties);
|
|
2570
|
+
var ErrorPropertyNames = errorFromKeys("propertyNames", CheckPropertyNames);
|
|
2571
|
+
var ErrorDependencies = errorFromKeys("dependencies", CheckDependencies);
|
|
2572
|
+
var ErrorDependentRequired = errorFromKeys("dependentRequired", CheckDependentRequired);
|
|
2573
|
+
var ErrorDependentSchemas = errorFromKeys("dependentSchemas", CheckDependentSchemas);
|
|
2574
|
+
var ErrorAllOf = errorFromKeys("allOf", CheckAllOf);
|
|
2575
|
+
var ErrorAnyOf = errorFromKeys("anyOf", CheckAnyOf);
|
|
2576
|
+
var ErrorOneOf = errorFromKeys("oneOf", CheckOneOf);
|
|
2577
|
+
var ErrorNot = errorFromKeys("not", CheckNot);
|
|
2578
|
+
var ErrorIf = errorFromKeys("if", CheckIf);
|
|
2579
|
+
var ErrorRef = errorFromKeys("$ref", CheckRef);
|
|
2580
|
+
var ErrorRecursiveRef = errorFromKeys("$recursiveRef", CheckRecursiveRef);
|
|
2581
|
+
var ErrorSchema = errorFromKeys("schema", CheckSchema);
|
|
2582
|
+
// src/schema/check.ts
|
|
2583
|
+
function Check(...args) {
|
|
2584
|
+
const [context, schema, value] = NormalizeArgs(args);
|
|
2585
|
+
return CheckSchemaValue(context, schema, value);
|
|
2586
|
+
}
|
|
2587
|
+
|
|
2588
|
+
// src/schema/build.ts
|
|
2589
|
+
class BuildResult {
|
|
2590
|
+
context;
|
|
2591
|
+
schema;
|
|
2592
|
+
external;
|
|
2593
|
+
functions;
|
|
2594
|
+
call;
|
|
2595
|
+
useUnevaluated;
|
|
2596
|
+
constructor(context, schema, external, functions2, call, useUnevaluated) {
|
|
2597
|
+
this.context = context;
|
|
2598
|
+
this.schema = schema;
|
|
2599
|
+
this.external = external;
|
|
2600
|
+
this.functions = functions2;
|
|
2601
|
+
this.call = call;
|
|
2602
|
+
this.useUnevaluated = useUnevaluated;
|
|
2603
|
+
}
|
|
2604
|
+
Context() {
|
|
2605
|
+
return this.context;
|
|
2606
|
+
}
|
|
2607
|
+
Schema() {
|
|
2608
|
+
return this.schema;
|
|
2609
|
+
}
|
|
2610
|
+
UseUnevaluated() {
|
|
2611
|
+
return this.useUnevaluated;
|
|
2612
|
+
}
|
|
2613
|
+
External() {
|
|
2614
|
+
return this.external;
|
|
2615
|
+
}
|
|
2616
|
+
Functions() {
|
|
2617
|
+
return this.functions;
|
|
2618
|
+
}
|
|
2619
|
+
Call() {
|
|
2620
|
+
return this.call;
|
|
2621
|
+
}
|
|
2622
|
+
Evaluate() {
|
|
2623
|
+
return {
|
|
2624
|
+
IsAccelerated: true,
|
|
2625
|
+
Code: this.functions.join(`
|
|
2626
|
+
`),
|
|
2627
|
+
Check: (value) => Check(this.context, this.schema, value)
|
|
2628
|
+
};
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
2631
|
+
function Build(...args) {
|
|
2632
|
+
const context = args.length === 1 ? {} : args[0];
|
|
2633
|
+
const schema = args.length === 1 ? args[0] : args[1];
|
|
2634
|
+
ResetExternal();
|
|
2635
|
+
ResetFunctions();
|
|
2636
|
+
const useUnevaluated = HasUnevaluated(context, schema);
|
|
2637
|
+
const stack = new Stack(context, schema);
|
|
2638
|
+
const buildContext = new BuildContext(useUnevaluated);
|
|
2639
|
+
const call = CreateFunction(stack, buildContext, schema, "value");
|
|
2640
|
+
return new BuildResult(context, schema, GetExternal(), GetFunctions(), call, useUnevaluated);
|
|
2641
|
+
}
|
|
2642
|
+
// src/schema/errors.ts
|
|
2643
|
+
function Errors(...args) {
|
|
2644
|
+
const [context, schema, value] = NormalizeArgs(args);
|
|
2645
|
+
const errors = CollectSchemaErrors(context, schema, value);
|
|
2646
|
+
return [errors.length === 0, errors];
|
|
2647
|
+
}
|
|
2648
|
+
|
|
2649
|
+
// src/schema/parse.ts
|
|
2650
|
+
class ParseError extends Error {
|
|
2651
|
+
schema;
|
|
2652
|
+
value;
|
|
2653
|
+
errors;
|
|
2654
|
+
constructor(schema, value, errors) {
|
|
2655
|
+
super(`Parse failed with ${errors.length} error(s)`);
|
|
2656
|
+
this.schema = schema;
|
|
2657
|
+
this.value = value;
|
|
2658
|
+
this.errors = errors;
|
|
2659
|
+
this.name = "ParseError";
|
|
2660
|
+
}
|
|
2661
|
+
}
|
|
2662
|
+
function TryParse(...args) {
|
|
2663
|
+
const [context, schema, value] = NormalizeArgs(args);
|
|
2664
|
+
const [result, errors] = Errors(context, schema, value);
|
|
2665
|
+
if (result) {
|
|
2666
|
+
return {
|
|
2667
|
+
success: true,
|
|
2668
|
+
value
|
|
2669
|
+
};
|
|
2670
|
+
}
|
|
2671
|
+
return {
|
|
2672
|
+
success: false,
|
|
2673
|
+
errors
|
|
2674
|
+
};
|
|
2675
|
+
}
|
|
2676
|
+
function Parse(...args) {
|
|
2677
|
+
const [context, schema, value] = NormalizeArgs(args);
|
|
2678
|
+
const result = TryParse(context, schema, value);
|
|
2679
|
+
if (!result.success) {
|
|
2680
|
+
throw new ParseError(schema, value, result.errors);
|
|
2681
|
+
}
|
|
2682
|
+
return result.value;
|
|
2683
|
+
}
|
|
2684
|
+
|
|
2685
|
+
// src/schema/compile.ts
|
|
2686
|
+
class Validator {
|
|
2687
|
+
build;
|
|
2688
|
+
result;
|
|
2689
|
+
constructor(context, schema) {
|
|
2690
|
+
this.build = Build(context, schema);
|
|
2691
|
+
this.result = this.build.Evaluate();
|
|
2692
|
+
}
|
|
2693
|
+
IsAccelerated() {
|
|
2694
|
+
return this.result.IsAccelerated;
|
|
2695
|
+
}
|
|
2696
|
+
Schema() {
|
|
2697
|
+
return this.build.Schema();
|
|
2698
|
+
}
|
|
2699
|
+
Check(value) {
|
|
2700
|
+
return this.result.Check(value);
|
|
2701
|
+
}
|
|
2702
|
+
Parse(value) {
|
|
2703
|
+
return Parse(this.build.Context(), this.build.Schema(), value);
|
|
2704
|
+
}
|
|
2705
|
+
TryParse(value) {
|
|
2706
|
+
return TryParse(this.build.Context(), this.build.Schema(), value);
|
|
2707
|
+
}
|
|
2708
|
+
Errors(value) {
|
|
2709
|
+
return Errors(this.build.Context(), this.build.Schema(), value);
|
|
2710
|
+
}
|
|
2711
|
+
}
|
|
2712
|
+
function Compile(...args) {
|
|
2713
|
+
const context = args.length === 1 ? {} : args[0];
|
|
2714
|
+
const schema = args.length === 1 ? args[0] : args[1];
|
|
2715
|
+
return new Validator(context, schema);
|
|
2716
|
+
}
|
|
2717
|
+
// src/shared/schema-access.ts
|
|
2718
|
+
function isRecord(value) {
|
|
2719
|
+
return typeof value === "object" && value !== null;
|
|
2720
|
+
}
|
|
2721
|
+
function isSchemaValue(value) {
|
|
2722
|
+
return isRecord(value) && typeof value["~kind"] === "string";
|
|
2723
|
+
}
|
|
2724
|
+
function schemaNode(schema) {
|
|
2725
|
+
return schema;
|
|
2726
|
+
}
|
|
2727
|
+
function schemaKind(schema) {
|
|
2728
|
+
const kind = schemaNode(schema)["~kind"];
|
|
2729
|
+
return typeof kind === "string" ? kind : undefined;
|
|
2730
|
+
}
|
|
2731
|
+
function schemaUnknownField(schema, field) {
|
|
2732
|
+
return schemaNode(schema)[field];
|
|
2733
|
+
}
|
|
2734
|
+
function schemaStringField(schema, field) {
|
|
2735
|
+
const value = schemaUnknownField(schema, field);
|
|
2736
|
+
return typeof value === "string" ? value : undefined;
|
|
2737
|
+
}
|
|
2738
|
+
function schemaNumberField(schema, field) {
|
|
2739
|
+
const value = schemaUnknownField(schema, field);
|
|
2740
|
+
return typeof value === "number" ? value : undefined;
|
|
2741
|
+
}
|
|
2742
|
+
function schemaBigIntField(schema, field) {
|
|
2743
|
+
const value = schemaUnknownField(schema, field);
|
|
2744
|
+
return typeof value === "bigint" ? value : undefined;
|
|
2745
|
+
}
|
|
2746
|
+
function schemaBooleanField(schema, field) {
|
|
2747
|
+
const value = schemaUnknownField(schema, field);
|
|
2748
|
+
return typeof value === "boolean" ? value : undefined;
|
|
2749
|
+
}
|
|
2750
|
+
function schemaStringListField(schema, field) {
|
|
2751
|
+
const value = schemaUnknownField(schema, field);
|
|
2752
|
+
return Array.isArray(value) && value.every((entry) => typeof entry === "string") ? value : [];
|
|
2753
|
+
}
|
|
2754
|
+
function schemaSchemaField(schema, field) {
|
|
2755
|
+
const value = schemaUnknownField(schema, field);
|
|
2756
|
+
return isSchemaValue(value) ? value : undefined;
|
|
2757
|
+
}
|
|
2758
|
+
function schemaSchemaListField(schema, field) {
|
|
2759
|
+
const value = schemaUnknownField(schema, field);
|
|
2760
|
+
return Array.isArray(value) && value.every(isSchemaValue) ? value : [];
|
|
2761
|
+
}
|
|
2762
|
+
function schemaSchemaMapField(schema, field) {
|
|
2763
|
+
const value = schemaUnknownField(schema, field);
|
|
2764
|
+
if (!isRecord(value)) {
|
|
2765
|
+
return {};
|
|
2766
|
+
}
|
|
2767
|
+
return Object.values(value).every(isSchemaValue) ? value : {};
|
|
2768
|
+
}
|
|
2769
|
+
function schemaBooleanOrSchemaField(schema, field) {
|
|
2770
|
+
const value = schemaUnknownField(schema, field);
|
|
2771
|
+
if (typeof value === "boolean" || value === undefined) {
|
|
2772
|
+
return value;
|
|
2773
|
+
}
|
|
2774
|
+
return isSchemaValue(value) ? value : undefined;
|
|
2775
|
+
}
|
|
2776
|
+
function schemaCallbackField(schema, field) {
|
|
2777
|
+
const value = schemaUnknownField(schema, field);
|
|
2778
|
+
return typeof value === "function" ? value : undefined;
|
|
2779
|
+
}
|
|
2780
|
+
function schemaItem(schema) {
|
|
2781
|
+
return schemaSchemaField(schema, "item");
|
|
2782
|
+
}
|
|
2783
|
+
function schemaInner(schema) {
|
|
2784
|
+
return schemaSchemaField(schema, "inner");
|
|
2785
|
+
}
|
|
2786
|
+
function schemaItemOrInner(schema) {
|
|
2787
|
+
return schemaItem(schema) ?? schemaInner(schema);
|
|
2788
|
+
}
|
|
2789
|
+
function schemaVariants(schema) {
|
|
2790
|
+
return schemaSchemaListField(schema, "variants");
|
|
2791
|
+
}
|
|
2792
|
+
function schemaProperties(schema) {
|
|
2793
|
+
return schemaSchemaMapField(schema, "properties");
|
|
2794
|
+
}
|
|
2795
|
+
function schemaDefinitions(schema) {
|
|
2796
|
+
return schemaSchemaMapField(schema, "$defs");
|
|
2797
|
+
}
|
|
2798
|
+
function schemaPatternProperties(schema) {
|
|
2799
|
+
return schemaSchemaMapField(schema, "patternProperties");
|
|
2800
|
+
}
|
|
2801
|
+
function schemaRequiredKeys(schema) {
|
|
2802
|
+
return schemaStringListField(schema, "required");
|
|
2803
|
+
}
|
|
2804
|
+
function schemaOptionalKeys(schema) {
|
|
2805
|
+
return schemaStringListField(schema, "optional");
|
|
2806
|
+
}
|
|
2807
|
+
function schemaConst(schema) {
|
|
2808
|
+
return schemaUnknownField(schema, "const");
|
|
2809
|
+
}
|
|
2810
|
+
function schemaPatterns(schema) {
|
|
2811
|
+
return schemaStringListField(schema, "patterns");
|
|
2812
|
+
}
|
|
2813
|
+
function schemaRefinements(schema) {
|
|
2814
|
+
const value = schemaUnknownField(schema, "~refine");
|
|
2815
|
+
return Array.isArray(value) ? value.filter((entry) => isRecord(entry) && typeof entry.refine === "function" && (entry.message === undefined || typeof entry.message === "string")) : [];
|
|
2816
|
+
}
|
|
2817
|
+
function schemaPath(path) {
|
|
2818
|
+
return path.join(".") || "/";
|
|
2819
|
+
}
|
|
2820
|
+
|
|
2821
|
+
// src/schema/emitter-base.ts
|
|
2822
|
+
function stringSchema(schema) {
|
|
2823
|
+
const result = { type: "string" };
|
|
2824
|
+
if (schema.minLength !== undefined)
|
|
2825
|
+
result["minLength"] = schema.minLength;
|
|
2826
|
+
if (schema.maxLength !== undefined)
|
|
2827
|
+
result["maxLength"] = schema.maxLength;
|
|
2828
|
+
if (schema.pattern !== undefined)
|
|
2829
|
+
result["pattern"] = schema.pattern;
|
|
2830
|
+
if (schema.format !== undefined && KNOWN_FORMATS.has(schema.format))
|
|
2831
|
+
result["format"] = schema.format;
|
|
2832
|
+
return result;
|
|
2833
|
+
}
|
|
2834
|
+
function objectLikeSchema(object, refs, options, emit) {
|
|
2835
|
+
const properties = {};
|
|
2836
|
+
const required = [];
|
|
2837
|
+
const propertySchemas = schemaProperties(object);
|
|
2838
|
+
for (const [key, propSchema] of Object.entries(propertySchemas)) {
|
|
2839
|
+
properties[key] = emit(propSchema, refs, options);
|
|
2840
|
+
}
|
|
2841
|
+
const optional = new Set(schemaOptionalKeys(object).map(String));
|
|
2842
|
+
for (const key of schemaRequiredKeys(object)) {
|
|
2843
|
+
if (key in propertySchemas && !optional.has(String(key))) {
|
|
2844
|
+
required.push(String(key));
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2847
|
+
const patternProperties = schemaPatternProperties(object);
|
|
2848
|
+
const additionalProperties = schemaBooleanOrSchemaField(object, "additionalProperties");
|
|
2849
|
+
return {
|
|
2850
|
+
type: "object",
|
|
2851
|
+
properties,
|
|
2852
|
+
...required.length > 0 ? { required } : {},
|
|
2853
|
+
...schemaUnknownField(object, "optional") !== undefined ? { $comment: "Optional keys are represented by omission from required in emitted JSON Schema." } : {},
|
|
2854
|
+
...Object.keys(patternProperties).length > 0 ? {
|
|
2855
|
+
patternProperties: Object.fromEntries(Object.entries(patternProperties).map(([pattern, patternSchema]) => [pattern, emit(patternSchema, refs, options)]))
|
|
2856
|
+
} : {},
|
|
2857
|
+
...additionalProperties === false ? { additionalProperties: false } : additionalProperties === true ? { additionalProperties: true } : additionalProperties !== undefined ? { additionalProperties: emit(additionalProperties, refs, options) } : {}
|
|
2858
|
+
};
|
|
2859
|
+
}
|
|
2860
|
+
function numberSchema(schema) {
|
|
2861
|
+
const result = { type: "number" };
|
|
2862
|
+
if (schema.minimum !== undefined)
|
|
2863
|
+
result["minimum"] = schema.minimum;
|
|
2864
|
+
if (schema.maximum !== undefined)
|
|
2865
|
+
result["maximum"] = schema.maximum;
|
|
2866
|
+
if (schema.exclusiveMinimum !== undefined)
|
|
2867
|
+
result["exclusiveMinimum"] = schema.exclusiveMinimum;
|
|
2868
|
+
if (schema.exclusiveMaximum !== undefined)
|
|
2869
|
+
result["exclusiveMaximum"] = schema.exclusiveMaximum;
|
|
2870
|
+
if (schema.multipleOf !== undefined)
|
|
2871
|
+
result["multipleOf"] = schema.multipleOf;
|
|
2872
|
+
return result;
|
|
2873
|
+
}
|
|
2874
|
+
function integerSchema(schema) {
|
|
2875
|
+
const result = { type: "integer" };
|
|
2876
|
+
if (schema.minimum !== undefined)
|
|
2877
|
+
result["minimum"] = schema.minimum;
|
|
2878
|
+
if (schema.maximum !== undefined)
|
|
2879
|
+
result["maximum"] = schema.maximum;
|
|
2880
|
+
if (schema.exclusiveMinimum !== undefined)
|
|
2881
|
+
result["exclusiveMinimum"] = schema.exclusiveMinimum;
|
|
2882
|
+
if (schema.exclusiveMaximum !== undefined)
|
|
2883
|
+
result["exclusiveMaximum"] = schema.exclusiveMaximum;
|
|
2884
|
+
if (schema.multipleOf !== undefined)
|
|
2885
|
+
result["multipleOf"] = schema.multipleOf;
|
|
2886
|
+
return result;
|
|
2887
|
+
}
|
|
2888
|
+
|
|
2889
|
+
// src/schema/emitter-derived.ts
|
|
2890
|
+
function emitDerivedSchema(kind, schema, refs, options, opt, emit) {
|
|
2891
|
+
switch (kind) {
|
|
2892
|
+
case "Exclude": {
|
|
2893
|
+
const excluded = schema;
|
|
2894
|
+
return opt({ allOf: [emit(excluded.left, refs, options), { not: emit(excluded.right, refs, options) }] });
|
|
2895
|
+
}
|
|
2896
|
+
case "Extract": {
|
|
2897
|
+
const extracted = schema;
|
|
2898
|
+
return opt({ allOf: [emit(extracted.left, refs, options), emit(extracted.right, refs, options)] });
|
|
2899
|
+
}
|
|
2900
|
+
case "Partial": {
|
|
2901
|
+
const partial = schema;
|
|
2902
|
+
const derived = deriveObjectSchema(partial.object, { requiredMode: "none" });
|
|
2903
|
+
return opt(objectLikeSchema(derived, refs, options, emit));
|
|
2904
|
+
}
|
|
2905
|
+
case "Required": {
|
|
2906
|
+
const required = schema;
|
|
2907
|
+
const derived = deriveObjectSchema(required.object, { requiredMode: "all" });
|
|
2908
|
+
return opt(objectLikeSchema(derived, refs, options, emit));
|
|
2909
|
+
}
|
|
2910
|
+
case "Pick": {
|
|
2911
|
+
const picked = schema;
|
|
2912
|
+
const derived = deriveObjectSchema(picked.object, { pickKeys: picked.keys.map(String), additionalProperties: false });
|
|
2913
|
+
return opt(objectLikeSchema(derived, refs, options, emit));
|
|
2914
|
+
}
|
|
2915
|
+
case "Omit": {
|
|
2916
|
+
const omitted = schema;
|
|
2917
|
+
const derived = deriveObjectSchema(omitted.object, { omitKeys: omitted.keys.map(String), additionalProperties: false });
|
|
2918
|
+
return opt(objectLikeSchema(derived, refs, options, emit));
|
|
2919
|
+
}
|
|
2920
|
+
case "KeyOf":
|
|
2921
|
+
return opt({ type: "string", enum: Object.keys(schema.object.properties) });
|
|
2922
|
+
case "Not":
|
|
2923
|
+
return opt({ not: emit(schema.schema, refs, options) });
|
|
2924
|
+
case "IfThenElse": {
|
|
2925
|
+
const conditional = schema;
|
|
2926
|
+
return opt({
|
|
2927
|
+
if: emit(conditional.if, refs, options),
|
|
2928
|
+
then: emit(conditional.then, refs, options),
|
|
2929
|
+
...conditional.else ? { else: emit(conditional.else, refs, options) } : {}
|
|
2930
|
+
});
|
|
2931
|
+
}
|
|
2932
|
+
case "Conditional": {
|
|
2933
|
+
const conditional = schema;
|
|
2934
|
+
const elseBranch = conditional.default ? emit(conditional.default, refs, options) : undefined;
|
|
2935
|
+
return opt({
|
|
2936
|
+
if: emit(conditional.check, refs, options),
|
|
2937
|
+
then: conditional.union.length > 0 ? { anyOf: conditional.union.map((entry) => emit(entry, refs, options)) } : {},
|
|
2938
|
+
...elseBranch !== undefined && Object.keys(elseBranch).length > 0 ? { else: elseBranch } : {}
|
|
2939
|
+
});
|
|
2940
|
+
}
|
|
2941
|
+
case "Index": {
|
|
2942
|
+
const index = schema;
|
|
2943
|
+
const candidates = deriveIndexSchemasForEmission(index.object, index.key);
|
|
2944
|
+
if (candidates.length === 0)
|
|
2945
|
+
return opt({ not: {} });
|
|
2946
|
+
if (candidates.length === 1 && candidates[0] !== undefined)
|
|
2947
|
+
return emit(candidates[0], refs, options);
|
|
2948
|
+
return opt({ anyOf: candidates.map((candidate) => emit(candidate, refs, options)) });
|
|
2949
|
+
}
|
|
2950
|
+
case "Mapped":
|
|
2951
|
+
return opt(objectLikeSchema(schema.object, refs, options, emit));
|
|
2952
|
+
default:
|
|
2953
|
+
return;
|
|
2954
|
+
}
|
|
2955
|
+
}
|
|
2956
|
+
|
|
2957
|
+
// src/type/instantiation.ts
|
|
2958
|
+
function getString(value) {
|
|
2959
|
+
return typeof value === "string" ? value : undefined;
|
|
2960
|
+
}
|
|
2961
|
+
function getSchema(value) {
|
|
2962
|
+
if (typeof value !== "object" || value === null) {
|
|
2963
|
+
return;
|
|
2964
|
+
}
|
|
2965
|
+
return typeof value["~kind"] === "string" ? value : undefined;
|
|
2966
|
+
}
|
|
2967
|
+
function getSchemaArray(value) {
|
|
2968
|
+
return Array.isArray(value) ? value.flatMap((entry) => getSchema(entry) ? [entry] : []) : [];
|
|
2969
|
+
}
|
|
2970
|
+
function getParameterSchema(schema) {
|
|
2971
|
+
const value = schema;
|
|
2972
|
+
return {
|
|
2973
|
+
name: getString(value["name"]) ?? "",
|
|
2974
|
+
equals: getSchema(value["equals"]) ?? schema
|
|
2975
|
+
};
|
|
2976
|
+
}
|
|
2977
|
+
function getInferSchema(schema) {
|
|
2978
|
+
const value = schema;
|
|
2979
|
+
return {
|
|
2980
|
+
name: getString(value["name"]) ?? "",
|
|
2981
|
+
extends: getSchema(value["extends"]) ?? schema
|
|
2982
|
+
};
|
|
2983
|
+
}
|
|
2984
|
+
function getGenericSchema(schema) {
|
|
2985
|
+
const value = schema;
|
|
2986
|
+
const parameters = Array.isArray(value["parameters"]) ? value["parameters"].flatMap((entry) => {
|
|
2987
|
+
if (typeof entry !== "object" || entry === null)
|
|
2988
|
+
return [];
|
|
2989
|
+
const candidate = entry;
|
|
2990
|
+
return candidate["~kind"] === "Parameter" ? [entry] : [];
|
|
2991
|
+
}) : [];
|
|
2992
|
+
return {
|
|
2993
|
+
parameters,
|
|
2994
|
+
expression: getSchema(value["expression"]) ?? schema
|
|
2995
|
+
};
|
|
2996
|
+
}
|
|
2997
|
+
function getCallSchema(schema) {
|
|
2998
|
+
const value = schema;
|
|
2999
|
+
return {
|
|
3000
|
+
target: getSchema(value["target"]) ?? schema,
|
|
3001
|
+
arguments: getSchemaArray(value["arguments"])
|
|
3002
|
+
};
|
|
3003
|
+
}
|
|
3004
|
+
function getCyclicSchema(schema) {
|
|
3005
|
+
const value = schema;
|
|
3006
|
+
const defsSource = value["$defs"];
|
|
3007
|
+
const defs = typeof defsSource === "object" && defsSource !== null ? Object.fromEntries(Object.entries(defsSource).flatMap(([key, entry]) => {
|
|
3008
|
+
const nextSchema = getSchema(entry);
|
|
3009
|
+
return nextSchema ? [[key, nextSchema]] : [];
|
|
3010
|
+
})) : {};
|
|
3011
|
+
return {
|
|
3012
|
+
$defs: defs,
|
|
3013
|
+
$ref: getString(value["$ref"]) ?? ""
|
|
3014
|
+
};
|
|
3015
|
+
}
|
|
3016
|
+
function bindParameterContext(parameters, arguments_) {
|
|
3017
|
+
const context = {};
|
|
3018
|
+
for (let index = 0;index < parameters.length; index += 1) {
|
|
3019
|
+
const parameter = parameters[index];
|
|
3020
|
+
const name = parameter.name;
|
|
3021
|
+
const argument = arguments_[index] ?? parameter.equals;
|
|
3022
|
+
context[name] = argument;
|
|
3023
|
+
}
|
|
3024
|
+
return context;
|
|
3025
|
+
}
|
|
3026
|
+
function getObjectSchema(schema) {
|
|
3027
|
+
const value = schema;
|
|
3028
|
+
const propertiesSource = value["properties"];
|
|
3029
|
+
const patternPropertiesSource = value["patternProperties"];
|
|
3030
|
+
const requiredSource = value["required"];
|
|
3031
|
+
const optionalSource = value["optional"];
|
|
3032
|
+
return {
|
|
3033
|
+
...schema,
|
|
3034
|
+
"~kind": "Object",
|
|
3035
|
+
properties: typeof propertiesSource === "object" && propertiesSource !== null ? propertiesSource : {},
|
|
3036
|
+
...typeof patternPropertiesSource === "object" && patternPropertiesSource !== null ? { patternProperties: patternPropertiesSource } : {},
|
|
3037
|
+
...Array.isArray(requiredSource) ? { required: requiredSource.filter((entry) => typeof entry === "string") } : {},
|
|
3038
|
+
...Array.isArray(optionalSource) ? { optional: optionalSource.filter((entry) => typeof entry === "string") } : {}
|
|
3039
|
+
};
|
|
3040
|
+
}
|
|
3041
|
+
function instantiateObject(context, schema) {
|
|
3042
|
+
const objectSchema = getObjectSchema(schema);
|
|
3043
|
+
const properties = {};
|
|
3044
|
+
for (const [key, value] of Object.entries(objectSchema.properties)) {
|
|
3045
|
+
properties[key] = Instantiate(context, value);
|
|
3046
|
+
}
|
|
3047
|
+
const patternProperties = objectSchema.patternProperties === undefined ? undefined : Object.fromEntries(Object.entries(objectSchema.patternProperties).map(([key, value]) => [key, Instantiate(context, value)]));
|
|
3048
|
+
return {
|
|
3049
|
+
...objectSchema,
|
|
3050
|
+
properties,
|
|
3051
|
+
...patternProperties !== undefined ? { patternProperties } : {},
|
|
3052
|
+
...typeof objectSchema.additionalProperties === "object" && objectSchema.additionalProperties !== null ? { additionalProperties: Instantiate(context, objectSchema.additionalProperties) } : {}
|
|
3053
|
+
};
|
|
3054
|
+
}
|
|
3055
|
+
function Instantiate(context, schema) {
|
|
3056
|
+
const value = schema;
|
|
3057
|
+
const kind = value["~kind"];
|
|
3058
|
+
switch (kind) {
|
|
3059
|
+
case "Parameter": {
|
|
3060
|
+
const parameter = getParameterSchema(schema);
|
|
3061
|
+
return context[parameter.name] ?? parameter.equals;
|
|
3062
|
+
}
|
|
3063
|
+
case "Infer": {
|
|
3064
|
+
const infer = getInferSchema(schema);
|
|
3065
|
+
return context[infer.name] ?? infer.extends;
|
|
3066
|
+
}
|
|
3067
|
+
case "This":
|
|
3068
|
+
return schema;
|
|
3069
|
+
case "Ref": {
|
|
3070
|
+
const name = value["name"];
|
|
3071
|
+
return typeof name === "string" && context[name] !== undefined ? context[name] : schema;
|
|
3072
|
+
}
|
|
3073
|
+
case "Array":
|
|
3074
|
+
return { ...schema, items: Instantiate(context, value["items"]) };
|
|
3075
|
+
case "Object":
|
|
3076
|
+
return instantiateObject(context, schema);
|
|
3077
|
+
case "Tuple":
|
|
3078
|
+
return { ...schema, items: value["items"].map((item) => Instantiate(context, item)) };
|
|
3079
|
+
case "Record":
|
|
3080
|
+
return {
|
|
3081
|
+
...schema,
|
|
3082
|
+
key: Instantiate(context, value["key"]),
|
|
3083
|
+
value: Instantiate(context, value["value"])
|
|
3084
|
+
};
|
|
3085
|
+
case "Union":
|
|
3086
|
+
case "Intersect":
|
|
3087
|
+
return { ...schema, variants: value["variants"].map((item) => Instantiate(context, item)) };
|
|
3088
|
+
case "Optional":
|
|
3089
|
+
case "Readonly":
|
|
3090
|
+
case "Capitalize":
|
|
3091
|
+
case "Lowercase":
|
|
3092
|
+
case "Uppercase":
|
|
3093
|
+
case "Uncapitalize":
|
|
3094
|
+
case "Awaited":
|
|
3095
|
+
return { ...schema, item: Instantiate(context, value["item"]) };
|
|
3096
|
+
case "Immutable":
|
|
3097
|
+
case "Refine":
|
|
3098
|
+
return { ...schema, item: Instantiate(context, value["item"]) };
|
|
3099
|
+
case "Codec":
|
|
3100
|
+
return { ...schema, inner: Instantiate(context, value["inner"]) };
|
|
3101
|
+
case "Exclude":
|
|
3102
|
+
case "Extract":
|
|
3103
|
+
return {
|
|
3104
|
+
...schema,
|
|
3105
|
+
left: Instantiate(context, value["left"]),
|
|
3106
|
+
right: Instantiate(context, value["right"])
|
|
3107
|
+
};
|
|
3108
|
+
case "Not":
|
|
3109
|
+
return { ...schema, schema: Instantiate(context, value["schema"]) };
|
|
3110
|
+
case "IfThenElse":
|
|
3111
|
+
return {
|
|
3112
|
+
...schema,
|
|
3113
|
+
if: Instantiate(context, value["if"]),
|
|
3114
|
+
then: Instantiate(context, value["then"]),
|
|
3115
|
+
else: Instantiate(context, value["else"])
|
|
3116
|
+
};
|
|
3117
|
+
case "Index":
|
|
3118
|
+
return {
|
|
3119
|
+
...schema,
|
|
3120
|
+
object: Instantiate(context, value["object"]),
|
|
3121
|
+
key: Instantiate(context, value["key"])
|
|
3122
|
+
};
|
|
3123
|
+
case "Mapped":
|
|
3124
|
+
return { ...schema, object: Instantiate(context, value["object"]) };
|
|
3125
|
+
case "Conditional":
|
|
3126
|
+
return {
|
|
3127
|
+
...schema,
|
|
3128
|
+
check: Instantiate(context, value["check"]),
|
|
3129
|
+
union: value["union"].map((item) => Instantiate(context, item)),
|
|
3130
|
+
...value["default"] !== undefined ? { default: Instantiate(context, value["default"]) } : {}
|
|
3131
|
+
};
|
|
3132
|
+
case "Function":
|
|
3133
|
+
case "Constructor":
|
|
3134
|
+
return {
|
|
3135
|
+
...schema,
|
|
3136
|
+
parameters: value["parameters"].map((item) => Instantiate(context, item)),
|
|
3137
|
+
returns: Instantiate(context, value["returns"])
|
|
3138
|
+
};
|
|
3139
|
+
case "Promise":
|
|
3140
|
+
case "Iterator":
|
|
3141
|
+
case "AsyncIterator":
|
|
3142
|
+
case "Rest":
|
|
3143
|
+
return { ...schema, item: Instantiate(context, value["item"]), items: Instantiate(context, value["items"] ?? value["item"]) };
|
|
3144
|
+
case "Decode":
|
|
3145
|
+
return { ...schema, inner: Instantiate(context, value["inner"]) };
|
|
3146
|
+
case "Encode":
|
|
3147
|
+
return { ...schema, inner: Instantiate(context, value["inner"]) };
|
|
3148
|
+
case "ReturnType":
|
|
3149
|
+
case "Parameters":
|
|
3150
|
+
return { ...schema, function: Instantiate(context, value["function"]) };
|
|
3151
|
+
case "InstanceType":
|
|
3152
|
+
case "ConstructorParameters":
|
|
3153
|
+
return { ...schema, constructor: Instantiate(context, value["constructor"]) };
|
|
3154
|
+
case "Generic": {
|
|
3155
|
+
const generic = getGenericSchema(schema);
|
|
3156
|
+
return {
|
|
3157
|
+
...generic,
|
|
3158
|
+
parameters: generic.parameters,
|
|
3159
|
+
expression: Instantiate(context, generic.expression)
|
|
3160
|
+
};
|
|
3161
|
+
}
|
|
3162
|
+
case "Call": {
|
|
3163
|
+
const call = getCallSchema(schema);
|
|
3164
|
+
const target = Instantiate(context, call.target);
|
|
3165
|
+
const arguments_ = call.arguments.map((item) => Instantiate(context, item));
|
|
3166
|
+
const targetValue = target;
|
|
3167
|
+
if (targetValue["~kind"] === "Generic") {
|
|
3168
|
+
const generic = getGenericSchema(target);
|
|
3169
|
+
const nextContext = bindParameterContext(generic.parameters, arguments_);
|
|
3170
|
+
return Instantiate({ ...context, ...nextContext }, generic.expression);
|
|
3171
|
+
}
|
|
3172
|
+
return {
|
|
3173
|
+
"~kind": "Call",
|
|
3174
|
+
target,
|
|
3175
|
+
arguments: arguments_
|
|
3176
|
+
};
|
|
3177
|
+
}
|
|
3178
|
+
case "Cyclic": {
|
|
3179
|
+
const cyclic = getCyclicSchema(schema);
|
|
3180
|
+
const defs = Object.fromEntries(Object.entries(cyclic.$defs).map(([key, value2]) => [key, Instantiate(context, value2)]));
|
|
3181
|
+
return {
|
|
3182
|
+
...cyclic,
|
|
3183
|
+
$defs: defs
|
|
3184
|
+
};
|
|
3185
|
+
}
|
|
3186
|
+
default:
|
|
3187
|
+
return schema;
|
|
3188
|
+
}
|
|
3189
|
+
}
|
|
3190
|
+
|
|
3191
|
+
// src/schema/emitter-reference.ts
|
|
3192
|
+
function emitReferenceSchema(kind, schema, refs, options, opt, emit) {
|
|
3193
|
+
switch (kind) {
|
|
3194
|
+
case "Recursive": {
|
|
3195
|
+
const recursive = schema;
|
|
3196
|
+
refs.set(recursive.name, recursive.schema);
|
|
3197
|
+
return { $ref: `#/definitions/${recursive.name}` };
|
|
3198
|
+
}
|
|
3199
|
+
case "Cyclic": {
|
|
3200
|
+
const definitions = schemaSchemaMapField(schema, "$defs");
|
|
3201
|
+
const ref = schemaStringField(schema, "$ref");
|
|
3202
|
+
return {
|
|
3203
|
+
$defs: Object.fromEntries(Object.entries(definitions).map(([key, value]) => [key, emit(value, refs, options)])),
|
|
3204
|
+
...ref !== undefined ? { $ref: `#/$defs/${ref}` } : {}
|
|
3205
|
+
};
|
|
3206
|
+
}
|
|
3207
|
+
case "Ref": {
|
|
3208
|
+
const refSchema = schema;
|
|
3209
|
+
return refs.has(refSchema.name) ? { $ref: `#/definitions/${refSchema.name}` } : opt({ not: {}, $comment: `Unresolved ref: ${refSchema.name}` });
|
|
3210
|
+
}
|
|
3211
|
+
case "This":
|
|
3212
|
+
return { $ref: "#" };
|
|
3213
|
+
case "Generic":
|
|
3214
|
+
return emit(schemaSchemaField(schema, "expression") ?? schema, refs, options);
|
|
3215
|
+
case "Call": {
|
|
3216
|
+
const instantiated = Instantiate({}, schema);
|
|
3217
|
+
return instantiated === schema ? opt({ not: {}, $comment: "Unable to instantiate call schema." }) : emit(instantiated, refs, options);
|
|
3218
|
+
}
|
|
3219
|
+
case "Infer":
|
|
3220
|
+
return emit(schemaSchemaField(schema, "extends") ?? schema, refs, options);
|
|
3221
|
+
case "Module": {
|
|
3222
|
+
const definitions = schemaSchemaMapField(schema, "definitions");
|
|
3223
|
+
return opt({
|
|
3224
|
+
$defs: Object.fromEntries(Object.entries(definitions).map(([name, definition]) => [name, emit(definition, refs, options)]))
|
|
3225
|
+
});
|
|
3226
|
+
}
|
|
3227
|
+
default:
|
|
3228
|
+
return;
|
|
3229
|
+
}
|
|
3230
|
+
}
|
|
3231
|
+
|
|
3232
|
+
// src/schema/emitter-wrapper.ts
|
|
3233
|
+
function emitWrapperSchema(kind, schema, refs, options, opt, emit) {
|
|
3234
|
+
switch (kind) {
|
|
3235
|
+
case "Rest":
|
|
3236
|
+
return opt({ type: "array", items: emit(schemaItem(schema) ?? schemaSchemaField(schema, "items") ?? schema, refs, options) });
|
|
3237
|
+
case "Capitalize":
|
|
3238
|
+
case "Lowercase":
|
|
3239
|
+
case "Uppercase":
|
|
3240
|
+
case "Uncapitalize":
|
|
3241
|
+
return emit(resolveStringActionSchema(schema), refs, options);
|
|
3242
|
+
case "Identifier":
|
|
3243
|
+
return opt({ type: "string", pattern: "^[$A-Z_a-z][$\\w]*$" });
|
|
3244
|
+
case "Parameter":
|
|
3245
|
+
return emit(schemaSchemaField(schema, "equals") ?? schema, refs, options);
|
|
3246
|
+
case "TemplateLiteral":
|
|
3247
|
+
return opt({ type: "string", pattern: schemaPatterns(schema).join("|") });
|
|
3248
|
+
case "Unsafe":
|
|
3249
|
+
return { ...schema.schema };
|
|
3250
|
+
case "Decode":
|
|
3251
|
+
case "Encode":
|
|
3252
|
+
return emit(schemaItemOrInner(schema) ?? schema, refs, options);
|
|
3253
|
+
case "Awaited":
|
|
3254
|
+
return emit(schemaItem(schemaSchemaField(schema, "promise") ?? schema) ?? schema, refs, options);
|
|
3255
|
+
case "ReturnType":
|
|
3256
|
+
return emit(schemaSchemaField(schemaSchemaField(schema, "function") ?? schema, "returns") ?? schema, refs, options);
|
|
3257
|
+
case "Parameters": {
|
|
3258
|
+
const parameters = schemaSchemaListField(schemaSchemaField(schema, "function") ?? schema, "parameters");
|
|
3259
|
+
return opt({
|
|
3260
|
+
type: "array",
|
|
3261
|
+
prefixItems: parameters.map((entry) => emit(entry, refs, options)),
|
|
3262
|
+
minItems: parameters.length,
|
|
3263
|
+
maxItems: parameters.length
|
|
3264
|
+
});
|
|
3265
|
+
}
|
|
3266
|
+
case "InstanceType":
|
|
3267
|
+
return emit(schemaSchemaField(schemaSchemaField(schema, "constructor") ?? schema, "returns") ?? schema, refs, options);
|
|
3268
|
+
case "ConstructorParameters": {
|
|
3269
|
+
const parameters = schemaSchemaListField(schemaSchemaField(schema, "constructor") ?? schema, "parameters");
|
|
3270
|
+
return opt({
|
|
3271
|
+
type: "array",
|
|
3272
|
+
prefixItems: parameters.map((entry) => emit(entry, refs, options)),
|
|
3273
|
+
minItems: parameters.length,
|
|
3274
|
+
maxItems: parameters.length
|
|
3275
|
+
});
|
|
3276
|
+
}
|
|
3277
|
+
case "Function":
|
|
3278
|
+
case "Constructor":
|
|
3279
|
+
case "Promise":
|
|
3280
|
+
case "Iterator":
|
|
3281
|
+
case "AsyncIterator":
|
|
3282
|
+
case "Symbol":
|
|
3283
|
+
case "Base":
|
|
3284
|
+
return opt({});
|
|
3285
|
+
default:
|
|
3286
|
+
return;
|
|
3287
|
+
}
|
|
3288
|
+
}
|
|
3289
|
+
|
|
3290
|
+
// src/schema/emitter-advanced.ts
|
|
3291
|
+
function emitAdvancedSchema(kind, schema, refs, options, opt, emit) {
|
|
3292
|
+
return emitReferenceSchema(kind, schema, refs, options, opt, emit) ?? emitDerivedSchema(kind, schema, refs, options, opt, emit) ?? emitWrapperSchema(kind, schema, refs, options, opt, emit);
|
|
3293
|
+
}
|
|
3294
|
+
|
|
3295
|
+
// src/schema/emitter.ts
|
|
3296
|
+
function Schema(schema, options = {}) {
|
|
3297
|
+
const refs = new Map;
|
|
3298
|
+
const emitted = toJsonSchema(schema, refs, options);
|
|
3299
|
+
const definitions = {};
|
|
3300
|
+
for (const [name, refSchema] of refs) {
|
|
3301
|
+
definitions[name] = toJsonSchema(refSchema, refs, options);
|
|
3302
|
+
}
|
|
3303
|
+
return { schema: emitted, definitions };
|
|
3304
|
+
}
|
|
3305
|
+
function To(schema, options = {}) {
|
|
3306
|
+
return toJsonSchema(schema, new Map, options ?? {});
|
|
3307
|
+
}
|
|
3308
|
+
function applySchemaOptions(schema, options) {
|
|
3309
|
+
const { descriptions = true, titles = true, defaults = true } = options;
|
|
3310
|
+
return (obj, extra = {}) => {
|
|
3311
|
+
const result = { ...obj, ...extra };
|
|
3312
|
+
const description = schemaUnknownField(schema, "description");
|
|
3313
|
+
const title = schemaUnknownField(schema, "title");
|
|
3314
|
+
const defaultValue = schemaUnknownField(schema, "default");
|
|
3315
|
+
if (descriptions && typeof description === "string")
|
|
3316
|
+
result.description = description;
|
|
3317
|
+
if (titles && typeof title === "string")
|
|
3318
|
+
result.title = title;
|
|
3319
|
+
if (defaults && defaultValue !== undefined)
|
|
3320
|
+
result["default"] = defaultValue;
|
|
3321
|
+
return result;
|
|
3322
|
+
};
|
|
3323
|
+
}
|
|
3324
|
+
function emitBuiltInSchema(kind, schema, refs, options, opt, emit) {
|
|
3325
|
+
switch (kind) {
|
|
3326
|
+
case "String":
|
|
3327
|
+
return opt(stringSchema(schema));
|
|
3328
|
+
case "Uint8Array": {
|
|
3329
|
+
const bytes = schema;
|
|
3330
|
+
return opt({
|
|
3331
|
+
type: "string",
|
|
3332
|
+
contentEncoding: "base64",
|
|
3333
|
+
...bytes.minByteLength !== undefined ? { minLength: Math.ceil(bytes.minByteLength * 4 / 3) } : {},
|
|
3334
|
+
...bytes.maxByteLength !== undefined ? { maxLength: Math.ceil(bytes.maxByteLength * 4 / 3) } : {},
|
|
3335
|
+
$comment: "Uint8Array runtime values are represented as base64 strings in emitted JSON Schema."
|
|
3336
|
+
});
|
|
3337
|
+
}
|
|
3338
|
+
case "RegExpInstance":
|
|
3339
|
+
return opt({ type: "object", $comment: "RegExpInstance validates actual RegExp objects; no JSON Schema equivalent." });
|
|
3340
|
+
case "Number":
|
|
3341
|
+
return opt(numberSchema(schema));
|
|
3342
|
+
case "Integer":
|
|
3343
|
+
return opt(integerSchema(schema));
|
|
3344
|
+
case "Boolean":
|
|
3345
|
+
return opt({ type: "boolean" });
|
|
3346
|
+
case "Null":
|
|
3347
|
+
return opt({ type: "null" });
|
|
3348
|
+
case "BigInt":
|
|
3349
|
+
return opt({ type: "string", $comment: "BigInt runtime value; no native JSON Schema equivalent." });
|
|
3350
|
+
case "Date":
|
|
3351
|
+
return opt({ type: "string", format: "date-time", $comment: "Date runtime instance; validated as native Date at runtime." });
|
|
3352
|
+
case "Literal":
|
|
3353
|
+
return opt({ const: schemaConst(schema) });
|
|
3354
|
+
case "Void":
|
|
3355
|
+
return opt({ type: "null", description: "void (undefined or null)" });
|
|
3356
|
+
case "Undefined":
|
|
3357
|
+
return opt({ not: {}, description: "undefined" });
|
|
3358
|
+
case "Unknown":
|
|
3359
|
+
case "Any":
|
|
3360
|
+
return opt({});
|
|
3361
|
+
case "Never":
|
|
3362
|
+
return opt({ not: {} });
|
|
3363
|
+
case "Array": {
|
|
3364
|
+
const array = schema;
|
|
3365
|
+
return opt({
|
|
3366
|
+
type: "array",
|
|
3367
|
+
items: emit(array.items, refs, options),
|
|
3368
|
+
...array.minItems !== undefined ? { minItems: array.minItems } : {},
|
|
3369
|
+
...array.maxItems !== undefined ? { maxItems: array.maxItems } : {},
|
|
3370
|
+
...array.uniqueItems ? { uniqueItems: true } : {},
|
|
3371
|
+
...array.contains !== undefined ? { contains: emit(array.contains, refs, options) } : {},
|
|
3372
|
+
...array.minContains !== undefined ? { minContains: array.minContains } : {},
|
|
3373
|
+
...array.maxContains !== undefined ? { maxContains: array.maxContains } : {}
|
|
3374
|
+
});
|
|
3375
|
+
}
|
|
3376
|
+
case "Object":
|
|
3377
|
+
return opt(objectLikeSchema(schema, refs, options, emit));
|
|
3378
|
+
case "Tuple": {
|
|
3379
|
+
const tuple = schema;
|
|
3380
|
+
return opt({
|
|
3381
|
+
type: "array",
|
|
3382
|
+
prefixItems: tuple.items.map((item) => emit(item, refs, options)),
|
|
3383
|
+
minItems: tuple.minItems ?? tuple.items.length,
|
|
3384
|
+
...tuple.maxItems !== undefined ? { maxItems: tuple.maxItems } : tuple.additionalItems === true ? {} : { maxItems: tuple.items.length },
|
|
3385
|
+
items: tuple.additionalItems === true ? {} : false
|
|
3386
|
+
});
|
|
3387
|
+
}
|
|
3388
|
+
case "Record": {
|
|
3389
|
+
const record = schema;
|
|
3390
|
+
return opt({
|
|
3391
|
+
type: "object",
|
|
3392
|
+
propertyNames: emit(record.key, refs, options),
|
|
3393
|
+
additionalProperties: emit(record.value, refs, options),
|
|
3394
|
+
...record.minProperties !== undefined ? { minProperties: record.minProperties } : {},
|
|
3395
|
+
...record.maxProperties !== undefined ? { maxProperties: record.maxProperties } : {}
|
|
3396
|
+
});
|
|
3397
|
+
}
|
|
3398
|
+
case "Union":
|
|
3399
|
+
return opt({ anyOf: schemaVariants(schema).map((entry) => emit(entry, refs, options)) });
|
|
3400
|
+
case "Intersect":
|
|
3401
|
+
return opt({ allOf: schemaVariants(schema).map((entry) => emit(entry, refs, options)) });
|
|
3402
|
+
case "Optional":
|
|
3403
|
+
return { ...emit(schemaItem(schema) ?? schema, refs, options), $comment: "Optional wrapper accepts undefined at runtime; JSON Schema represents the defined-value branch only." };
|
|
3404
|
+
case "Readonly":
|
|
3405
|
+
case "Immutable":
|
|
3406
|
+
return emit(schemaItem(schema) ?? schema, refs, options);
|
|
3407
|
+
case "Codec":
|
|
3408
|
+
return emit(schemaItemOrInner(schema) ?? schema, refs, options);
|
|
3409
|
+
case "Refine": {
|
|
3410
|
+
const emitted = emit(schemaItem(schema) ?? schema, refs, options);
|
|
3411
|
+
const messages = schemaRefinements(schema).flatMap((entry) => entry.message === undefined ? [] : [entry.message]);
|
|
3412
|
+
return { ...emitted, ...messages.length > 0 ? { $comment: messages.join("; ") } : {} };
|
|
3413
|
+
}
|
|
3414
|
+
case "Enum":
|
|
3415
|
+
return opt({ type: "string", enum: schemaStringListField(schema, "values") });
|
|
3416
|
+
default:
|
|
3417
|
+
return;
|
|
3418
|
+
}
|
|
3419
|
+
}
|
|
3420
|
+
function toJsonSchema(schema, refs, options) {
|
|
3421
|
+
const kind = schemaUnknownField(schema, "~kind");
|
|
3422
|
+
const resolvedKind = typeof kind === "string" ? kind : undefined;
|
|
3423
|
+
const opt = applySchemaOptions(schema, options);
|
|
3424
|
+
const emit = (nextSchema, nextRefs, nextOptions) => toJsonSchema(nextSchema, nextRefs, nextOptions);
|
|
3425
|
+
return emitBuiltInSchema(resolvedKind, schema, refs, options, opt, emit) ?? emitReferenceSchema(resolvedKind, schema, refs, options, opt, emit) ?? emitWrapperSchema(resolvedKind, schema, refs, options, opt, emit) ?? emitDerivedSchema(resolvedKind, schema, refs, options, opt, emit) ?? emitAdvancedSchema(resolvedKind, schema, refs, options, opt, emit) ?? {};
|
|
3426
|
+
}
|
|
3427
|
+
// src/schema/index.ts
|
|
3428
|
+
var schema_default = exports_schema;
|
|
3429
|
+
export {
|
|
3430
|
+
schema_default as default,
|
|
3431
|
+
Validator,
|
|
3432
|
+
TryParse,
|
|
3433
|
+
To,
|
|
3434
|
+
Stack,
|
|
3435
|
+
Set2 as Set,
|
|
3436
|
+
Schema,
|
|
3437
|
+
Resolve,
|
|
3438
|
+
ResetFunctions,
|
|
3439
|
+
ResetExternal,
|
|
3440
|
+
Ref,
|
|
3441
|
+
Reducer,
|
|
3442
|
+
Pointer,
|
|
3443
|
+
ParseError,
|
|
3444
|
+
Parse,
|
|
3445
|
+
IsUniqueItems,
|
|
3446
|
+
IsUnevaluatedProperties,
|
|
3447
|
+
IsUnevaluatedItems,
|
|
3448
|
+
IsType,
|
|
3449
|
+
IsThen,
|
|
3450
|
+
IsSchemaObject2 as IsSchemaObject,
|
|
3451
|
+
IsSchema2 as IsSchema,
|
|
3452
|
+
IsRequired,
|
|
3453
|
+
IsRefine,
|
|
3454
|
+
IsRef,
|
|
3455
|
+
IsRecursiveRef,
|
|
3456
|
+
IsRecursiveAnchorTrue,
|
|
3457
|
+
IsRecursiveAnchor,
|
|
3458
|
+
IsPropertyNames,
|
|
3459
|
+
IsProperties,
|
|
3460
|
+
IsPrefixItems,
|
|
3461
|
+
IsPatternProperties,
|
|
3462
|
+
IsPattern,
|
|
3463
|
+
IsOneOf,
|
|
3464
|
+
IsNot,
|
|
3465
|
+
IsMultipleOf,
|
|
3466
|
+
IsMinimum,
|
|
3467
|
+
IsMinProperties,
|
|
3468
|
+
IsMinLength,
|
|
3469
|
+
IsMinItems,
|
|
3470
|
+
IsMinContains,
|
|
3471
|
+
IsMaximum,
|
|
3472
|
+
IsMaxProperties,
|
|
3473
|
+
IsMaxLength,
|
|
3474
|
+
IsMaxItems,
|
|
3475
|
+
IsMaxContains,
|
|
3476
|
+
IsItemsUnsized,
|
|
3477
|
+
IsItemsSized,
|
|
3478
|
+
IsItems,
|
|
3479
|
+
IsIf,
|
|
3480
|
+
IsId,
|
|
3481
|
+
IsGuardInterface,
|
|
3482
|
+
IsGuard,
|
|
3483
|
+
IsFormat,
|
|
3484
|
+
IsExclusiveMinimum,
|
|
3485
|
+
IsExclusiveMaximum,
|
|
3486
|
+
IsEnum,
|
|
3487
|
+
IsElse,
|
|
3488
|
+
IsDynamicRef,
|
|
3489
|
+
IsDynamicAnchor,
|
|
3490
|
+
IsDependentSchemas,
|
|
3491
|
+
IsDependentRequired,
|
|
3492
|
+
IsDependencies,
|
|
3493
|
+
IsDefs,
|
|
3494
|
+
IsDefault,
|
|
3495
|
+
IsContentMediaType,
|
|
3496
|
+
IsContentEncoding,
|
|
3497
|
+
IsContains,
|
|
3498
|
+
IsConst,
|
|
3499
|
+
IsBooleanSchema,
|
|
3500
|
+
IsAnyOf,
|
|
3501
|
+
IsAnchor,
|
|
3502
|
+
IsAllOf,
|
|
3503
|
+
IsAdditionalProperties,
|
|
3504
|
+
IsAdditionalItems,
|
|
3505
|
+
Indices,
|
|
3506
|
+
HasUnevaluated,
|
|
3507
|
+
Has,
|
|
3508
|
+
GetFunctions,
|
|
3509
|
+
GetExternal,
|
|
3510
|
+
Get,
|
|
3511
|
+
Errors,
|
|
3512
|
+
ErrorUniqueItems,
|
|
3513
|
+
ErrorUnevaluatedProperties,
|
|
3514
|
+
ErrorUnevaluatedItems,
|
|
3515
|
+
ErrorType,
|
|
3516
|
+
ErrorSchema,
|
|
3517
|
+
ErrorRequired,
|
|
3518
|
+
ErrorRefine,
|
|
3519
|
+
ErrorRef,
|
|
3520
|
+
ErrorRecursiveRef,
|
|
3521
|
+
ErrorPropertyNames,
|
|
3522
|
+
ErrorProperties,
|
|
3523
|
+
ErrorPrefixItems,
|
|
3524
|
+
ErrorPatternProperties,
|
|
3525
|
+
ErrorPattern,
|
|
3526
|
+
ErrorOneOf,
|
|
3527
|
+
ErrorNot,
|
|
3528
|
+
ErrorMultipleOf,
|
|
3529
|
+
ErrorMinimum,
|
|
3530
|
+
ErrorMinProperties,
|
|
3531
|
+
ErrorMinLength,
|
|
3532
|
+
ErrorMinItems,
|
|
3533
|
+
ErrorMinContains,
|
|
3534
|
+
ErrorMaximum,
|
|
3535
|
+
ErrorMaxProperties,
|
|
3536
|
+
ErrorMaxLength,
|
|
3537
|
+
ErrorMaxItems,
|
|
3538
|
+
ErrorMaxContains,
|
|
3539
|
+
ErrorItems,
|
|
3540
|
+
ErrorIf,
|
|
3541
|
+
ErrorGuard,
|
|
3542
|
+
ErrorFormat,
|
|
3543
|
+
ErrorExclusiveMinimum,
|
|
3544
|
+
ErrorExclusiveMaximum,
|
|
3545
|
+
ErrorEnum,
|
|
3546
|
+
ErrorDependentSchemas,
|
|
3547
|
+
ErrorDependentRequired,
|
|
3548
|
+
ErrorDependencies,
|
|
3549
|
+
ErrorContext,
|
|
3550
|
+
ErrorContains,
|
|
3551
|
+
ErrorConst,
|
|
3552
|
+
ErrorBooleanSchema,
|
|
3553
|
+
ErrorAnyOf,
|
|
3554
|
+
ErrorAllOf,
|
|
3555
|
+
ErrorAdditionalProperties,
|
|
3556
|
+
ErrorAdditionalItems,
|
|
3557
|
+
Delete,
|
|
3558
|
+
CreateVariable,
|
|
3559
|
+
CreateFunction,
|
|
3560
|
+
Compile,
|
|
3561
|
+
CheckUniqueItems,
|
|
3562
|
+
CheckUnevaluatedProperties,
|
|
3563
|
+
CheckUnevaluatedItems,
|
|
3564
|
+
CheckType,
|
|
3565
|
+
CheckSchema,
|
|
3566
|
+
CheckRequired,
|
|
3567
|
+
CheckRefine,
|
|
3568
|
+
CheckRef,
|
|
3569
|
+
CheckRecursiveRef,
|
|
3570
|
+
CheckPropertyNames,
|
|
3571
|
+
CheckProperties,
|
|
3572
|
+
CheckPrefixItems,
|
|
3573
|
+
CheckPatternProperties,
|
|
3574
|
+
CheckPattern,
|
|
3575
|
+
CheckOneOf,
|
|
3576
|
+
CheckNot,
|
|
3577
|
+
CheckMultipleOf,
|
|
3578
|
+
CheckMinimum,
|
|
3579
|
+
CheckMinProperties,
|
|
3580
|
+
CheckMinLength,
|
|
3581
|
+
CheckMinItems,
|
|
3582
|
+
CheckMinContains,
|
|
3583
|
+
CheckMaximum,
|
|
3584
|
+
CheckMaxProperties,
|
|
3585
|
+
CheckMaxLength,
|
|
3586
|
+
CheckMaxItems,
|
|
3587
|
+
CheckMaxContains,
|
|
3588
|
+
CheckItems,
|
|
3589
|
+
CheckIf,
|
|
3590
|
+
CheckGuard,
|
|
3591
|
+
CheckFormat,
|
|
3592
|
+
CheckExclusiveMinimum,
|
|
3593
|
+
CheckExclusiveMaximum,
|
|
3594
|
+
CheckEnum,
|
|
3595
|
+
CheckDependentSchemas,
|
|
3596
|
+
CheckDependentRequired,
|
|
3597
|
+
CheckDependencies,
|
|
3598
|
+
CheckContext,
|
|
3599
|
+
CheckContains,
|
|
3600
|
+
CheckConst,
|
|
3601
|
+
CheckBooleanSchema,
|
|
3602
|
+
CheckAnyOf,
|
|
3603
|
+
CheckAllOf,
|
|
3604
|
+
CheckAdditionalProperties,
|
|
3605
|
+
CheckAdditionalItems,
|
|
3606
|
+
Check,
|
|
3607
|
+
CanAdditionalPropertiesFast,
|
|
3608
|
+
BuildUniqueItems,
|
|
3609
|
+
BuildUnevaluatedProperties,
|
|
3610
|
+
BuildUnevaluatedItems,
|
|
3611
|
+
BuildType,
|
|
3612
|
+
BuildSchema,
|
|
3613
|
+
BuildResult,
|
|
3614
|
+
BuildRequired,
|
|
3615
|
+
BuildRefine,
|
|
3616
|
+
BuildRef,
|
|
3617
|
+
BuildRecursiveRef,
|
|
3618
|
+
BuildPropertyNames,
|
|
3619
|
+
BuildProperties,
|
|
3620
|
+
BuildPrefixItems,
|
|
3621
|
+
BuildPatternProperties,
|
|
3622
|
+
BuildPattern,
|
|
3623
|
+
BuildOneOf,
|
|
3624
|
+
BuildNot,
|
|
3625
|
+
BuildMultipleOf,
|
|
3626
|
+
BuildMinimum,
|
|
3627
|
+
BuildMinProperties,
|
|
3628
|
+
BuildMinLength,
|
|
3629
|
+
BuildMinItems,
|
|
3630
|
+
BuildMinContains,
|
|
3631
|
+
BuildMaximum,
|
|
3632
|
+
BuildMaxProperties,
|
|
3633
|
+
BuildMaxLength,
|
|
3634
|
+
BuildMaxItems,
|
|
3635
|
+
BuildMaxContains,
|
|
3636
|
+
BuildItems,
|
|
3637
|
+
BuildIf,
|
|
3638
|
+
BuildGuard,
|
|
3639
|
+
BuildFormat,
|
|
3640
|
+
BuildExclusiveMinimum,
|
|
3641
|
+
BuildExclusiveMaximum,
|
|
3642
|
+
BuildEnum,
|
|
3643
|
+
BuildDependentSchemas,
|
|
3644
|
+
BuildDependentRequired,
|
|
3645
|
+
BuildDependencies,
|
|
3646
|
+
BuildContext,
|
|
3647
|
+
BuildContains,
|
|
3648
|
+
BuildConst,
|
|
3649
|
+
BuildBooleanSchema,
|
|
3650
|
+
BuildAnyOf,
|
|
3651
|
+
BuildAllOf,
|
|
3652
|
+
BuildAdditionalPropertiesStandard,
|
|
3653
|
+
BuildAdditionalPropertiesFast,
|
|
3654
|
+
BuildAdditionalProperties,
|
|
3655
|
+
BuildAdditionalItems,
|
|
3656
|
+
Build,
|
|
3657
|
+
AccumulatedErrorContext
|
|
3658
|
+
};
|
|
3659
|
+
|
|
3660
|
+
//# debugId=E15CA57717B3AABF64756E2164756E21
|
|
3661
|
+
//# sourceMappingURL=index.js.map
|