source: trip-planner-front/node_modules/ajv/dist/core.d.ts@ 6a80231

Last change on this file since 6a80231 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 8.0 KB
Line 
1export { Format, FormatDefinition, AsyncFormatDefinition, KeywordDefinition, KeywordErrorDefinition, CodeKeywordDefinition, MacroKeywordDefinition, FuncKeywordDefinition, Vocabulary, Schema, SchemaObject, AnySchemaObject, AsyncSchema, AnySchema, ValidateFunction, AsyncValidateFunction, AnyValidateFunction, ErrorObject, ErrorNoParams, } from "./types";
2export { SchemaCxt, SchemaObjCxt } from "./compile";
3export interface Plugin<Opts> {
4 (ajv: Ajv, options?: Opts): Ajv;
5 [prop: string]: any;
6}
7export { KeywordCxt } from "./compile/validate";
8export { DefinedError } from "./vocabularies/errors";
9export { JSONType } from "./compile/rules";
10export { JSONSchemaType } from "./types/json-schema";
11export { JTDSchemaType, SomeJTDSchemaType, JTDDataType } from "./types/jtd-schema";
12export { _, str, stringify, nil, Name, Code, CodeGen, CodeGenOptions } from "./compile/codegen";
13import type { Schema, AnySchema, AnySchemaObject, SchemaObject, AsyncSchema, Vocabulary, KeywordDefinition, AddedKeywordDefinition, AnyValidateFunction, ValidateFunction, AsyncValidateFunction, ErrorObject, Format, AddedFormat } from "./types";
14import type { JSONSchemaType } from "./types/json-schema";
15import type { JTDSchemaType, SomeJTDSchemaType, JTDDataType } from "./types/jtd-schema";
16import ValidationError from "./runtime/validation_error";
17import MissingRefError from "./compile/ref_error";
18import { ValidationRules } from "./compile/rules";
19import { SchemaEnv } from "./compile";
20import { Code, ValueScope } from "./compile/codegen";
21export declare type Options = CurrentOptions & DeprecatedOptions;
22export interface CurrentOptions {
23 strict?: boolean | "log";
24 strictSchema?: boolean | "log";
25 strictNumbers?: boolean | "log";
26 strictTypes?: boolean | "log";
27 strictTuples?: boolean | "log";
28 strictRequired?: boolean | "log";
29 allowMatchingProperties?: boolean;
30 allowUnionTypes?: boolean;
31 validateFormats?: boolean;
32 $data?: boolean;
33 allErrors?: boolean;
34 verbose?: boolean;
35 discriminator?: boolean;
36 unicodeRegExp?: boolean;
37 timestamp?: "string" | "date";
38 parseDate?: boolean;
39 allowDate?: boolean;
40 $comment?: true | ((comment: string, schemaPath?: string, rootSchema?: AnySchemaObject) => unknown);
41 formats?: {
42 [Name in string]?: Format;
43 };
44 keywords?: Vocabulary;
45 schemas?: AnySchema[] | {
46 [Key in string]?: AnySchema;
47 };
48 logger?: Logger | false;
49 loadSchema?: (uri: string) => Promise<AnySchemaObject>;
50 removeAdditional?: boolean | "all" | "failing";
51 useDefaults?: boolean | "empty";
52 coerceTypes?: boolean | "array";
53 next?: boolean;
54 unevaluated?: boolean;
55 dynamicRef?: boolean;
56 schemaId?: "id" | "$id";
57 jtd?: boolean;
58 meta?: SchemaObject | boolean;
59 defaultMeta?: string | AnySchemaObject;
60 validateSchema?: boolean | "log";
61 addUsedSchema?: boolean;
62 inlineRefs?: boolean | number;
63 passContext?: boolean;
64 loopRequired?: number;
65 loopEnum?: number;
66 ownProperties?: boolean;
67 multipleOfPrecision?: number;
68 int32range?: boolean;
69 messages?: boolean;
70 code?: CodeOptions;
71}
72export interface CodeOptions {
73 es5?: boolean;
74 lines?: boolean;
75 optimize?: boolean | number;
76 formats?: Code;
77 source?: boolean;
78 process?: (code: string, schema?: SchemaEnv) => string;
79}
80interface InstanceCodeOptions extends CodeOptions {
81 optimize: number;
82}
83interface DeprecatedOptions {
84 /** @deprecated */
85 ignoreKeywordsWithRef?: boolean;
86 /** @deprecated */
87 jsPropertySyntax?: boolean;
88 /** @deprecated */
89 unicode?: boolean;
90}
91declare type RequiredInstanceOptions = {
92 [K in "strictSchema" | "strictNumbers" | "strictTypes" | "strictTuples" | "strictRequired" | "inlineRefs" | "loopRequired" | "loopEnum" | "meta" | "messages" | "schemaId" | "addUsedSchema" | "validateSchema" | "validateFormats" | "int32range" | "unicodeRegExp"]: NonNullable<Options[K]>;
93} & {
94 code: InstanceCodeOptions;
95};
96export declare type InstanceOptions = Options & RequiredInstanceOptions;
97export interface Logger {
98 log(...args: unknown[]): unknown;
99 warn(...args: unknown[]): unknown;
100 error(...args: unknown[]): unknown;
101}
102export default class Ajv {
103 opts: InstanceOptions;
104 errors?: ErrorObject[] | null;
105 logger: Logger;
106 readonly scope: ValueScope;
107 readonly schemas: {
108 [Key in string]?: SchemaEnv;
109 };
110 readonly refs: {
111 [Ref in string]?: SchemaEnv | string;
112 };
113 readonly formats: {
114 [Name in string]?: AddedFormat;
115 };
116 readonly RULES: ValidationRules;
117 readonly _compilations: Set<SchemaEnv>;
118 private readonly _loading;
119 private readonly _cache;
120 private readonly _metaOpts;
121 static ValidationError: typeof ValidationError;
122 static MissingRefError: typeof MissingRefError;
123 constructor(opts?: Options);
124 _addVocabularies(): void;
125 _addDefaultMetaSchema(): void;
126 defaultMeta(): string | AnySchemaObject | undefined;
127 validate(schema: Schema | string, data: unknown): boolean;
128 validate(schemaKeyRef: AnySchema | string, data: unknown): boolean | Promise<unknown>;
129 validate<T>(schema: Schema | JSONSchemaType<T> | string, data: unknown): data is T;
130 validate<T>(schema: JTDSchemaType<T>, data: unknown): data is T;
131 validate<N extends never, T extends SomeJTDSchemaType>(schema: T, data: unknown): data is JTDDataType<T>;
132 validate<T>(schema: AsyncSchema, data: unknown | T): Promise<T>;
133 validate<T>(schemaKeyRef: AnySchema | string, data: unknown): data is T | Promise<T>;
134 compile<T = unknown>(schema: Schema | JSONSchemaType<T>, _meta?: boolean): ValidateFunction<T>;
135 compile<T = unknown>(schema: JTDSchemaType<T>, _meta?: boolean): ValidateFunction<T>;
136 compile<N extends never, T extends SomeJTDSchemaType>(schema: T, _meta?: boolean): ValidateFunction<JTDDataType<T>>;
137 compile<T = unknown>(schema: AsyncSchema, _meta?: boolean): AsyncValidateFunction<T>;
138 compile<T = unknown>(schema: AnySchema, _meta?: boolean): AnyValidateFunction<T>;
139 compileAsync<T = unknown>(schema: SchemaObject | JSONSchemaType<T>, _meta?: boolean): Promise<ValidateFunction<T>>;
140 compileAsync<T = unknown>(schema: JTDSchemaType<T>, _meta?: boolean): Promise<ValidateFunction<T>>;
141 compileAsync<T = unknown>(schema: AsyncSchema, meta?: boolean): Promise<AsyncValidateFunction<T>>;
142 compileAsync<T = unknown>(schema: AnySchemaObject, meta?: boolean): Promise<AnyValidateFunction<T>>;
143 addSchema(schema: AnySchema | AnySchema[], // If array is passed, `key` will be ignored
144 key?: string, // Optional schema key. Can be passed to `validate` method instead of schema object or id/ref. One schema per instance can have empty `id` and `key`.
145 _meta?: boolean, // true if schema is a meta-schema. Used internally, addMetaSchema should be used instead.
146 _validateSchema?: boolean | "log"): Ajv;
147 addMetaSchema(schema: AnySchemaObject, key?: string, // schema key
148 _validateSchema?: boolean | "log"): Ajv;
149 validateSchema(schema: AnySchema, throwOrLogError?: boolean): boolean | Promise<unknown>;
150 getSchema<T = unknown>(keyRef: string): AnyValidateFunction<T> | undefined;
151 removeSchema(schemaKeyRef?: AnySchema | string | RegExp): Ajv;
152 addVocabulary(definitions: Vocabulary): Ajv;
153 addKeyword(kwdOrDef: string | KeywordDefinition, def?: KeywordDefinition): Ajv;
154 getKeyword(keyword: string): AddedKeywordDefinition | boolean;
155 removeKeyword(keyword: string): Ajv;
156 addFormat(name: string, format: Format): Ajv;
157 errorsText(errors?: ErrorObject[] | null | undefined, // optional array of validation errors
158 { separator, dataVar }?: ErrorsTextOptions): string;
159 $dataMetaSchema(metaSchema: AnySchemaObject, keywordsJsonPointers: string[]): AnySchemaObject;
160 private _removeAllSchemas;
161 _addSchema(schema: AnySchema, meta?: boolean, baseId?: string, validateSchema?: boolean | "log", addSchema?: boolean): SchemaEnv;
162 private _checkUnique;
163 private _compileSchemaEnv;
164 private _compileMetaSchema;
165}
166export interface ErrorsTextOptions {
167 separator?: string;
168 dataVar?: string;
169}
Note: See TracBrowser for help on using the repository browser.