@arc-js/jon 0.0.1

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.
package/index.min.d.ts ADDED
@@ -0,0 +1,433 @@
1
+ interface ValidationResult {
2
+ valid: boolean;
3
+ data: any;
4
+ error: any;
5
+ }
6
+ interface RuleFunction {
7
+ (value: any): ValidationResult;
8
+ }
9
+ declare class JONDefaultSchema {
10
+ protected _label: string | undefined;
11
+ protected _lang: string;
12
+ protected _default: any;
13
+ protected _rules: RuleFunction[];
14
+ protected _value: any;
15
+ protected _default_error: any;
16
+ map: ((data: any) => any) | undefined;
17
+ preMap: ((data: any) => any) | undefined;
18
+ protected _mapError: {
19
+ [key: string]: Function;
20
+ };
21
+ protected _errMsgs: any;
22
+ protected _PRIMARY__REQUIRED__RULE: RuleFunction | undefined;
23
+ protected _PRIMARY__ENUM__RULE: RuleFunction | undefined;
24
+ protected _PRIMARY__ENUM_NOT__RULE: RuleFunction | undefined;
25
+ protected _PRIMARY__CUSTOM01__RULE: RuleFunction | undefined;
26
+ protected _PRIMARY__CUSTOM02__RULE: RuleFunction | undefined;
27
+ protected _PRIMARY__CUSTOM03__RULE: RuleFunction | undefined;
28
+ protected _PRIMARY__CUSTOM04__RULE: RuleFunction | undefined;
29
+ protected _PRIMARY__CUSTOM05__RULE: RuleFunction | undefined;
30
+ protected _PRIMARY__CUSTOM06__RULE: RuleFunction | undefined;
31
+ protected _PRIMARY__CUSTOM07__RULE: RuleFunction | undefined;
32
+ protected _PRIMARY__CUSTOM08__RULE: RuleFunction | undefined;
33
+ protected _PRIMARY__CUSTOM09__RULE: RuleFunction | undefined;
34
+ protected _PRIMARY__CUSTOM10__RULE: RuleFunction | undefined;
35
+ protected _PRIMARY__CUSTOM11__RULE: RuleFunction | undefined;
36
+ protected _PRIMARY__CUSTOM12__RULE: RuleFunction | undefined;
37
+ protected _PRIMARY__CUSTOM13__RULE: RuleFunction | undefined;
38
+ protected _PRIMARY__CUSTOM14__RULE: RuleFunction | undefined;
39
+ protected _PRIMARY__CUSTOM15__RULE: RuleFunction | undefined;
40
+ protected _PRIMARY__CUSTOM16__RULE: RuleFunction | undefined;
41
+ protected _PRIMARY__CUSTOM17__RULE: RuleFunction | undefined;
42
+ protected _PRIMARY__CUSTOM18__RULE: RuleFunction | undefined;
43
+ protected _PRIMARY__CUSTOM19__RULE: RuleFunction | undefined;
44
+ protected _PRIMARY__CUSTOM20__RULE: RuleFunction | undefined;
45
+ protected _PRIMARY__CUSTOM21__RULE: RuleFunction | undefined;
46
+ protected _PRIMARY__CUSTOM22__RULE: RuleFunction | undefined;
47
+ protected _PRIMARY__CUSTOM23__RULE: RuleFunction | undefined;
48
+ protected _PRIMARY__CUSTOM24__RULE: RuleFunction | undefined;
49
+ protected _PRIMARY__CUSTOM25__RULE: RuleFunction | undefined;
50
+ protected _PRIMARY__CUSTOM26__RULE: RuleFunction | undefined;
51
+ protected _PRIMARY__CUSTOM27__RULE: RuleFunction | undefined;
52
+ protected _PRIMARY__CUSTOM28__RULE: RuleFunction | undefined;
53
+ protected _PRIMARY__CUSTOM29__RULE: RuleFunction | undefined;
54
+ protected _PRIMARY__CUSTOM30__RULE: RuleFunction | undefined;
55
+ protected _PRIMARY__CUSTOM31__RULE: RuleFunction | undefined;
56
+ protected _PRIMARY__CUSTOM32__RULE: RuleFunction | undefined;
57
+ protected _PRIMARY__CUSTOM33__RULE: RuleFunction | undefined;
58
+ protected _PRIMARY__CUSTOM34__RULE: RuleFunction | undefined;
59
+ protected _PRIMARY__CUSTOM35__RULE: RuleFunction | undefined;
60
+ protected _PRIMARY__CUSTOM36__RULE: RuleFunction | undefined;
61
+ protected _PRIMARY__CUSTOM37__RULE: RuleFunction | undefined;
62
+ protected _PRIMARY__CUSTOM38__RULE: RuleFunction | undefined;
63
+ protected _PRIMARY__CUSTOM39__RULE: RuleFunction | undefined;
64
+ protected _PRIMARY__CUSTOM40__RULE: RuleFunction | undefined;
65
+ protected _PRIMARY__CUSTOM41__RULE: RuleFunction | undefined;
66
+ protected _PRIMARY__CUSTOM42__RULE: RuleFunction | undefined;
67
+ protected _PRIMARY__CUSTOM43__RULE: RuleFunction | undefined;
68
+ protected _PRIMARY__CUSTOM44__RULE: RuleFunction | undefined;
69
+ protected _PRIMARY__CUSTOM45__RULE: RuleFunction | undefined;
70
+ protected _PRIMARY__CUSTOM46__RULE: RuleFunction | undefined;
71
+ protected _PRIMARY__CUSTOM47__RULE: RuleFunction | undefined;
72
+ protected _PRIMARY__CUSTOM48__RULE: RuleFunction | undefined;
73
+ protected _PRIMARY__CUSTOM49__RULE: RuleFunction | undefined;
74
+ protected _PRIMARY__CUSTOM50__RULE: RuleFunction | undefined;
75
+ protected _errorRule: string | undefined;
76
+ constructor(lang?: string);
77
+ applyApp(rule?: (data: any) => boolean, sanitize?: (data: any) => any, exception?: any): this;
78
+ required(isRequired?: boolean): this;
79
+ enum(...choices: any[]): this;
80
+ enumNot(...choices: any[]): this;
81
+ get_default(): any;
82
+ set_default(defaultVal: any): void;
83
+ get_lang(): string;
84
+ set_lang(lang: string): void;
85
+ get_label(): string;
86
+ set_label(label: any): void;
87
+ get_error(): any;
88
+ set_error(error: any): void;
89
+ defaultError(error: any): this;
90
+ lang(value: string): this;
91
+ label(value: any): this;
92
+ default(value: any): this;
93
+ getLang(): string;
94
+ setLang(lang: string): void;
95
+ addRule(rule: RuleFunction): void;
96
+ validate(value: any): ValidationResult;
97
+ isValid(value: any): boolean;
98
+ error(value: any): any;
99
+ sanitize(value: any): any;
100
+ protected primaryValidation(value: any): ValidationResult | undefined;
101
+ getMapError(): Function;
102
+ initMapError(mapError: any): this;
103
+ applyPreMapping(map?: (data: any) => any): this;
104
+ applyMapping(map?: (data: any) => any): this;
105
+ getErrorRule(): string | undefined;
106
+ }
107
+
108
+ declare class ArraySchema$1 extends JONDefaultSchema {
109
+ private _maxValue;
110
+ private _minValue;
111
+ private _lessValue;
112
+ private _greaterValue;
113
+ private _lengthValue;
114
+ private _types;
115
+ private _ARRAY__RULE;
116
+ private _ARRAY__TYPE__RULE;
117
+ private _ARRAY__MIN__RULE;
118
+ private _ARRAY__MAX__RULE;
119
+ private _ARRAY__LESS__RULE;
120
+ private _ARRAY__GREATER__RULE;
121
+ private _ARRAY__LENGTH__RULE;
122
+ constructor(lang?: string);
123
+ array(): this;
124
+ types(...values: any[]): this;
125
+ min(minValue: number): this;
126
+ max(maxValue: number): this;
127
+ less(lessValue: number): this;
128
+ greater(greaterValue: number): this;
129
+ length(lengthValue: number): this;
130
+ validate(value: any): ValidationResult;
131
+ private arrayValidation;
132
+ }
133
+ declare class ObjectSchema$1 extends JONDefaultSchema {
134
+ private _struct;
135
+ private _primaryStruct;
136
+ private _maxValue;
137
+ private _minValue;
138
+ private _lessValue;
139
+ private _greaterValue;
140
+ private _lengthValue;
141
+ private _oldValueForStruct;
142
+ private _OBJECT__RULE;
143
+ private _OBJECT__STRUCT__RULE;
144
+ private _OBJECT__PRIMARY_STRUCT__RULE;
145
+ private _OBJECT__TYPES_VALUES__RULE;
146
+ private _OBJECT__CONTAINS_KEYS__RULE;
147
+ private _OBJECT__NO_CONTAINS_KEYS__RULE;
148
+ private _OBJECT__REGEXP_CONTAINS_KEYS__RULE;
149
+ private _OBJECT__REGEXP_NO_CONTAINS_KEYS__RULE;
150
+ private _OBJECT__MIN__RULE;
151
+ private _OBJECT__MAX__RULE;
152
+ private _OBJECT__LESS__RULE;
153
+ private _OBJECT__GREATER__RULE;
154
+ private _OBJECT__LENGTH__RULE;
155
+ constructor(lang?: string);
156
+ object(): this;
157
+ private structAction;
158
+ struct(values: {
159
+ [key: string]: any;
160
+ }): this;
161
+ primaryStruct(values: {
162
+ [key: string]: any;
163
+ }): this;
164
+ getStruct(): {
165
+ [key: string]: any;
166
+ };
167
+ typesValues(...values: any[]): this;
168
+ containsKeys(keys?: string[], strict?: boolean): this;
169
+ noContainsKeys(keys?: string[], strict?: boolean): this;
170
+ regExpContainsKeys(ruleValue: string | RegExp, flag?: string | undefined, strict?: boolean): this;
171
+ regExpNoContainsKeys(ruleValue: string | RegExp, flag?: string | undefined, strict?: boolean): this;
172
+ min(minValue: number): this;
173
+ max(maxValue: number): this;
174
+ less(lessValue: number): this;
175
+ greater(greaterValue: number): this;
176
+ length(lengthValue: number): this;
177
+ validate(value: any): ValidationResult;
178
+ private objectValidation;
179
+ }
180
+ declare class ChosenTypeSchema$1 extends JONDefaultSchema {
181
+ private _types;
182
+ private _invalid_types;
183
+ private _CHOSEN_TYPE__RULE;
184
+ constructor(lang?: string);
185
+ private chosenTypes;
186
+ choices(...types: any[]): this;
187
+ types(): any[];
188
+ validate(value: any): ValidationResult;
189
+ private chosenTypesValidation;
190
+ }
191
+ declare class EnumSchema$1 extends JONDefaultSchema {
192
+ private _choices;
193
+ private _ENUM__RULE;
194
+ constructor(lang?: string);
195
+ enum(): this;
196
+ choices(...values: any[]): this;
197
+ validate(value: any): ValidationResult;
198
+ private enumValidation;
199
+ }
200
+ declare class NotEnumSchema$1 extends JONDefaultSchema {
201
+ private _choices;
202
+ private _NOT_ENUM__RULE;
203
+ constructor(lang?: string);
204
+ notEnum(): this;
205
+ choices(...values: any[]): this;
206
+ validate(value: any): ValidationResult;
207
+ private notEnumValidation;
208
+ }
209
+ declare class StringSchema$1 extends JONDefaultSchema {
210
+ private _maxValue;
211
+ private _minValue;
212
+ private _lessValue;
213
+ private _greaterValue;
214
+ private _lengthValue;
215
+ private _format;
216
+ private _dateFormat;
217
+ private _timeFormat;
218
+ private _enum_choices;
219
+ private _not_enum_choices;
220
+ private _STRING__RULE;
221
+ private _STRING__MIN__RULE;
222
+ private _STRING__MAX__RULE;
223
+ private _STRING__LESS__RULE;
224
+ private _STRING__GREATER__RULE;
225
+ private _STRING__LENGTH__RULE;
226
+ private _STRING__REGEXP__RULE;
227
+ private _STRING__ALPHANUM__RULE;
228
+ private _STRING__BASE64__RULE;
229
+ private _STRING__LOWERCASE__RULE;
230
+ private _STRING__UPPERCASE__RULE;
231
+ private _STRING__CAPITALIZE__RULE;
232
+ private _STRING__UC_FIRST__RULE;
233
+ private _STRING__CREDIT_CARD__RULE;
234
+ private _STRING__DATAURI__RULE;
235
+ private _STRING__DOMAIN__RULE;
236
+ private _STRING__URL__RULE;
237
+ private _STRING__HOSTNAME__RULE;
238
+ private _STRING__IP_ADDRESS__RULE;
239
+ private _STRING__EMAIL__RULE;
240
+ private _STRING__GUID__RULE;
241
+ private _STRING__HEXA__RULE;
242
+ private _STRING__BINARY__RULE;
243
+ private _STRING__DATE__RULE;
244
+ private _STRING__IDENTIFIER__RULE;
245
+ private _STRING__ENUM__RULE;
246
+ private _STRING__NOT_ENUM__RULE;
247
+ constructor(lang?: string);
248
+ string(): this;
249
+ min(minValue: number): this;
250
+ max(maxValue: number): this;
251
+ less(lessValue: number): this;
252
+ greater(greaterValue: number): this;
253
+ length(lengthValue: number): this;
254
+ regexp(ruleValue: string | RegExp, flag?: string | undefined, errorMap?: ((lang: string, label: string) => {
255
+ [key: string]: string;
256
+ }) | undefined): this;
257
+ alphanum(): this;
258
+ base64(paddingRequired?: boolean, urlSafe?: boolean): this;
259
+ lowercase(strictMode?: boolean): this;
260
+ uppercase(strictMode?: boolean): this;
261
+ capitalize(strictMode?: boolean): this;
262
+ ucFirst(strictMode?: boolean): this;
263
+ creditCard(types?: string[]): this;
264
+ dataUri(): this;
265
+ domain(): this;
266
+ url(): this;
267
+ hostname(): this;
268
+ IPAddress(types?: string[]): this;
269
+ email(): this;
270
+ guid(types?: string[]): this;
271
+ hexa(insensitive?: boolean): this;
272
+ binary(): this;
273
+ date(format?: string | undefined): this;
274
+ identifier(): this;
275
+ enum(...values: any[]): this;
276
+ enumChoices(...values: any[]): this;
277
+ notEnum(...values: any[]): this;
278
+ notEnumchoices(...values: any[]): this;
279
+ changeFormat(newFormat: string): this;
280
+ validate(value: any): ValidationResult;
281
+ private stringValidation;
282
+ }
283
+ declare class NumberSchema$1 extends JONDefaultSchema {
284
+ private _NUMBER__RULE;
285
+ private _NUMBER__MIN__RULE;
286
+ private _NUMBER__MAX__RULE;
287
+ private _NUMBER__LESS__RULE;
288
+ private _NUMBER__GREATER__RULE;
289
+ private _NUMBER__NEGATIVE__RULE;
290
+ private _NUMBER__POSITIVE__RULE;
291
+ private _NUMBER__SIGNED__RULE;
292
+ private _NUMBER__INTEGER__RULE;
293
+ private _NUMBER__DECIMAL__RULE;
294
+ private _NUMBER__MULTIPLE__RULE;
295
+ private _NUMBER__TCP_PORT__RULE;
296
+ constructor(lang?: string);
297
+ number(): this;
298
+ min(minValue: number): this;
299
+ max(maxValue: number): this;
300
+ less(lessValue: number): this;
301
+ greater(greaterValue: number): this;
302
+ negative(): this;
303
+ positive(): this;
304
+ signed(): this;
305
+ integer(): this;
306
+ decimal(): this;
307
+ multiple(nber: number): this;
308
+ TCPPort(): this;
309
+ validate(value: any): ValidationResult;
310
+ private numberValidation;
311
+ }
312
+ declare class BooleanSchema$1 extends JONDefaultSchema {
313
+ private _trueValues;
314
+ private _falseValues;
315
+ private _BOOLEAN__RULE;
316
+ constructor(lang?: string);
317
+ boolean(): this;
318
+ required(isRequired?: boolean): this;
319
+ trueValues(valueInitial: any[]): this;
320
+ falseValues(valueInitial: any[]): this;
321
+ validate(value: any): ValidationResult;
322
+ private booleanValidation;
323
+ getMapError(): Function;
324
+ }
325
+ declare class DateSchema$1 extends JONDefaultSchema {
326
+ private _timezone;
327
+ private _format;
328
+ private _dateFormat;
329
+ private _timeFormat;
330
+ private _maxValue;
331
+ private _minValue;
332
+ private _lessValue;
333
+ private _greaterValue;
334
+ private _equalValue;
335
+ private _DATE__RULE;
336
+ private _DATE__MIN__RULE;
337
+ private _DATE__MAX__RULE;
338
+ private _DATE__LESS__RULE;
339
+ private _DATE__GREATER__RULE;
340
+ private _DATE__EQUAL_TO__RULE;
341
+ private _DATE__TO_DATE__RULE;
342
+ private _DATE__TO_TIME__RULE;
343
+ constructor(lang?: string);
344
+ date(): this;
345
+ min(minValue: any): this;
346
+ max(maxValue: any): this;
347
+ less(lessValue: any): this;
348
+ greater(greaterValue: any): this;
349
+ equalTo(equalValue: any): this;
350
+ changeFormat(newFormat: string): this;
351
+ changeTimezone(newTimezone: string): this;
352
+ validate(value: any): ValidationResult;
353
+ private dateValidation;
354
+ }
355
+ declare class AnyTypeSchema$1 extends JONDefaultSchema {
356
+ private _ANY_TYPE__RULE;
357
+ constructor(lang?: string);
358
+ anyType(): this;
359
+ validate(value: any): ValidationResult;
360
+ private anyTypeValidation;
361
+ }
362
+ declare class FileSchema extends JONDefaultSchema {
363
+ private _maxValue;
364
+ private _minValue;
365
+ private _lessValue;
366
+ private _greaterValue;
367
+ private _lengthValue;
368
+ private _FILE__RULE;
369
+ private _FILE__MIN__RULE;
370
+ private _FILE__MAX__RULE;
371
+ private _FILE__LESS__RULE;
372
+ private _FILE__GREATER__RULE;
373
+ private _FILE__LENGTH__RULE;
374
+ constructor(lang?: string);
375
+ file(): this;
376
+ min(minValue: number): this;
377
+ max(maxValue: number): this;
378
+ less(lessValue: number): this;
379
+ greater(greaterValue: number): this;
380
+ length(lengthValue: number): this;
381
+ validate(value: any): ValidationResult;
382
+ private fileValidation;
383
+ /**
384
+ * Convertit un DataURL (data:image/png;base64,...) en File
385
+ * @param dataUrl Le dataURI complet
386
+ * @param fileName Nom du fichier à générer
387
+ */
388
+ private dataUrlToFile;
389
+ }
390
+ declare const _default$1: {
391
+ String: typeof StringSchema$1;
392
+ Number: typeof NumberSchema$1;
393
+ Boolean: typeof BooleanSchema$1;
394
+ Date: typeof DateSchema$1;
395
+ Enum: typeof EnumSchema$1;
396
+ NotEnum: typeof NotEnumSchema$1;
397
+ Array: typeof ArraySchema$1;
398
+ File: typeof FileSchema;
399
+ Object: typeof ObjectSchema$1;
400
+ ChosenType: typeof ChosenTypeSchema$1;
401
+ AnyType: typeof AnyTypeSchema$1;
402
+ };
403
+
404
+ declare global {
405
+ interface Window {
406
+ JON: typeof _default$1;
407
+ }
408
+ }
409
+ declare const StringSchema: typeof StringSchema$1;
410
+ declare const NumberSchema: typeof NumberSchema$1;
411
+ declare const BooleanSchema: typeof BooleanSchema$1;
412
+ declare const DateSchema: typeof DateSchema$1;
413
+ declare const EnumSchema: typeof EnumSchema$1;
414
+ declare const NotEnumSchema: typeof NotEnumSchema$1;
415
+ declare const ArraySchema: typeof ArraySchema$1;
416
+ declare const ObjectSchema: typeof ObjectSchema$1;
417
+ declare const ChosenTypeSchema: typeof ChosenTypeSchema$1;
418
+ declare const AnyTypeSchema: typeof AnyTypeSchema$1;
419
+ declare const _default: {
420
+ String: typeof StringSchema$1;
421
+ Number: typeof NumberSchema$1;
422
+ Boolean: typeof BooleanSchema$1;
423
+ Date: typeof DateSchema$1;
424
+ Enum: typeof EnumSchema$1;
425
+ NotEnum: typeof NotEnumSchema$1;
426
+ Array: typeof ArraySchema$1;
427
+ File: typeof FileSchema;
428
+ Object: typeof ObjectSchema$1;
429
+ ChosenType: typeof ChosenTypeSchema$1;
430
+ AnyType: typeof AnyTypeSchema$1;
431
+ };
432
+
433
+ export { AnyTypeSchema, ArraySchema, BooleanSchema, ChosenTypeSchema, DateSchema, EnumSchema, NotEnumSchema, NumberSchema, ObjectSchema, StringSchema, _default as default };