Skip to content

Instantly share code, notes, and snippets.

@goodmind
Created July 2, 2019 02:19
Show Gist options
  • Save goodmind/7b6233decb2def0597f1a0852078ab0e to your computer and use it in GitHub Desktop.
Save goodmind/7b6233decb2def0597f1a0852078ab0e to your computer and use it in GitHub Desktop.
// flow-typed signature: 4dca2d6505646485b3c4fad4c008ed4d
// flow-typed version: <<STUB>>/ajv_v6.5.4/flow_v0.81.0
/**
* This is an autogenerated libdef stub for:
*
* 'ajv'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/
declare module 'ajv' {
declare var ajv: {
(options?: ajv$Options): ajv$Ajv,
new(options?: ajv$Options): ajv$Ajv,
ValidationError: ValidationError,
MissingRefError: MissingRefError,
$dataMetaSchema: { [key: string]: any }
};
declare interface ajv$Ajv {
/**
* Validate data using schema
* Schema will be compiled and cached (using serialized JSON as key, [fast-json-stable-stringify](https://github.com/epoberezkin/fast-json-stable-stringify) is used to serialize by default).
* @param {string | {[key: string]: any} | Boolean} schemaKeyRef key, ref or schema object
* @param {Any} data to be validated
* @return {Boolean} validation result. Errors from the last validation will be available in `ajv.errors` (and also in compiled schema: `schema.errors`).
*/
validate(
schemaKeyRef: { [key: string]: any } | string | boolean,
data: any
): boolean | PromiseLike<any>;
/**
* Create validating function for passed schema.
* @param {{[key: string]: any} | Boolean} schema schema object
* @return {Function} validating function
*/
compile(schema: { [key: string]: any } | boolean): ajv$ValidateFunction;
/**
* Creates validating function for passed schema with asynchronous loading of missing schemas.
* `loadSchema` option should be a function that accepts schema uri and node-style callback.
* @this {ajv$Ajv}
* @param {{[key: string]: any} | Boolean} schema schema object
* @param {Boolean} meta optional true to compile meta-schema; this parameter can be skipped
* @param {Function} callback optional node-style callback, it is always called with 2 parameters: error (or null) and validating function.
* @return {PromiseLike<ajv$ValidateFunction>} validating function
*/
compileAsync(
schema: { [key: string]: any } | boolean,
meta?: Boolean,
callback?: (err: Error, validate: ajv$ValidateFunction) => any
): PromiseLike<ajv$ValidateFunction>;
/**
* Adds schema to the instance.
* @param {{[key: string]: any} | Array} schema schema or array of schemas. If array is passed, `key` and other parameters will be ignored.
* @param {string} key Optional schema key. Can be passed to `validate` method instead of schema object or id/ref. One schema per instance can have empty `id` and `key`.
* @return {ajv$Ajv} this for method chaining
*/
addSchema(
schema: Array<{ [key: string]: any }> | { [key: string]: any },
key?: string
): ajv$Ajv;
/**
* Add schema that will be used to validate other schemas
* options in META_IGNORE_OPTIONS are alway set to false
* @param {{[key: string]: any}} schema schema object
* @param {string} key optional schema key
* @return {ajv$Ajv} this for method chaining
*/
addMetaSchema(schema: { [key: string]: any }, key?: string): ajv$Ajv;
/**
* Validate schema
* @param {{[key: string]: any} | Boolean} schema schema to validate
* @return {Boolean} true if schema is valid
*/
validateSchema(schema: { [key: string]: any } | boolean): boolean;
/**
* Get compiled schema from the instance by `key` or `ref`.
* @param {string} keyRef `key` that was passed to `addSchema` or full schema reference (`schema.id` or resolved id).
* @return {Function} schema validating function (with property `schema`).
*/
getSchema(keyRef: string): ajv$ValidateFunction;
/**
* Remove cached schema(s).
* If no parameter is passed all schemas but meta-schemas are removed.
* If RegExp is passed all schemas with key/id matching pattern but meta-schemas are removed.
* Even if schema is referenced by other schemas it still can be removed as other schemas have local references.
* @param {string | {[key: string]: any} | RegExp | Boolean} schemaKeyRef key, ref, pattern to match key/ref or schema object
* @return {ajv$Ajv} this for method chaining
*/
removeSchema(
schemaKeyRef?: { [key: string]: any } | string | RegExp | boolean
): ajv$Ajv;
/**
* Add custom format
* @param {string} name format name
* @param {string | RegExp | Function} format string is converted to RegExp; function should return boolean (true when valid)
* @return {ajv$Ajv} this for method chaining
*/
addFormat(
name: string,
format: ajv$FormatValidator | ajv$FormatDefinition
): ajv$Ajv;
/**
* Define custom keyword
* @this {ajv$Ajv}
* @param {string} keyword custom keyword, should be a valid identifier, should be different from all standard, custom and macro keywords.
* @param {{[key: string]: any}} definition keyword definition object with properties `type` (type(s) which the keyword applies to), `validate` or `compile`.
* @return {ajv$Ajv} this for method chaining
*/
addKeyword(keyword: string, definition: ajv$KeywordDefinition): ajv$Ajv;
/**
* Get keyword definition
* @this {ajv$Ajv}
* @param {string} keyword pre-defined or custom keyword.
* @return {{[key: string]: any} | Boolean} custom keyword definition, `true` if it is a predefined keyword, `false` otherwise.
*/
getKeyword(keyword: string): { [key: string]: any } | boolean;
/**
* Remove keyword
* @this {ajv$Ajv}
* @param {string} keyword pre-defined or custom keyword.
* @return {ajv$Ajv} this for method chaining
*/
removeKeyword(keyword: string): ajv$Ajv;
/**
* Convert array of error message objects to string
* @param {Array<{[key: string]: any}>} errors optional array of validation errors, if not passed errors from the instance are used.
* @param {{[key: string]: any}} options optional options with properties `separator` and `dataVar`.
* @return {string} human readable string with all errors descriptions
*/
errorsText(
errors?: Array<ajv$ErrorObject> | null,
options?: ajv$ErrorsTextOptions
): string;
errors?: Array<ajv$ErrorObject>;
}
declare interface ajv$ValidateFunction {
(
data: any,
dataPath?: string,
parentData?: { [key: string]: any } | Array<any>,
parentDataProperty?: string | number,
rootData?: { [key: string]: any } | Array<any>
): boolean | PromiseLike<any>;
schema?: { [key: string]: any } | boolean;
errors?: null | Array<ajv$ErrorObject>;
refs?: { [key: string]: any };
refVal?: Array<any>;
root?: ajv$ValidateFunction | { [key: string]: any };
$async?: true;
source?: { [key: string]: any };
}
declare interface ajv$Options {
$data?: boolean;
allErrors?: boolean;
verbose?: boolean;
jsonPointers?: boolean;
uniqueItems?: boolean;
unicode?: boolean;
format?: string;
formats?: { [key: string]: any };
unknownFormats?: true | string[] | 'ignore';
schemas?: Array<{ [key: string]: any }> | { [key: string]: any };
schemaId?: '$id' | 'id' | 'auto';
missingRefs?: true | 'ignore' | 'fail';
extendRefs?: true | 'ignore' | 'fail';
loadSchema?: (
uri: string,
cb?: (err: Error, schema: { [key: string]: any }) => void
) => PromiseLike<{ [key: string]: any } | boolean>;
removeAdditional?: boolean | 'all' | 'failing';
useDefaults?: boolean | 'shared';
coerceTypes?: boolean | 'array';
async?: boolean | string;
transpile?: string | ((code: string) => string);
meta?: boolean | { [key: string]: any };
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) => string;
cache?: { [key: string]: any };
}
declare type ajv$FormatValidator =
| string
| RegExp
| ((data: string) => boolean | PromiseLike<any>);
declare type ajv$NumberFormatValidator = (
data: number
) => boolean | PromiseLike<any>;
declare interface ajv$NumberFormatDefinition {
type: 'number';
validate: ajv$NumberFormatValidator;
compare?: (data1: number, data2: number) => number;
async?: boolean;
}
declare interface ajv$StringFormatDefinition {
type?: 'string';
validate: ajv$FormatValidator;
compare?: (data1: string, data2: string) => number;
async?: boolean;
}
declare type ajv$FormatDefinition =
| ajv$NumberFormatDefinition
| ajv$StringFormatDefinition;
declare interface ajv$KeywordDefinition {
type?: string | Array<string>;
async?: boolean;
$data?: boolean;
errors?: boolean | string;
metaSchema?: { [key: string]: any };
schema?: boolean;
modifying?: boolean;
valid?: boolean;
validate?: ajv$SchemaValidateFunction | ajv$ValidateFunction;
compile?: (
schema: any,
parentSchema: { [key: string]: any },
it: ajv$CompilationContext
) => ajv$ValidateFunction;
macro?: (
schema: any,
parentSchema: { [key: string]: any },
it: ajv$CompilationContext
) => { [key: string]: any } | boolean;
inline?: (
it: ajv$CompilationContext,
keyword: string,
schema: any,
parentSchema: { [key: string]: any }
) => string;
}
declare interface ajv$CompilationContext {
level: number;
dataLevel: number;
schema: any;
schemaPath: string;
baseId: string;
async: boolean;
opts: ajv$Options;
formats: {
[index: string]: ajv$FormatDefinition | void
};
compositeRule: boolean;
validate: (schema: { [key: string]: any }) => boolean;
util: {
copy(obj: any, target?: any): any,
toHash(
source: string[]
): {
[index: string]: true | void
},
equal(obj: any, target: any): boolean,
getProperty(str: string): string,
schemaHasRules(schema: { [key: string]: any }, 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$Ajv;
}
declare interface ajv$SchemaValidateFunction {
(
schema: any,
data: any,
parentSchema?: { [key: string]: any },
dataPath?: string,
parentData?: { [key: string]: any } | Array<any>,
parentDataProperty?: string | number,
rootData?: { [key: string]: any } | Array<any>
): boolean | PromiseLike<any>;
errors?: Array<ajv$ErrorObject>;
}
declare interface ajv$ErrorsTextOptions {
separator?: string;
dataVar?: string;
}
declare interface ajv$ErrorObject {
keyword: string;
dataPath: string;
schemaPath: string;
params: ajv$ErrorParameters;
propertyName?: string;
message?: string;
schema?: any;
parentSchema?: { [key: string]: any };
data?: any;
}
declare type ajv$ErrorParameters =
| ajv$RefParams
| ajv$LimitParams
| ajv$AdditionalPropertiesParams
| ajv$DependenciesParams
| ajv$FormatParams
| ajv$ComparisonParams
| ajv$MultipleOfParams
| ajv$PatternParams
| ajv$RequiredParams
| ajv$TypeParams
| ajv$UniqueItemsParams
| ajv$CustomParams
| ajv$PatternRequiredParams
| ajv$PropertyNamesParams
| ajv$IfParams
| ajv$SwitchParams
| ajv$NoParams
| ajv$EnumParams;
declare interface ajv$RefParams {
ref: string;
}
declare interface ajv$LimitParams {
limit: number;
}
declare interface ajv$AdditionalPropertiesParams {
additionalProperty: string;
}
declare interface ajv$DependenciesParams {
property: string;
missingProperty: string;
depsCount: number;
deps: string;
}
declare interface ajv$FormatParams {
format: string;
}
declare interface ajv$ComparisonParams {
comparison: string;
limit: number | string;
exclusive: boolean;
}
declare interface ajv$MultipleOfParams {
multipleOf: number;
}
declare interface ajv$PatternParams {
pattern: string;
}
declare interface ajv$RequiredParams {
missingProperty: string;
}
declare interface ajv$TypeParams {
type: string;
}
declare interface ajv$UniqueItemsParams {
i: number;
j: number;
}
declare interface ajv$CustomParams {
keyword: string;
}
declare interface ajv$PatternRequiredParams {
missingPattern: string;
}
declare interface ajv$PropertyNamesParams {
propertyName: string;
}
declare interface ajv$IfParams {
failingKeyword: string;
}
declare interface ajv$SwitchParams {
caseIndex: number;
}
declare interface ajv$NoParams {}
declare interface ajv$EnumParams {
allowedValues: Array<any>;
}
declare class ValidationError mixins Error {
constructor(errors: Array<ajv$ErrorObject>): this;
message: string;
errors: Array<ajv$ErrorObject>;
ajv: true;
validation: true;
}
declare class MissingRefError mixins Error {
constructor(baseId: string, ref: string, message?: string): this;
static message: (baseId: string, ref: string) => string;
message: string;
missingRef: string;
missingSchema: string;
}
declare module.exports: typeof ajv;
}
/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module 'ajv/dist/ajv.bundle' {
declare module.exports: any;
}
declare module 'ajv/dist/ajv.min' {
declare module.exports: any;
}
declare module 'ajv/lib/ajv' {
declare module.exports: any;
}
declare module 'ajv/lib/cache' {
declare module.exports: any;
}
declare module 'ajv/lib/compile/async' {
declare module.exports: any;
}
declare module 'ajv/lib/compile/equal' {
declare module.exports: any;
}
declare module 'ajv/lib/compile/error_classes' {
declare module.exports: any;
}
declare module 'ajv/lib/compile/formats' {
declare module.exports: any;
}
declare module 'ajv/lib/compile/index' {
declare module.exports: any;
}
declare module 'ajv/lib/compile/resolve' {
declare module.exports: any;
}
declare module 'ajv/lib/compile/rules' {
declare module.exports: any;
}
declare module 'ajv/lib/compile/schema_obj' {
declare module.exports: any;
}
declare module 'ajv/lib/compile/ucs2length' {
declare module.exports: any;
}
declare module 'ajv/lib/compile/util' {
declare module.exports: any;
}
declare module 'ajv/lib/data' {
declare module.exports: any;
}
declare module 'ajv/lib/dotjs/_limit' {
declare module.exports: any;
}
declare module 'ajv/lib/dotjs/_limitItems' {
declare module.exports: any;
}
declare module 'ajv/lib/dotjs/_limitLength' {
declare module.exports: any;
}
declare module 'ajv/lib/dotjs/_limitProperties' {
declare module.exports: any;
}
declare module 'ajv/lib/dotjs/allOf' {
declare module.exports: any;
}
declare module 'ajv/lib/dotjs/anyOf' {
declare module.exports: any;
}
declare module 'ajv/lib/dotjs/comment' {
declare module.exports: any;
}
declare module 'ajv/lib/dotjs/const' {
declare module.exports: any;
}
declare module 'ajv/lib/dotjs/contains' {
declare module.exports: any;
}
declare module 'ajv/lib/dotjs/custom' {
declare module.exports: any;
}
declare module 'ajv/lib/dotjs/dependencies' {
declare module.exports: any;
}
declare module 'ajv/lib/dotjs/enum' {
declare module.exports: any;
}
declare module 'ajv/lib/dotjs/format' {
declare module.exports: any;
}
declare module 'ajv/lib/dotjs/if' {
declare module.exports: any;
}
declare module 'ajv/lib/dotjs/index' {
declare module.exports: any;
}
declare module 'ajv/lib/dotjs/items' {
declare module.exports: any;
}
declare module 'ajv/lib/dotjs/multipleOf' {
declare module.exports: any;
}
declare module 'ajv/lib/dotjs/not' {
declare module.exports: any;
}
declare module 'ajv/lib/dotjs/oneOf' {
declare module.exports: any;
}
declare module 'ajv/lib/dotjs/pattern' {
declare module.exports: any;
}
declare module 'ajv/lib/dotjs/properties' {
declare module.exports: any;
}
declare module 'ajv/lib/dotjs/propertyNames' {
declare module.exports: any;
}
declare module 'ajv/lib/dotjs/ref' {
declare module.exports: any;
}
declare module 'ajv/lib/dotjs/required' {
declare module.exports: any;
}
declare module 'ajv/lib/dotjs/uniqueItems' {
declare module.exports: any;
}
declare module 'ajv/lib/dotjs/validate' {
declare module.exports: any;
}
declare module 'ajv/lib/keyword' {
declare module.exports: any;
}
declare module 'ajv/scripts/bundle' {
declare module.exports: any;
}
declare module 'ajv/scripts/compile-dots' {
declare module.exports: any;
}
// Filename aliases
declare module 'ajv/dist/ajv.bundle.js' {
declare module.exports: $Exports<'ajv/dist/ajv.bundle'>;
}
declare module 'ajv/dist/ajv.min.js' {
declare module.exports: $Exports<'ajv/dist/ajv.min'>;
}
declare module 'ajv/lib/ajv.js' {
declare module.exports: $Exports<'ajv/lib/ajv'>;
}
declare module 'ajv/lib/cache.js' {
declare module.exports: $Exports<'ajv/lib/cache'>;
}
declare module 'ajv/lib/compile/async.js' {
declare module.exports: $Exports<'ajv/lib/compile/async'>;
}
declare module 'ajv/lib/compile/equal.js' {
declare module.exports: $Exports<'ajv/lib/compile/equal'>;
}
declare module 'ajv/lib/compile/error_classes.js' {
declare module.exports: $Exports<'ajv/lib/compile/error_classes'>;
}
declare module 'ajv/lib/compile/formats.js' {
declare module.exports: $Exports<'ajv/lib/compile/formats'>;
}
declare module 'ajv/lib/compile/index.js' {
declare module.exports: $Exports<'ajv/lib/compile/index'>;
}
declare module 'ajv/lib/compile/resolve.js' {
declare module.exports: $Exports<'ajv/lib/compile/resolve'>;
}
declare module 'ajv/lib/compile/rules.js' {
declare module.exports: $Exports<'ajv/lib/compile/rules'>;
}
declare module 'ajv/lib/compile/schema_obj.js' {
declare module.exports: $Exports<'ajv/lib/compile/schema_obj'>;
}
declare module 'ajv/lib/compile/ucs2length.js' {
declare module.exports: $Exports<'ajv/lib/compile/ucs2length'>;
}
declare module 'ajv/lib/compile/util.js' {
declare module.exports: $Exports<'ajv/lib/compile/util'>;
}
declare module 'ajv/lib/data.js' {
declare module.exports: $Exports<'ajv/lib/data'>;
}
declare module 'ajv/lib/dotjs/_limit.js' {
declare module.exports: $Exports<'ajv/lib/dotjs/_limit'>;
}
declare module 'ajv/lib/dotjs/_limitItems.js' {
declare module.exports: $Exports<'ajv/lib/dotjs/_limitItems'>;
}
declare module 'ajv/lib/dotjs/_limitLength.js' {
declare module.exports: $Exports<'ajv/lib/dotjs/_limitLength'>;
}
declare module 'ajv/lib/dotjs/_limitProperties.js' {
declare module.exports: $Exports<'ajv/lib/dotjs/_limitProperties'>;
}
declare module 'ajv/lib/dotjs/allOf.js' {
declare module.exports: $Exports<'ajv/lib/dotjs/allOf'>;
}
declare module 'ajv/lib/dotjs/anyOf.js' {
declare module.exports: $Exports<'ajv/lib/dotjs/anyOf'>;
}
declare module 'ajv/lib/dotjs/comment.js' {
declare module.exports: $Exports<'ajv/lib/dotjs/comment'>;
}
declare module 'ajv/lib/dotjs/const.js' {
declare module.exports: $Exports<'ajv/lib/dotjs/const'>;
}
declare module 'ajv/lib/dotjs/contains.js' {
declare module.exports: $Exports<'ajv/lib/dotjs/contains'>;
}
declare module 'ajv/lib/dotjs/custom.js' {
declare module.exports: $Exports<'ajv/lib/dotjs/custom'>;
}
declare module 'ajv/lib/dotjs/dependencies.js' {
declare module.exports: $Exports<'ajv/lib/dotjs/dependencies'>;
}
declare module 'ajv/lib/dotjs/enum.js' {
declare module.exports: $Exports<'ajv/lib/dotjs/enum'>;
}
declare module 'ajv/lib/dotjs/format.js' {
declare module.exports: $Exports<'ajv/lib/dotjs/format'>;
}
declare module 'ajv/lib/dotjs/if.js' {
declare module.exports: $Exports<'ajv/lib/dotjs/if'>;
}
declare module 'ajv/lib/dotjs/index.js' {
declare module.exports: $Exports<'ajv/lib/dotjs/index'>;
}
declare module 'ajv/lib/dotjs/items.js' {
declare module.exports: $Exports<'ajv/lib/dotjs/items'>;
}
declare module 'ajv/lib/dotjs/multipleOf.js' {
declare module.exports: $Exports<'ajv/lib/dotjs/multipleOf'>;
}
declare module 'ajv/lib/dotjs/not.js' {
declare module.exports: $Exports<'ajv/lib/dotjs/not'>;
}
declare module 'ajv/lib/dotjs/oneOf.js' {
declare module.exports: $Exports<'ajv/lib/dotjs/oneOf'>;
}
declare module 'ajv/lib/dotjs/pattern.js' {
declare module.exports: $Exports<'ajv/lib/dotjs/pattern'>;
}
declare module 'ajv/lib/dotjs/properties.js' {
declare module.exports: $Exports<'ajv/lib/dotjs/properties'>;
}
declare module 'ajv/lib/dotjs/propertyNames.js' {
declare module.exports: $Exports<'ajv/lib/dotjs/propertyNames'>;
}
declare module 'ajv/lib/dotjs/ref.js' {
declare module.exports: $Exports<'ajv/lib/dotjs/ref'>;
}
declare module 'ajv/lib/dotjs/required.js' {
declare module.exports: $Exports<'ajv/lib/dotjs/required'>;
}
declare module 'ajv/lib/dotjs/uniqueItems.js' {
declare module.exports: $Exports<'ajv/lib/dotjs/uniqueItems'>;
}
declare module 'ajv/lib/dotjs/validate.js' {
declare module.exports: $Exports<'ajv/lib/dotjs/validate'>;
}
declare module 'ajv/lib/keyword.js' {
declare module.exports: $Exports<'ajv/lib/keyword'>;
}
declare module 'ajv/scripts/bundle.js' {
declare module.exports: $Exports<'ajv/scripts/bundle'>;
}
declare module 'ajv/scripts/compile-dots.js' {
declare module.exports: $Exports<'ajv/scripts/compile-dots'>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment