forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jjv.d.ts
42 lines (34 loc) · 1.04 KB
/
jjv.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Type definitions for JJV v1.0.2
// Project: https://github.com/acornejo/jjv
// Definitions by: Wim Looman <https://github.com/Nemo157>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module "jjv" {
function jjv(): jjv.Env;
namespace jjv {
interface Errors {
validation: {
[property: string]: {
required?: boolean;
type?: string;
}
};
}
interface Options {
checkRequired?: boolean;
useDefault?: boolean;
useCoerce?: boolean;
removeAdditional?: boolean;
}
interface Env {
defaultOptions: Options;
addSchema(name: string, schema: Object): void;
addType(name: string, parse: (input: any) => any): void;
addFormat(name: string, parse: (input: any) => any): void;
addCheck(name: string, check: (input: any, comparator: any) => any): void;
addTypeCoercion(name: string, coerce: (input: any) => any): void;
validate(name: string, object: any, options?: Options): Errors;
validate(schema: Object, object: any, options?: Options): Errors;
}
}
export = jjv;
}