-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.d.ts
97 lines (86 loc) · 2.75 KB
/
main.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Type definitions for aldeed:simple-schema meteor package
// Project: https://atmospherejs.com/aldeed/simple-schema
// Definitions by: Dave Allen <https://github.com/fullflavedave>
interface IAldeedSimpleSchemaPropertyAttributes {
type: any | any[];
label?: string | Function;
min?: number | Date;
max?: number | Date;
exclusiveMin?: boolean;
exclusiveMax?: boolean;
minCount?: number;
maxCount?: number;
optional?: boolean;
allowedValues?: any[];
regEx?: RegExp;
blackbox?: boolean;
trim?: boolean;
custom?: Function;
defaultValue?: any;
autoValue?: Function;
decimal?: boolean;
/**
* Index for collection
* Can be true, -1 or 1
* @type {number|boolean}
*/
index?:number|boolean;
/**
* Unique flag for index
* @type {boolean}
*/
unique?: boolean;
/**
* Sparce flag for index
* @type {boolean}
*/
sparse?: boolean;
}
interface SimpleSchemaDefinition {
[property: string]: IAldeedSimpleSchemaPropertyAttributes;
}
interface ValidateOptions {
modifier?: boolean;
upsert?: boolean;
extendedCustomContext: { [key: string]: any };
}
interface SimpleSchemaCleanOptions {
filter?: boolean;
autoConvert?: boolean;
removeEmptyStrings?: boolean;
trimStrings?: boolean;
getAutoValues?: boolean;
isModifier?: boolean;
extendedAutoValueContext?: any;
}
interface SimpleSchema_Static {
new(definition: SimpleSchemaDefinition|SimpleSchema_Instance[]): SimpleSchema_Instance;
extendOptions(options: { [option: string]: any }): void;
addValidator(validator: Function): void;
messages(messageKeysAndTexts: { [errorKey: string]: string; /** Text for that error **/ } | { exp: RegExp; msg: string; }[]): void;
debug(isDebugging: boolean): void;
RegEx: { Email: RegExp, WeakDomain: RegExp, Url: RegExp, Domain: RegExp, IP: RegExp, IPv4: RegExp, IPv6: RegExp, Id: RegExp, ZipCode: RegExp};
}
interface SimpleSchema_Instance {
messages(messages: Object): void;
schema(): SimpleSchema_Static;
validate(obj: any, options?: ValidateOptions): boolean;
validateOne(obj: any, key: string, options: ValidateOptions): boolean;
clean(obj: any, options?: SimpleSchemaCleanOptions): void;
addValidator(validator: Function): void;
newContext(): {
validate(obj: any, options?: ValidateOptions): boolean;
validateOne(obj: any, key: string, options: ValidateOptions): boolean;
isValid(): boolean;
invalidKeys(): { name: string; type: any }[];
keyIsInvalid(key: string): boolean;
keyErrorMessage(key: string): string;
resetValidation(): void;
};
validator(): (...args: any[]) => boolean;
}
declare const SimpleSchema: SimpleSchema_Static;
declare module 'meteor/aldeed:simple-schema' {
export const SimpleSchema: SimpleSchema_Static;
type SimpleSchema = SimpleSchema_Instance;
}