|
| 1 | +// Type definitions for ajv v3.4.0 |
| 2 | +// Project: https://github.com/epoberezkin/ajv |
| 3 | +// Definitions by: Rich Adams <https://github.com/enriched> |
| 4 | +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped |
| 5 | + |
| 6 | +declare module ajv { |
| 7 | + interface AjvStatic { |
| 8 | + (options?: AjvOptions): AjvInstance; |
| 9 | + } |
| 10 | + |
| 11 | + interface AjvInstance { |
| 12 | + compile(schema: Object): ValidationFunction; |
| 13 | + compileAsync(schema: Object, cb: (err: any, validate: ValidationFunction) => any): void; |
| 14 | + validate(schema: Object|string, data: any): boolean; |
| 15 | + addSchema(schema: Array<Object>|Object, key?: string): void; |
| 16 | + addMetaSchema(schema: Object, key?: string): void; |
| 17 | + validateSchema(schema: Object): boolean; |
| 18 | + getSchema(key: string): ValidationFunction; |
| 19 | + removeSchema(schema: Object|string); |
| 20 | + addFormat(name: string, format: RegExp|Function|Object|string): void; |
| 21 | + addKeyword(keyword: string, definition: Object): void; |
| 22 | + errorsText(errors?: Array<Object>, options?: Object); |
| 23 | + } |
| 24 | + |
| 25 | + interface ValidationFunction { |
| 26 | + (data: Object|string): boolean; |
| 27 | + errors?: Array<ErrorObject>; |
| 28 | + } |
| 29 | + |
| 30 | + interface AjvOptions { |
| 31 | + allErrors?: boolean; |
| 32 | + removeAdditional?: boolean; |
| 33 | + useDefaults?: boolean; |
| 34 | + coerceTypes?: boolean; |
| 35 | + verbose?: boolean; |
| 36 | + format?: string; |
| 37 | + formats?: Object; |
| 38 | + schemas?: Object; |
| 39 | + meta?: boolean; |
| 40 | + validateSchema?: boolean; |
| 41 | + addUsedSchema?: boolean; |
| 42 | + inlineRefs?: boolean; |
| 43 | + loopRequired?: number; |
| 44 | + multipleOfPrecision?: boolean; |
| 45 | + missingRefs?: boolean; |
| 46 | + loadSchema?: (uri, cb: (err, schema) => any) => any; |
| 47 | + uniqueItems?: boolean; |
| 48 | + unicode?: boolean; |
| 49 | + beautify?: boolean; |
| 50 | + cache?: any; |
| 51 | + errorDataPath?: string; |
| 52 | + jsonPointers?: boolean; |
| 53 | + messages?: boolean; |
| 54 | + v5?: boolean; |
| 55 | + } |
| 56 | + |
| 57 | + interface ErrorsOptions { |
| 58 | + separator?: string; |
| 59 | + dataVar?: string; |
| 60 | + } |
| 61 | + |
| 62 | + interface ErrorObject { |
| 63 | + keyword: string; |
| 64 | + dataPath: string; |
| 65 | + schemaPath: string; |
| 66 | + params: ErrorParameters; |
| 67 | + // Excluded if messages set to false |
| 68 | + message?: string; |
| 69 | + // These added with verbose option |
| 70 | + schema?: Object; |
| 71 | + parentSchema?: Object; |
| 72 | + data: Object; |
| 73 | + } |
| 74 | + |
| 75 | + interface ErrorParameters { |
| 76 | + maxItems?: MinMaxParam; |
| 77 | + minItems?: MinMaxParam; |
| 78 | + maxLength?: MinMaxParam; |
| 79 | + minLength?: MinMaxParam; |
| 80 | + maxProperties?: MinMaxParam; |
| 81 | + minProperties?: MinMaxParam; |
| 82 | + additionalItems?: MinMaxParam; |
| 83 | + additionalProperties: AdditionalPropertyParam; |
| 84 | + patternGroups: PatternGroup[]; |
| 85 | + dependencies: Dependency[]; |
| 86 | + format: Object; |
| 87 | + maximum: MaximumMinimumParam; |
| 88 | + minimum: MaximumMinimumParam; |
| 89 | + multipleOf: MultipleOfParam; |
| 90 | + pattern: PatternParam; |
| 91 | + required: RequiredParam; |
| 92 | + type: TypeParam; |
| 93 | + uniqueItems: UniqueItemsParam; |
| 94 | + $ref: RefParam; |
| 95 | + } |
| 96 | + |
| 97 | + interface MinMaxParam { |
| 98 | + limit: number; |
| 99 | + } |
| 100 | + |
| 101 | + interface AdditionalPropertyParam { |
| 102 | + additionalProperty: string; |
| 103 | + } |
| 104 | + |
| 105 | + interface PatternGroup { |
| 106 | + pattern: string; |
| 107 | + reason: string; |
| 108 | + limit: number; |
| 109 | + } |
| 110 | + |
| 111 | + interface Dependency { |
| 112 | + property: string; |
| 113 | + missingProperty: string; |
| 114 | + deps: string; |
| 115 | + depsCount: number; |
| 116 | + } |
| 117 | + |
| 118 | + interface MaximumMinimumParam { |
| 119 | + limit: number; |
| 120 | + exclusive: boolean; |
| 121 | + comparison: string; |
| 122 | + } |
| 123 | + |
| 124 | + interface MultipleOfParam { |
| 125 | + multipleOf: Object; |
| 126 | + } |
| 127 | + |
| 128 | + interface PatternParam { |
| 129 | + pattern: Object; |
| 130 | + } |
| 131 | + |
| 132 | + interface RequiredParam { |
| 133 | + missingProperty: string; |
| 134 | + } |
| 135 | + |
| 136 | + interface TypeParam { |
| 137 | + type: string; |
| 138 | + } |
| 139 | + |
| 140 | + interface UniqueItemsParam { |
| 141 | + i: number; |
| 142 | + j: number; |
| 143 | + } |
| 144 | + interface RefParam { |
| 145 | + ref: string; |
| 146 | + } |
| 147 | +} |
| 148 | + |
| 149 | +export = ajv; |
0 commit comments