123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- declare var ajv: {
- (options?: ajv.Options): ajv.Ajv;
- new (options?: ajv.Options): ajv.Ajv;
- }
- declare namespace ajv {
- interface Ajv {
-
- validate(schemaKeyRef: Object | string, data: any): boolean;
-
- compile(schema: Object): ValidateFunction;
-
- compileAsync(schema: Object, callback: (err: Error, validate: ValidateFunction) => any): void;
-
- addSchema(schema: Array<Object> | Object, key?: string): void;
-
- addMetaSchema(schema: Object, key?: string): void;
-
- validateSchema(schema: Object): boolean;
-
- getSchema(keyRef: string): ValidateFunction;
-
- removeSchema(schemaKeyRef?: Object | string | RegExp): void;
-
- addFormat(name: string, format: FormatValidator | FormatDefinition): void;
-
- addKeyword(keyword: string, definition: KeywordDefinition): void;
-
- getKeyword(keyword: string): Object | boolean;
-
- removeKeyword(keyword: string): void;
-
- errorsText(errors?: Array<ErrorObject>, options?: ErrorsTextOptions): string;
- errors?: Array<ErrorObject>;
- }
- interface Thenable <R> {
- then <U> (onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;
- }
- interface ValidateFunction {
- (
- data: any,
- dataPath?: string,
- parentData?: Object | Array<any>,
- parentDataProperty?: string | number,
- rootData?: Object | Array<any>
- ): boolean | Thenable<boolean>;
- errors?: Array<ErrorObject>;
- schema?: Object;
- }
- interface Options {
- v5?: boolean;
- allErrors?: boolean;
- verbose?: boolean;
- jsonPointers?: boolean;
- uniqueItems?: boolean;
- unicode?: boolean;
- format?: string;
- formats?: Object;
- unknownFormats?: boolean | string | Array<string>;
- schemas?: Array<Object> | Object;
- ownProperties?: boolean;
- missingRefs?: boolean | string;
- extendRefs?: boolean | string;
- loadSchema?: (uri: string, cb: (err: Error, schema: Object) => any) => any;
- removeAdditional?: boolean | string;
- useDefaults?: boolean | string;
- coerceTypes?: boolean | string;
- async?: boolean | string;
- transpile?: string | ((code: string) => string);
- meta?: boolean | Object;
- validateSchema?: boolean | string;
- addUsedSchema?: boolean;
- inlineRefs?: boolean | number;
- passContext?: boolean;
- loopRequired?: number;
- multipleOfPrecision?: number;
- errorDataPath?: string;
- messages?: boolean;
- sourceCode?: boolean;
- beautify?: boolean | Object;
- cache?: Object;
- }
- type FormatValidator = string | RegExp | ((data: string) => boolean);
- interface FormatDefinition {
- validate: FormatValidator;
- compare: (data1: string, data2: string) => number;
- async?: boolean;
- }
- interface KeywordDefinition {
- type?: string | Array<string>;
- async?: boolean;
- errors?: boolean | string;
-
- schema?: boolean;
- modifying?: boolean;
- valid?: boolean;
-
- validate?: ValidateFunction | SchemaValidateFunction;
- compile?: (schema: Object, parentSchema: Object) => ValidateFunction;
- macro?: (schema: Object, parentSchema: Object) => Object;
- inline?: (it: Object, keyword: string, schema: Object, parentSchema: Object) => string;
- }
- interface SchemaValidateFunction {
- (
- schema: Object,
- data: any,
- parentSchema?: Object,
- dataPath?: string,
- parentData?: Object | Array<any>,
- parentDataProperty?: string | number
- ): boolean | Thenable<boolean>;
- errors?: Array<ErrorObject>;
- }
- interface ErrorsTextOptions {
- separator?: string;
- dataVar?: string;
- }
- interface ErrorObject {
- keyword: string;
- dataPath: string;
- schemaPath: string;
- params: ErrorParameters;
-
- message?: string;
-
- schema?: Object;
- parentSchema?: Object;
- data?: any;
- }
- type ErrorParameters = RefParams | LimitParams | AdditionalPropertiesParams |
- DependenciesParams | FormatParams | ComparisonParams |
- MultipleOfParams | PatternParams | RequiredParams |
- TypeParams | UniqueItemsParams | CustomParams |
- PatternGroupsParams | PatternRequiredParams |
- 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 PatternGroupsParams {
- reason: string;
- limit: number;
- pattern: string;
- }
- interface PatternRequiredParams {
- missingPattern: string;
- }
- interface SwitchParams {
- caseIndex: number;
- }
- interface NoParams {}
- interface EnumParams {
- allowedValues: Array<any>;
- }
- }
- export = ajv;
|