@jetio/validator 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1362 -0
- package/dist/cli.js +219 -0
- package/dist/compileSchema.d.ts +148 -0
- package/dist/compileSchema.js +2199 -0
- package/dist/compileSchema.js.map +1 -0
- package/dist/formats.d.ts +41 -0
- package/dist/formats.js +166 -0
- package/dist/formats.js.map +1 -0
- package/dist/index.cjs.js +6167 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.esm.js +6148 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/jet-validator.d.ts +88 -0
- package/dist/jet-validator.js +983 -0
- package/dist/jet-validator.js.map +1 -0
- package/dist/resolver.d.ts +348 -0
- package/dist/resolver.js +2459 -0
- package/dist/resolver.js.map +1 -0
- package/dist/scripts/load-metaschemas.d.ts +1 -0
- package/dist/scripts/metaschema-loader.d.ts +2 -0
- package/dist/src/compileSchema.d.ts +148 -0
- package/dist/src/formats.d.ts +41 -0
- package/dist/src/index.d.ts +9 -0
- package/dist/src/jet-validator.d.ts +88 -0
- package/dist/src/resolver.d.ts +348 -0
- package/dist/src/types/format.d.ts +7 -0
- package/dist/src/types/keywords.d.ts +78 -0
- package/dist/src/types/schema.d.ts +123 -0
- package/dist/src/types/standalone.d.ts +4 -0
- package/dist/src/types/validation.d.ts +49 -0
- package/dist/src/utilities/index.d.ts +11 -0
- package/dist/src/utilities/schema.d.ts +10 -0
- package/dist/types/format.d.ts +7 -0
- package/dist/types/format.js +3 -0
- package/dist/types/format.js.map +1 -0
- package/dist/types/keywords.d.ts +78 -0
- package/dist/types/keywords.js +4 -0
- package/dist/types/keywords.js.map +1 -0
- package/dist/types/schema.d.ts +123 -0
- package/dist/types/schema.js +3 -0
- package/dist/types/schema.js.map +1 -0
- package/dist/types/standalone.d.ts +4 -0
- package/dist/types/standalone.js +3 -0
- package/dist/types/standalone.js.map +1 -0
- package/dist/types/validation.d.ts +49 -0
- package/dist/types/validation.js +3 -0
- package/dist/types/validation.js.map +1 -0
- package/dist/utilities/index.d.ts +11 -0
- package/dist/utilities/index.js +146 -0
- package/dist/utilities/index.js.map +1 -0
- package/dist/utilities/schema.d.ts +10 -0
- package/dist/utilities/schema.js +232 -0
- package/dist/utilities/schema.js.map +1 -0
- package/dist/validator.umd.js +6196 -0
- package/package.json +79 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.JetValidator = void 0;
|
|
18
|
+
var jet_validator_1 = require("./jet-validator");
|
|
19
|
+
Object.defineProperty(exports, "JetValidator", { enumerable: true, get: function () { return jet_validator_1.JetValidator; } });
|
|
20
|
+
__exportStar(require("./resolver"), exports);
|
|
21
|
+
__exportStar(require("./formats"), exports);
|
|
22
|
+
__exportStar(require("./compileSchema"), exports);
|
|
23
|
+
__exportStar(require("./types/format"), exports);
|
|
24
|
+
__exportStar(require("./types/keywords"), exports);
|
|
25
|
+
__exportStar(require("./types/schema"), exports);
|
|
26
|
+
__exportStar(require("./types/validation"), exports);
|
|
27
|
+
__exportStar(require("./utilities"), exports);
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AACrB,6CAA2B;AAC3B,4CAA0B;AAC1B,kDAAgC;AAChC,iDAA+B;AAC/B,mDAAiC;AACjC,iDAA+B;AAC/B,qDAAmC;AACnC,8CAA4B"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { SchemaDefinition } from "./types/schema";
|
|
2
|
+
import { ErrorAttachedValidatorFn, ValidationResult, ValidatorOptions } from "./types/validation";
|
|
3
|
+
import { CodeKeywordDefinition, CompileKeywordDefinition, KeywordDefinition, MacroKeywordDefinition, ValidateKeywordDefinition } from "./types/keywords";
|
|
4
|
+
import { FormatDefinition } from "./types/format";
|
|
5
|
+
export declare class JetValidator {
|
|
6
|
+
private schemas;
|
|
7
|
+
private metaSchemas;
|
|
8
|
+
private customKeywords;
|
|
9
|
+
private formatValidators;
|
|
10
|
+
private hasMacros;
|
|
11
|
+
private compilationCache;
|
|
12
|
+
options: Required<ValidatorOptions>;
|
|
13
|
+
private counter;
|
|
14
|
+
private aliases;
|
|
15
|
+
constructor(options?: ValidatorOptions);
|
|
16
|
+
addFormat(key: string, validator: FormatDefinition, options?: {
|
|
17
|
+
override?: boolean;
|
|
18
|
+
}): void;
|
|
19
|
+
removeFormat(key: string): void;
|
|
20
|
+
getFormat(format: string): FormatDefinition | undefined;
|
|
21
|
+
testFormat(value: string, format: string): boolean | Promise<boolean>;
|
|
22
|
+
isFormatRegistered(key: string): boolean;
|
|
23
|
+
getRegisteredFormats(): string[];
|
|
24
|
+
validateFormat(value: string, format: string): any;
|
|
25
|
+
getAllFormats(): Record<string, FormatDefinition>;
|
|
26
|
+
addKeyword(definition: MacroKeywordDefinition | CompileKeywordDefinition | ValidateKeywordDefinition | CodeKeywordDefinition): this;
|
|
27
|
+
removeKeyword(keyword: string): this;
|
|
28
|
+
hasMacroKeywords(): boolean;
|
|
29
|
+
getKeyword(keyword: string): MacroKeywordDefinition | CompileKeywordDefinition | ValidateKeywordDefinition | CodeKeywordDefinition | undefined;
|
|
30
|
+
private validateKeywordDefinition;
|
|
31
|
+
isKeywordAdded(key: string): boolean;
|
|
32
|
+
getAddedKeywords(): string[];
|
|
33
|
+
clearKeywords(): void;
|
|
34
|
+
getAllKeywords(): Map<string, KeywordDefinition>;
|
|
35
|
+
addSchema(schema: SchemaDefinition, id?: string): void;
|
|
36
|
+
getSchema(key: string): SchemaDefinition | undefined;
|
|
37
|
+
getCompiledSchema(key: string, config?: ValidatorOptions): Function;
|
|
38
|
+
getCompiledSchemaAsync(key: string, config?: ValidatorOptions): Promise<Function>;
|
|
39
|
+
isSchemaAdded(key: string): boolean;
|
|
40
|
+
getAddedSchemas(): string[];
|
|
41
|
+
removeSchema(pattern?: string | RegExp | object): void;
|
|
42
|
+
clearSchemas(): void;
|
|
43
|
+
getAllSchemas(): Record<string, SchemaDefinition>;
|
|
44
|
+
validate(schema: object | boolean | string, data: any, config?: ValidatorOptions): ValidationResult;
|
|
45
|
+
validateAsync(schema: object | boolean | string, data: any, config?: ValidatorOptions): Promise<ValidationResult>;
|
|
46
|
+
getMetaSchema($schema?: string, options?: ValidatorOptions): {
|
|
47
|
+
metaSchema: object | undefined;
|
|
48
|
+
metaSchemaId: string;
|
|
49
|
+
};
|
|
50
|
+
validateSchemaSync(schema: SchemaDefinition, options?: ValidatorOptions): {
|
|
51
|
+
valid: boolean;
|
|
52
|
+
errors: any;
|
|
53
|
+
};
|
|
54
|
+
validateSchemaAsync(schema: SchemaDefinition, options?: ValidatorOptions): Promise<{
|
|
55
|
+
valid: boolean;
|
|
56
|
+
errors: any;
|
|
57
|
+
}>;
|
|
58
|
+
addMetaSchema(schema: SchemaDefinition, key?: string): this;
|
|
59
|
+
clearRegistries(): void;
|
|
60
|
+
private compileResolved;
|
|
61
|
+
compile(fschema: object | boolean, config?: ValidatorOptions): ErrorAttachedValidatorFn;
|
|
62
|
+
compileAsync(fschema: SchemaDefinition | boolean, config?: ValidatorOptions): Promise<ErrorAttachedValidatorFn>;
|
|
63
|
+
logErrors(errors: any, indent?: number): void;
|
|
64
|
+
getFieldFromPath(dataPath: string): string;
|
|
65
|
+
getFullFieldPath(dataPath: string): string;
|
|
66
|
+
getFieldErrors(errors: any[]): Record<string, string[]>;
|
|
67
|
+
errorsText(errors: any[], options?: {
|
|
68
|
+
separator?: string;
|
|
69
|
+
dataVar?: string;
|
|
70
|
+
}): string;
|
|
71
|
+
generateStandalone(schema: object, sconfig?: ValidatorOptions): {
|
|
72
|
+
code: string;
|
|
73
|
+
functionName: string;
|
|
74
|
+
formatSetup?: string;
|
|
75
|
+
imports: string[];
|
|
76
|
+
};
|
|
77
|
+
private inlineUsedFormats;
|
|
78
|
+
private resolveFormats;
|
|
79
|
+
private inlineAllConfiguredFormats;
|
|
80
|
+
private resolve$DataFormat;
|
|
81
|
+
private createFormatObject;
|
|
82
|
+
private getSafeFormatName;
|
|
83
|
+
private formatNeedsExternalDeps;
|
|
84
|
+
private inlineFormatWithDeps;
|
|
85
|
+
private serializeFormatFunction;
|
|
86
|
+
private isSelfContained;
|
|
87
|
+
private generateFormatSetup;
|
|
88
|
+
}
|