Files
DefinitelyTyped/ajv/index.d.ts
Kanchalai Tanglertsampan 1200f753d6 Merge branch 'master' into types-2.0
# Conflicts:
#	.gitignore
#	ajv/ajv.d.ts
#	angular-material/angular-material.d.ts
#	angular-protractor/angular-protractor.d.ts
#	angularjs/angular-tests.ts
#	angularjs/angular.d.ts
#	aws-sdk/aws-sdk.d.ts
#	electron-devtools-installer/electron-devtools-installer-tests.ts
#	electron-json-storage/electron-json-storage-tests.ts
#	electron-notifications/electron-notifications.d.ts
#	electron-notify/electron-notify.d.ts
#	electron-window-state/electron-window-state.d.ts
#	electron/electron-prebuilt.d.ts
#	enzyme/enzyme.d.ts
#	eventemitter3/eventemitter3-tests.ts
#	eventemitter3/eventemitter3.d.ts
#	graphql/graphql.d.ts
#	highcharts/highcharts.d.ts
#	immutable/immutable.d.ts
#	inquirer/inquirer.d.ts
#	jasmine/jasmine.d.ts
#	joi/joi.d.ts
#	jquery.dataTables/jquery.dataTables-tests.ts
#	jquery.dataTables/jquery.dataTables.d.ts
#	kafka-node/kafka-node.d.ts
#	kefir/kefir.d.ts
#	kendo-ui/kendo-ui.d.ts
#	koa/koa.d.ts
#	leaflet/leaflet.d.ts
#	lodash/lodash.d.ts
#	mapbox-gl/mapbox-gl.d.ts
#	material-ui/material-ui.d.ts
#	menubar/menubar.d.ts
#	mongodb/mongodb.d.ts
#	needle/needle-tests.ts
#	needle/needle.d.ts
#	noble/noble.d.ts
#	node/node.d.ts
#	pegjs/pegjs.d.ts
#	pixi.js/pixi.js.d.ts
#	polymer/polymer.d.ts
#	quill/quill-tests.ts
#	quill/quill.d.ts
#	react-bootstrap/react-bootstrap.d.ts
#	react-fa/react-fa-tests.tsx
#	react-fa/react-fa.d.ts
#	react-native/react-native.d.ts
#	react-select/react-select.d.ts
#	react/react.d.ts
#	threejs/three-vrcontrols.d.ts
#	threejs/three-vreffect.d.ts
#	toastr/toastr.d.ts
#	validator/validator.d.ts
#	webpack/webpack.d.ts
#	winston/winston.d.ts
2016-11-09 17:20:41 -08:00

113 lines
3.9 KiB
TypeScript

// Type definitions for ajv
// Project: https://github.com/epoberezkin/ajv
// Definitions by: York Yao <https://github.com/plantain-00/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare class Ajv {
/**
* Create Ajv instance.
*/
constructor(options?: Ajv.AjvOptions);
/**
* Generate validating function and cache the compiled schema for future use.
*/
compile(schema: any): Ajv.AjvValidate;
/**
* Asyncronous version of compile method that loads missing remote schemas using asynchronous function in options.loadSchema.
*/
compileAsync(schema: any, callback: (error: Error, validate: Ajv.AjvValidate) => void): void;
/**
* Validate data using passed schema (it will be compiled and cached).
*/
validate(schema: any, data: any): boolean | PromiseLike<boolean>;
errors: Ajv.ValidationError[];
/**
* Add schema(s) to validator instance.
*/
addSchema(schema: any, key: string): void;
/**
* Adds meta schema(s) that can be used to validate other schemas.
* That function should be used instead of addSchema because there may be instance options that would compile a meta schema incorrectly (at the moment it is removeAdditional option).
*/
addMetaSchema(schema: any, key: string): void;
/**
* Validates schema.
* This method should be used to validate schemas rather than validate due to the inconsistency of uri format in JSON-Schema standard.
*/
validateSchema(schema: any): Boolean;
/**
* Retrieve compiled schema previously added with addSchema by the key passed to addSchema or by its full reference (id).
* Returned validating function has schema property with the reference to the original schema.
*/
getSchema(key: string): Ajv.AjvValidate;
/**
* Remove added/cached schema.
* Even if schema is referenced by other schemas it can be safely removed as dependent schemas have local references.
*/
removeSchema(schema: any): void;
/**
* Add custom format to validate strings. It can also be used to replace pre-defined formats for Ajv instance.
*/
addFormat(name: string, format: any): void;
/**
* Add custom validation keyword to Ajv instance.
*/
addKeyword(keyword: string, definition: Ajv.AjxKeywordDefinition): void;
errorsText(): any;
static ValidationError: Function;
}
declare namespace Ajv {
type AjvOptions = {
v5?: boolean;
allErrors?: boolean;
verbose?: boolean;
jsonPointers?: boolean;
uniqueItems?: boolean;
unicode?: boolean;
format?: string;
formats?: any;
schemas?: any;
missingRefs?: boolean;
loadSchema?(uri: string, callback: (error: Error, body: any) => void): void;
removeAdditional?: boolean;
useDefaults?: boolean;
coerceTypes?: boolean;
async?: any;
transpile?: string;
meta?: boolean;
validateSchema?: boolean;
addUsedSchema?: boolean;
inlineRefs?: boolean;
passContext?: boolean;
loopRequired?: number;
ownProperties?: boolean;
multipleOfPrecision?: boolean | number;
errorDataPath?: string,
messages?: boolean;
beautify?: boolean;
cache?: any;
}
type AjvValidate = ((data: any) => boolean | PromiseLike<boolean>) & {
errors: ValidationError[];
}
type AjxKeywordDefinition = {
async?: boolean;
type: string;
compile?: (schema: any, parentsSchema: any) => ((data: any) => boolean | PromiseLike<boolean>);
validate?: (schema: any, data: any) => boolean;
}
type ValidationError = {
keyword: string;
dataPath: string;
schemaPath: string;
params: any;
message: string;
schema: any;
parentSchema: any;
data: any;
}
}
export = Ajv;