123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397 |
- declare var ajv: {
- (options?: ajv.Options): ajv.Ajv;
- new(options?: ajv.Options): ajv.Ajv;
- ValidationError: typeof AjvErrors.ValidationError;
- MissingRefError: typeof AjvErrors.MissingRefError;
- $dataMetaSchema: object;
- }
- declare namespace AjvErrors {
- class ValidationError extends Error {
- constructor(errors: Array<ajv.ErrorObject>);
- message: string;
- errors: Array<ajv.ErrorObject>;
- ajv: true;
- validation: true;
- }
- class MissingRefError extends Error {
- constructor(baseId: string, ref: string, message?: string);
- static message: (baseId: string, ref: string) => string;
- message: string;
- missingRef: string;
- missingSchema: string;
- }
- }
- declare namespace ajv {
- type ValidationError = AjvErrors.ValidationError;
- type MissingRefError = AjvErrors.MissingRefError;
- interface Ajv {
-
- validate(schemaKeyRef: object | string | boolean, data: any): boolean | PromiseLike<any>;
-
- compile(schema: object | boolean): ValidateFunction;
-
- compileAsync(schema: object | boolean, meta?: Boolean, callback?: (err: Error, validate: ValidateFunction) => any): PromiseLike<ValidateFunction>;
-
- addSchema(schema: Array<object> | object, key?: string): Ajv;
-
- addMetaSchema(schema: object, key?: string): Ajv;
-
- validateSchema(schema: object | boolean): boolean;
-
- getSchema(keyRef: string): ValidateFunction | undefined;
-
- removeSchema(schemaKeyRef?: object | string | RegExp | boolean): Ajv;
-
- addFormat(name: string, format: FormatValidator | FormatDefinition): Ajv;
-
- addKeyword(keyword: string, definition: KeywordDefinition): Ajv;
-
- getKeyword(keyword: string): object | boolean;
-
- removeKeyword(keyword: string): Ajv;
-
- validateKeyword(definition: KeywordDefinition, throwError: boolean): boolean;
-
- errorsText(errors?: Array<ErrorObject> | null, options?: ErrorsTextOptions): string;
- errors?: Array<ErrorObject> | null;
- _opts: Options;
- }
- interface CustomLogger {
- log(...args: any[]): any;
- warn(...args: any[]): any;
- error(...args: any[]): any;
- }
- interface ValidateFunction {
- (
- data: any,
- dataPath?: string,
- parentData?: object | Array<any>,
- parentDataProperty?: string | number,
- rootData?: object | Array<any>
- ): boolean | PromiseLike<any>;
- schema?: object | boolean;
- errors?: null | Array<ErrorObject>;
- refs?: object;
- refVal?: Array<any>;
- root?: ValidateFunction | object;
- $async?: true;
- source?: object;
- }
- interface Options {
- $data?: boolean;
- allErrors?: boolean;
- verbose?: boolean;
- jsonPointers?: boolean;
- uniqueItems?: boolean;
- unicode?: boolean;
- format?: false | string;
- formats?: object;
- keywords?: object;
- unknownFormats?: true | string[] | 'ignore';
- schemas?: Array<object> | object;
- schemaId?: '$id' | 'id' | 'auto';
- missingRefs?: true | 'ignore' | 'fail';
- extendRefs?: true | 'ignore' | 'fail';
- loadSchema?: (uri: string, cb?: (err: Error, schema: object) => void) => PromiseLike<object | boolean>;
- removeAdditional?: boolean | 'all' | 'failing';
- useDefaults?: boolean | 'empty' | 'shared';
- coerceTypes?: boolean | 'array';
- strictDefaults?: boolean | 'log';
- strictKeywords?: boolean | 'log';
- strictNumbers?: boolean;
- async?: boolean | string;
- transpile?: string | ((code: string) => string);
- meta?: boolean | object;
- validateSchema?: boolean | 'log';
- addUsedSchema?: boolean;
- inlineRefs?: boolean | number;
- passContext?: boolean;
- loopRequired?: number;
- ownProperties?: boolean;
- multipleOfPrecision?: boolean | number;
- errorDataPath?: string,
- messages?: boolean;
- sourceCode?: boolean;
- processCode?: (code: string, schema: object) => string;
- cache?: object;
- logger?: CustomLogger | false;
- nullable?: boolean;
- serialize?: ((schema: object | boolean) => any) | false;
- }
- type FormatValidator = string | RegExp | ((data: string) => boolean | PromiseLike<any>);
- type NumberFormatValidator = ((data: number) => boolean | PromiseLike<any>);
- interface NumberFormatDefinition {
- type: "number",
- validate: NumberFormatValidator;
- compare?: (data1: number, data2: number) => number;
- async?: boolean;
- }
- interface StringFormatDefinition {
- type?: "string",
- validate: FormatValidator;
- compare?: (data1: string, data2: string) => number;
- async?: boolean;
- }
- type FormatDefinition = NumberFormatDefinition | StringFormatDefinition;
- interface KeywordDefinition {
- type?: string | Array<string>;
- async?: boolean;
- $data?: boolean;
- errors?: boolean | string;
- metaSchema?: object;
-
- schema?: boolean;
- statements?: boolean;
- dependencies?: Array<string>;
- modifying?: boolean;
- valid?: boolean;
-
- validate?: SchemaValidateFunction | ValidateFunction;
- compile?: (schema: any, parentSchema: object, it: CompilationContext) => ValidateFunction;
- macro?: (schema: any, parentSchema: object, it: CompilationContext) => object | boolean;
- inline?: (it: CompilationContext, keyword: string, schema: any, parentSchema: object) => string;
- }
- interface CompilationContext {
- level: number;
- dataLevel: number;
- dataPathArr: string[];
- schema: any;
- schemaPath: string;
- baseId: string;
- async: boolean;
- opts: Options;
- formats: {
- [index: string]: FormatDefinition | undefined;
- };
- keywords: {
- [index: string]: KeywordDefinition | undefined;
- };
- compositeRule: boolean;
- validate: (schema: object) => boolean;
- util: {
- copy(obj: any, target?: any): any;
- toHash(source: string[]): { [index: string]: true | undefined };
- equal(obj: any, target: any): boolean;
- getProperty(str: string): string;
- schemaHasRules(schema: object, rules: any): string;
- escapeQuotes(str: string): string;
- toQuotedString(str: string): string;
- getData(jsonPointer: string, dataLevel: number, paths: string[]): string;
- escapeJsonPointer(str: string): string;
- unescapeJsonPointer(str: string): string;
- escapeFragment(str: string): string;
- unescapeFragment(str: string): string;
- };
- self: Ajv;
- }
- interface SchemaValidateFunction {
- (
- schema: any,
- data: any,
- parentSchema?: object,
- dataPath?: string,
- parentData?: object | Array<any>,
- parentDataProperty?: string | number,
- rootData?: object | Array<any>
- ): boolean | PromiseLike<any>;
- errors?: Array<ErrorObject>;
- }
- interface ErrorsTextOptions {
- separator?: string;
- dataVar?: string;
- }
- interface ErrorObject {
- keyword: string;
- dataPath: string;
- schemaPath: string;
- params: ErrorParameters;
-
- propertyName?: string;
-
- message?: string;
-
- schema?: any;
- parentSchema?: object;
- data?: any;
- }
- type ErrorParameters = RefParams | LimitParams | AdditionalPropertiesParams |
- DependenciesParams | FormatParams | ComparisonParams |
- MultipleOfParams | PatternParams | RequiredParams |
- TypeParams | UniqueItemsParams | CustomParams |
- PatternRequiredParams | PropertyNamesParams |
- IfParams | SwitchParams | NoParams | EnumParams;
- interface RefParams {
- ref: string;
- }
- interface LimitParams {
- limit: number;
- }
- interface AdditionalPropertiesParams {
- additionalProperty: string;
- }
- interface DependenciesParams {
- property: string;
- missingProperty: string;
- depsCount: number;
- deps: string;
- }
- interface FormatParams {
- format: string
- }
- interface ComparisonParams {
- comparison: string;
- limit: number | string;
- exclusive: boolean;
- }
- interface MultipleOfParams {
- multipleOf: number;
- }
- interface PatternParams {
- pattern: string;
- }
- interface RequiredParams {
- missingProperty: string;
- }
- interface TypeParams {
- type: string;
- }
- interface UniqueItemsParams {
- i: number;
- j: number;
- }
- interface CustomParams {
- keyword: string;
- }
- interface PatternRequiredParams {
- missingPattern: string;
- }
- interface PropertyNamesParams {
- propertyName: string;
- }
- interface IfParams {
- failingKeyword: string;
- }
- interface SwitchParams {
- caseIndex: number;
- }
- interface NoParams { }
- interface EnumParams {
- allowedValues: Array<any>;
- }
- }
- export = ajv;
|