-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathindex.d.ts
227 lines (195 loc) · 5.78 KB
/
index.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
// Type definitions for redux-form-validators
// Project: https://github.com/gtournie/redux-form-validators
// Definitions by: Ben Barber <https://github.com/benbarber>
// TypeScript Version: 2.6
export type Validator = (value: any, allValues?: any, props?: any) => any
export type FormValidator = (allValues?: any) => any
export interface MessageDescriptor {
id?: string
defaultMessage?: string
description?: string
values?: string | object
}
export interface MessageProps {
props: MessageDescriptor
}
declare type ValidatorMessage = MessageDescriptor | MessageProps | string
export interface DefaultValidatorOptions {
if?: (values: any, value: any, props: any, name: string) => boolean
unless?: (values: any, value: any, props: any, name: string) => boolean
memoize?: any
message?: ValidatorMessage
msg?: ValidatorMessage
}
export interface ValidatorMessages {
absence: ValidatorMessage
acceptance: ValidatorMessage
confirmation: ValidatorMessage
dateFormat: ValidatorMessage
dateInvalid: ValidatorMessage
dateRange: ValidatorMessage
email: ValidatorMessage
emailDomain: ValidatorMessage
equalTo: ValidatorMessage
even: ValidatorMessage
exclusion: ValidatorMessage
file: ValidatorMessage
fileAccept: ValidatorMessage
fileTooBig: ValidatorMessage
fileTooFew: ValidatorMessage
fileTooMany: ValidatorMessage
fileTooSmall: ValidatorMessage
greaterThan: ValidatorMessage
greaterThanOrEqualTo: ValidatorMessage
inclusion: ValidatorMessage
invalid: ValidatorMessage
lessThan: ValidatorMessage
lessThanOrEqualTo: ValidatorMessage
notAnInteger: ValidatorMessage
notANumber: ValidatorMessage
odd: ValidatorMessage
otherThan: ValidatorMessage
presence: ValidatorMessage
tooLong: ValidatorMessage
tooShort: ValidatorMessage
url: ValidatorMessage
wrongLength: ValidatorMessage
}
export const validateForm: (validations: object) => FormValidator
export interface AddValidatorOptions {
validator: Validator
defaultMessage?: string
defaultMsg?: string
}
export const addValidator: (options: AddValidatorOptions) => Validator
export const combine: (...validators: Validator[]) => Validator
export const absence: (options?: DefaultValidatorOptions) => Validator
export const acceptance: (options?: DefaultValidatorOptions) => Validator
export interface ConfirmationValidatorOptions extends DefaultValidatorOptions {
field?: string
fieldLabel?: string
caseSensitive?: boolean
}
export const confirmation: (options?: ConfirmationValidatorOptions) => Validator
export interface DateValidatorOptions extends DefaultValidatorOptions {
format?: string
ymd?: string
'='?: Date | number | string
'!='?: Date | number | string
'>'?: Date | number | string
'>='?: Date | number | string
'<'?: Date | number | string
'<='?: Date | number | string
allowBlank?: boolean
}
export const date: (options?: DateValidatorOptions) => Validator
export const exclusion: (options?: DefaultValidatorOptions) => Validator
export interface EmailValidatorOptions extends DefaultValidatorOptions {
allowBlank?: boolean
}
export const email: (options?: EmailValidatorOptions) => Validator
export interface FileValidatorOptions extends DefaultValidatorOptions {
accept?: string
minSize?: number | string
maxSize?: number | string
minFiles?: number
maxFiles?: number
allowBlank?: boolean
}
export const file: (options?: FileValidatorOptions) => Validator
export interface FormatOptions extends DefaultValidatorOptions {
with?: RegExp
without?: RegExp
allowBlank?: boolean
}
export const format: (options?: FormatOptions) => Validator
export interface InclusionValidatorOptions extends DefaultValidatorOptions {
in?: any[]
within?: any[]
caseSensitive?: boolean
allowBlank?: boolean
}
export const inclusion: (options?: InclusionValidatorOptions) => Validator
export interface LengthValidatorOptions extends DefaultValidatorOptions {
'='?: number
is?: number
max?: number
maximum?: number
min?: number
minimum?: number
in?: number[]
within?: number[]
allowBlank?: boolean
}
export const length: (options?: LengthValidatorOptions) => Validator
export interface NumericalityValidatorOptions extends DefaultValidatorOptions {
int?: boolean
integer?: boolean
even?: boolean
odd?: boolean
'='?: number
equalTo?: number
'!='?: number
otherThan?: number
'>'?: number
greaterThan?: number
'<'?: number
lessThan?: number
'>='?: number
greaterThanOrEqualTo?: number
'<='?: number
lessThanOrEqualTo?: number
allowBlank?: boolean
}
export const numericality: (options?: NumericalityValidatorOptions) => Validator
export const presence: (options?: DefaultValidatorOptions) => Validator
export const required: (options?: DefaultValidatorOptions) => Validator
export interface UrlValidatorOptions extends DefaultValidatorOptions {
protocol?: string
protocols?: string[]
emptyProtocol?: boolean
protocolIdentifier?: boolean
basicAuth?: boolean
local?: boolean
ipv4?: boolean
ipv6?: boolean
host?: boolean
port?: boolean
path?: boolean
search?: boolean
hash?: boolean
}
interface URL {
protocol?: string;
hash?: string;
host?: string;
ipv4?: string;
ipv6?: string;
port?: number;
search?: string;
path?: string;
basicAuth?: {
username: string;
password?: string;
};
}
export const url : {
(options?: UrlValidatorOptions): Validator;
parseURL: (url: string, options?: UrlValidatorOptions) => URL | null;
}
declare const Validators: {
formatMessage: (msg: MessageDescriptor) => string
formatSize: (size: string, units: string) => string
defaultOptions: {
memoize: any
allowBlank: boolean
urlProtocols: string[]
dateFormat: string
dateYmd: string
accept: string[]
caseSensitive: boolean
}
messages: ValidatorMessages
pluralRules: object
}
export default Validators