ajv/lib/ajv.d.ts

146 lines
3.5 KiB
TypeScript
Raw Normal View History

2016-04-15 22:20:35 +03:00
declare function ajv (options?: ajv.Options): ajv.Ajv;
declare namespace ajv {
interface Ajv {
compile(schema: Object): ValidateFunction;
compileAsync(schema: Object, cb: (err: any, validate: ValidateFunction) => any): void;
validate(schema: Object | string, data: any): boolean;
addSchema(schema: Array<Object> | Object, key?: string): void;
addMetaSchema(schema: Object, key?: string): void;
validateSchema(schema: Object): boolean;
getSchema(key: string): ValidateFunction;
2016-04-17 21:37:40 +03:00
removeSchema(schema: Object|string|RegExp);
addFormat(name: string, format: string|RegExp|Function|Object): void;
2016-04-15 22:20:35 +03:00
addKeyword(keyword: string, definition: Object): void;
2016-04-17 21:37:40 +03:00
errorsText(errors?: Array<ErrorObject>, options?: ErrorsTextOptions);
2016-04-15 22:20:35 +03:00
}
interface ValidateFunction {
(data: Object | string): boolean;
errors?: Array<ErrorObject>;
}
interface Options {
2016-04-17 21:37:40 +03:00
v5?: boolean;
2016-04-15 22:20:35 +03:00
allErrors?: boolean;
verbose?: boolean;
2016-04-17 21:37:40 +03:00
jsonPointers?: boolean;
uniqueItems?: boolean;
unicode?: boolean;
2016-04-15 22:20:35 +03:00
format?: string;
formats?: Object;
2016-04-17 21:37:40 +03:00
schemas?: Array<Object> | Object;
missingRefs?: boolean | string;
loadSchema?: (uri, cb: (err, schema) => any) => any;
removeAdditional?: boolean | string;
useDefaults?: boolean | string;
coerceTypes?: boolean;
async?: boolean | string;
transpile?: string | (code: string) => string;
meta?: boolean | Object;
validateSchema?: boolean | string;
2016-04-15 22:20:35 +03:00
addUsedSchema?: boolean;
2016-04-17 21:37:40 +03:00
inlineRefs?: boolean | number;
passContext?: boolean;
2016-04-15 22:20:35 +03:00
loopRequired?: number;
2016-04-17 21:37:40 +03:00
multipleOfPrecision?: number;
2016-04-15 22:20:35 +03:00
errorDataPath?: string;
messages?: boolean;
2016-04-17 21:37:40 +03:00
beautify?: boolean | Object;
cache?: Object;
2016-04-15 22:20:35 +03:00
}
2016-04-17 21:37:40 +03:00
interface ErrorsTextOptions {
2016-04-15 22:20:35 +03:00
separator?: string;
dataVar?: string;
}
interface ErrorObject {
keyword: string;
dataPath: string;
schemaPath: string;
params: ErrorParameters;
// Excluded if messages set to false.
message?: string;
// These are added with the `verbose` option.
schema?: Object;
parentSchema?: Object;
2016-04-17 21:37:40 +03:00
data?: any;
2016-04-15 22:20:35 +03:00
}
interface ErrorParameters {
maxItems?: MinMaxParam;
minItems?: MinMaxParam;
maxLength?: MinMaxParam;
minLength?: MinMaxParam;
maxProperties?: MinMaxParam;
minProperties?: MinMaxParam;
additionalItems?: MinMaxParam;
additionalProperties?: AdditionalPropertyParam;
patternGroups?: PatternGroup[];
dependencies?: Dependency[];
format?: Object;
maximum?: MaximumMinimumParam;
minimum?: MaximumMinimumParam;
multipleOf?: MultipleOfParam;
pattern?: PatternParam;
required?: RequiredParam;
type?: TypeParam;
uniqueItems?: UniqueItemsParam;
$ref?: RefParam;
}
interface MinMaxParam {
limit: number;
}
interface AdditionalPropertyParam {
additionalProperty: string;
}
interface PatternGroup {
pattern: string;
reason: string;
limit: number;
}
interface Dependency {
property: string;
missingProperty: string;
deps: string;
depsCount: number;
}
interface MaximumMinimumParam {
limit: number;
exclusive: boolean;
comparison: string;
}
interface MultipleOfParam {
multipleOf: Object;
}
interface PatternParam {
pattern: Object;
}
interface RequiredParam {
missingProperty: string;
}
interface TypeParam {
type: string;
}
interface UniqueItemsParam {
i: number;
j: number;
}
interface RefParam {
ref: string;
}
}
export = ajv;