@nattyjs/validation-decorators 0.0.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,404 @@
1
+ interface BaseValidatorConfig {
2
+ message?: string;
3
+ conditionalExpression?: Function;
4
+ messageKey?: string;
5
+ }
6
+
7
+ interface ArrayConfig extends BaseValidatorConfig {
8
+ matchValues?: any[];
9
+ }
10
+
11
+ declare function allOf(config?: ArrayConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
12
+
13
+ interface RequiredConfig extends BaseValidatorConfig {
14
+ }
15
+
16
+ declare function required(config?: RequiredConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
17
+
18
+ declare enum NumericValueType {
19
+ PositiveNumber = 1,
20
+ NegativeNumber = 2,
21
+ Both = 3
22
+ }
23
+
24
+ interface NumericConfig extends BaseValidatorConfig {
25
+ allowDecimal?: boolean;
26
+ acceptValue?: NumericValueType;
27
+ isFormat?: boolean;
28
+ digitsInfo?: string;
29
+ persistZero?: boolean;
30
+ }
31
+
32
+ declare function numeric(config?: NumericConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
33
+
34
+ interface AlphaConfig extends BaseValidatorConfig {
35
+ allowWhiteSpace?: boolean;
36
+ locale?: string;
37
+ allowCharacters?: string;
38
+ }
39
+
40
+ declare function alpha(config?: AlphaConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
41
+
42
+ declare function alphaNumeric(config?: AlphaConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
43
+
44
+ declare function ascii(config?: BaseValidatorConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
45
+
46
+ interface ContainsConfig extends BaseValidatorConfig {
47
+ value?: string;
48
+ values?: any[];
49
+ }
50
+
51
+ declare function contains(config: ContainsConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
52
+
53
+ interface CreditCardConfig extends BaseValidatorConfig {
54
+ creditCardTypes?: string[];
55
+ fieldName?: string;
56
+ }
57
+
58
+ declare function creditCard(config: CreditCardConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
59
+
60
+ declare function cusip(config?: BaseValidatorConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
61
+
62
+ declare function dataUri(config?: BaseValidatorConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
63
+
64
+ declare function date(config?: BaseValidatorConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
65
+
66
+ interface FieldConfig extends BaseValidatorConfig {
67
+ fieldName?: string;
68
+ }
69
+
70
+ interface DifferentConfig extends FieldConfig {
71
+ }
72
+
73
+ declare function different(config: DifferentConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
74
+
75
+ interface DigitConfig extends BaseValidatorConfig {
76
+ }
77
+
78
+ declare function digit(config?: DigitConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
79
+
80
+ interface EmailConfig extends BaseValidatorConfig {
81
+ }
82
+
83
+ declare function email(config?: EmailConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
84
+
85
+ interface DefaultConfig extends BaseValidatorConfig {
86
+ value?: string;
87
+ }
88
+
89
+ interface StringValueConfig extends DefaultConfig {
90
+ values?: any[];
91
+ }
92
+
93
+ declare function endsWith(config: StringValueConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
94
+
95
+ declare function even(config?: BaseValidatorConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
96
+
97
+ interface ExtensionConfig extends BaseValidatorConfig {
98
+ extensions?: string[];
99
+ isExcludeExtensions?: boolean;
100
+ }
101
+
102
+ declare function extension(config: ExtensionConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
103
+
104
+ interface FactorConfig extends BaseValidatorConfig {
105
+ dividend?: number;
106
+ fieldName?: string;
107
+ }
108
+
109
+ declare function factor(config?: FactorConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
110
+
111
+ interface RelationalOperatorConfig extends BaseValidatorConfig {
112
+ fieldName?: string;
113
+ value?: any;
114
+ isArrayControl?: boolean;
115
+ }
116
+
117
+ declare function greaterThanEqualTo(config: RelationalOperatorConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
118
+
119
+ declare function greaterThan(config: RelationalOperatorConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
120
+
121
+ interface MessageConfig extends BaseValidatorConfig {
122
+ }
123
+
124
+ declare function hexColor(config?: MessageConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
125
+
126
+ declare enum IpVersion {
127
+ V4 = 1,
128
+ V6 = 2,
129
+ AnyOne = 3
130
+ }
131
+
132
+ interface IpConfig extends BaseValidatorConfig {
133
+ version?: IpVersion;
134
+ isCidr?: boolean;
135
+ }
136
+
137
+ declare function ip(config?: IpConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
138
+
139
+ declare function json(config?: DefaultConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
140
+
141
+ declare function latitude(config?: BaseValidatorConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
142
+
143
+ declare function latLong(config?: BaseValidatorConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
144
+
145
+ declare function leapYear(config?: BaseValidatorConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
146
+
147
+ declare function lessThanEqualTo(config: RelationalOperatorConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
148
+
149
+ declare function lessThan(config: RelationalOperatorConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
150
+
151
+ declare function longitude(config?: BaseValidatorConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
152
+
153
+ declare function lowerCase(config?: MessageConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
154
+
155
+ declare function mac(config?: BaseValidatorConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
156
+
157
+ interface DateConfig extends BaseValidatorConfig {
158
+ value?: Date | string;
159
+ fieldName?: string;
160
+ allowISODate?: boolean;
161
+ }
162
+
163
+ interface MaxDateConfig extends DateConfig {
164
+ operator?: "<" | "<=";
165
+ }
166
+
167
+ declare function maxDate(config: MaxDateConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
168
+
169
+ interface NumberConfig extends BaseValidatorConfig {
170
+ value?: number;
171
+ }
172
+
173
+ declare function maxLength(config: NumberConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
174
+
175
+ declare function maxNumber(config: NumberConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
176
+
177
+ interface TimeRelationConfig extends BaseValidatorConfig {
178
+ value?: string;
179
+ fieldName?: string;
180
+ allowSeconds?: boolean;
181
+ }
182
+ interface MinTimeConfig extends TimeRelationConfig {
183
+ operator?: ">" | ">=";
184
+ }
185
+ interface MaxTimeConfig extends TimeRelationConfig {
186
+ operator?: "<" | "<=";
187
+ }
188
+
189
+ declare function maxTime(config: MaxTimeConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
190
+
191
+ interface MinDateConfig extends DateConfig {
192
+ operator?: ">" | ">=";
193
+ }
194
+
195
+ declare function minDate(config: MinDateConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
196
+
197
+ declare function minLength(config: NumberConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
198
+
199
+ declare function minNumber(config: NumberConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
200
+
201
+ declare function minTime(config: MinTimeConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
202
+
203
+ declare function noneOf(config?: ArrayConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
204
+
205
+ declare function notEmpty(config?: BaseValidatorConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
206
+
207
+ declare function odd(config?: BaseValidatorConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
208
+
209
+ declare function oneOf(config?: ArrayConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
210
+
211
+ interface PasswordValidation {
212
+ digit?: boolean;
213
+ alphabet?: boolean;
214
+ contains?: string;
215
+ lowerCase?: boolean;
216
+ upperCase?: boolean;
217
+ specialCharacter?: boolean;
218
+ minLength?: number;
219
+ maxLength?: number;
220
+ }
221
+ interface PasswordValidationMessage {
222
+ digit?: string;
223
+ alphabet?: string;
224
+ contains?: string;
225
+ lowerCase?: string;
226
+ upperCase?: string;
227
+ specialCharacter?: string;
228
+ minLength?: string;
229
+ maxLength?: string;
230
+ }
231
+
232
+ interface PasswordConfig {
233
+ validation?: PasswordValidation;
234
+ conditionalExpression?: string | Function;
235
+ message?: PasswordValidationMessage | string;
236
+ messageKey?: PasswordValidationMessage | string;
237
+ }
238
+
239
+ declare function password(config: PasswordConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
240
+
241
+ interface PatternConfig extends BaseValidatorConfig {
242
+ expression?: {
243
+ [key: string]: RegExp;
244
+ };
245
+ }
246
+
247
+ declare function pattern(config: PatternConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
248
+
249
+ declare function port(config?: BaseValidatorConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
250
+
251
+ declare function primeNumber(config?: BaseValidatorConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
252
+
253
+ interface RangeConfig extends BaseValidatorConfig {
254
+ minimumNumber?: number;
255
+ maximumNumber?: number;
256
+ }
257
+
258
+ declare function range(config: RangeConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
259
+
260
+ declare function requiredTrue(config?: RequiredConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
261
+
262
+ interface StringComparisonConfig extends DefaultConfig {
263
+ isRestrict?: boolean;
264
+ values?: any[];
265
+ }
266
+
267
+ declare function startsWith(config: StringComparisonConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
268
+
269
+ declare function upperCase(config?: MessageConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
270
+
271
+ declare enum UrlValidationType {
272
+ FQDN = 1,
273
+ LocalHost = 2,
274
+ IntranetServer = 3
275
+ }
276
+
277
+ interface UrlConfig extends BaseValidatorConfig {
278
+ urlValidationType?: UrlValidationType;
279
+ }
280
+
281
+ declare function url(config?: UrlConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
282
+
283
+ declare function blacklist(chars: string): (target: any, propertyKey: string, parameterIndex?: any) => void;
284
+
285
+ declare function escape(): (target: any, propertyKey: string, parameterIndex?: any) => void;
286
+
287
+ declare function ltrim(): (target: any, propertyKey: string, parameterIndex?: any) => void;
288
+
289
+ declare function prefix(text: string): (target: any, propertyKey: string, parameterIndex?: any) => void;
290
+
291
+ declare function rtrim(): (target: any, propertyKey: string, parameterIndex?: any) => void;
292
+
293
+ declare function stripLow(keepNewLines?: boolean): (target: any, propertyKey: string, parameterIndex?: any) => void;
294
+
295
+ declare function suffix(text: string): (target: any, propertyKey: string, parameterIndex?: any) => void;
296
+
297
+ declare function toBoolean(strict?: boolean): (target: any, propertyKey: string, parameterIndex?: any) => void;
298
+
299
+ declare function toDate(): (target: any, propertyKey: string, parameterIndex?: any) => void;
300
+
301
+ declare function toInt(radix?: number): (target: any, propertyKey: string, parameterIndex?: any) => void;
302
+
303
+ declare function toString(): (target: any, propertyKey: string, parameterIndex?: any) => void;
304
+
305
+ declare function trim(): (target: any, propertyKey: string, parameterIndex?: any) => void;
306
+
307
+ declare function whitelist(chars: string): (target: any, propertyKey: string, parameterIndex?: any) => void;
308
+
309
+ interface SanitizeConfig {
310
+ custom: Function;
311
+ }
312
+
313
+ declare function sanitize(config: SanitizeConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
314
+
315
+ interface Type<T> extends Function {
316
+ new (...args: any[]): T;
317
+ }
318
+
319
+ interface PropConfig$1 {
320
+ type?: Type<any>;
321
+ isArrayType?: boolean;
322
+ }
323
+
324
+ declare function prop(config?: PropConfig$1): (target: any, propertyKey: string, parameterIndex?: any) => void;
325
+
326
+ interface DecoratorParams {
327
+ target: Function;
328
+ propertyKey?: string;
329
+ descriptor?: PropertyDescriptor;
330
+ }
331
+
332
+ interface ModelConfig {
333
+ tableName?: string;
334
+ }
335
+
336
+ interface DbFieldConfig {
337
+ name?: string;
338
+ type?: number;
339
+ defaultValue?: any;
340
+ isPrimaryKey?: boolean;
341
+ foreignKey?: any;
342
+ oneToMany?: FieldRelationConfig;
343
+ oneToOne?: FieldRelationConfig;
344
+ }
345
+ interface FieldRelationConfig {
346
+ model: any;
347
+ foreignKey: string;
348
+ }
349
+
350
+ interface PropConfig {
351
+ db?: DbFieldConfig;
352
+ }
353
+
354
+ interface PropertyDecoratorConfig {
355
+ decoratorParams: DecoratorParams;
356
+ validatorConfig?: any;
357
+ propConfig?: PropConfig;
358
+ modelConfig?: ModelConfig;
359
+ sanitizerConfig?: {
360
+ name: string;
361
+ config: any;
362
+ sanitizer: Function;
363
+ };
364
+ }
365
+
366
+ declare const decoratorRegistrationCaller: {
367
+ register: (config: PropertyDecoratorConfig) => {};
368
+ };
369
+
370
+ type ValidatorFn = null | {
371
+ [key: string]: any;
372
+ };
373
+
374
+ interface ValidatorParams {
375
+ root: any;
376
+ current: any;
377
+ value: any;
378
+ }
379
+
380
+ declare function requiredValidator(config: RequiredConfig, params: ValidatorParams): ValidatorFn;
381
+
382
+ declare const ControlValidators: {
383
+ required: typeof requiredValidator;
384
+ };
385
+
386
+ interface FormConfig {
387
+ errorMessage?: ErrorMessage;
388
+ dateConfig?: {
389
+ seperator?: string;
390
+ format?: 'mdy' | 'dmy' | 'ymd';
391
+ };
392
+ }
393
+ interface ErrorMessage {
394
+ validator?: {
395
+ [key: string]: string;
396
+ };
397
+ }
398
+
399
+ declare const validationForms: {
400
+ formConfig: FormConfig;
401
+ configure(config: FormConfig): void;
402
+ };
403
+
404
+ export { ControlValidators, FormConfig, NumericValueType, RequiredConfig, ValidatorFn, allOf as decoratorAllOfValidation, alphaNumeric as decoratorAlphaNumericValidation, alpha as decoratorAlphaValidation, ascii as decoratorAsciiValidation, blacklist as decoratorBlacklistSanitizer, contains as decoratorContainsValidation, creditCard as decoratorCreditCardValidation, cusip as decoratorCusipValidation, dataUri as decoratorDataUriValidation, date as decoratorDateValidation, different as decoratorDifferentValdiation, digit as decoratorDigitValidation, email as decoratorEmailValidation, endsWith as decoratorEndsWithValidation, escape as decoratorEscapeSanitizer, even as decoratorEvenValidation, extension as decoratorExtensionValidation, factor as decoratorFactorValidation, greaterThanEqualTo as decoratorGreaterThanEqualToValidation, greaterThan as decoratorGreaterThanValidation, hexColor as decoratorHexColorValidation, ip as decoratorIpValidation, json as decoratorJsonValidation, latLong as decoratorLatLongValidation, latitude as decoratorLatitudeValdiation, leapYear as decoratorLeapYearValidation, lessThanEqualTo as decoratorLessThanEqualToValidation, lessThan as decoratorLessThanValidation, longitude as decoratorLongitudeValidation, lowerCase as decoratorLowercaseValidation, ltrim as decoratorLtrimSanitizer, mac as decoratorMacValidation, maxDate as decoratorMaxDateValidation, maxLength as decoratorMaxLengthValidation, maxNumber as decoratorMaxNumberValidation, maxTime as decoratorMaxTimeValidation, minDate as decoratorMinDateValidation, minLength as decoratorMinLengthValidation, minNumber as decoratorMinNumberValidation, minTime as decoratorMinTimeValidation, noneOf as decoratorNoneOfValidation, notEmpty as decoratorNotEmptyValidation, numeric as decoratorNumericValidation, odd as decoratorOddValidation, oneOf as decoratorOneOfValidation, password as decoratorPasswordValdiation, pattern as decoratorPatternValidation, port as decoratorPortValidation, prefix as decoratorPrefixSanitizer, primeNumber as decoratorPrimeNumberValidation, range as decoratorRangeValidation, decoratorRegistrationCaller, requiredTrue as decoratorRequiredTrueValidation, required as decoratorRequiredValidation, rtrim as decoratorRtrimSanitizer, sanitize as decoratorSanitizeSanitizer, startsWith as decoratorStartsWithValidation, stripLow as decoratorStripLowSanitizer, suffix as decoratorSuffixSanitizer, toBoolean as decoratorToBooleanSanitizer, toDate as decoratorToDateSanitizer, toInt as decoratorToIntSanitizer, toString as decoratorToStringSanitizer, trim as decoratorTrimSanitizer, upperCase as decoratorUpperCaseValidation, url as decoratorUrlValidation, whitelist as decoratorWhitelistSanitizer, prop, validationForms };