@bolttech/form-engine-core 0.0.1-beta.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.
Files changed (40) hide show
  1. package/index.esm.d.ts +1 -0
  2. package/index.esm.js +3518 -0
  3. package/package.json +14 -0
  4. package/src/formatters/creditCard.d.ts +23 -0
  5. package/src/formatters/custom.d.ts +29 -0
  6. package/src/formatters/handler.d.ts +2 -0
  7. package/src/formatters/regex.d.ts +47 -0
  8. package/src/formatters/splitter.d.ts +17 -0
  9. package/src/formatters/string.d.ts +88 -0
  10. package/src/helpers/creditCard.d.ts +95 -0
  11. package/src/helpers/helpers.d.ts +64 -0
  12. package/src/index.d.ts +10 -0
  13. package/src/interfaces/schema.d.ts +82 -0
  14. package/src/interfaces/state.d.ts +27 -0
  15. package/src/managers/field.d.ts +294 -0
  16. package/src/managers/form.d.ts +224 -0
  17. package/src/managers/formGroup.d.ts +64 -0
  18. package/src/masks/creditCard.d.ts +60 -0
  19. package/src/masks/generic.d.ts +39 -0
  20. package/src/masks/handler.d.ts +2 -0
  21. package/src/masks/string.d.ts +97 -0
  22. package/src/types/event.d.ts +43 -0
  23. package/src/types/form.d.ts +51 -0
  24. package/src/types/mapper.d.ts +94 -0
  25. package/src/types/schema.d.ts +742 -0
  26. package/src/types/template.d.ts +32 -0
  27. package/src/types/utility.d.ts +4 -0
  28. package/src/validations/creditCard.d.ts +52 -0
  29. package/src/validations/custom.d.ts +25 -0
  30. package/src/validations/date.d.ts +78 -0
  31. package/src/validations/document.d.ts +25 -0
  32. package/src/validations/handler.d.ts +2 -0
  33. package/src/validations/length.d.ts +39 -0
  34. package/src/validations/list.d.ts +32 -0
  35. package/src/validations/logical.d.ts +75 -0
  36. package/src/validations/multiple.d.ts +31 -0
  37. package/src/validations/number.d.ts +115 -0
  38. package/src/validations/object.d.ts +44 -0
  39. package/src/validations/regex.d.ts +217 -0
  40. package/src/validations/string.d.ts +53 -0
@@ -0,0 +1,742 @@
1
+ /// <reference types="node" />
2
+ /** @virtual */
3
+ import { TCurrencyCode, TCurrencyLocalCode } from '@gaignoux/currency';
4
+ import { OutgoingHttpHeaders } from 'http2';
5
+ import { TEvents } from './event';
6
+ /**
7
+ * @type TLengthValidation
8
+ * Represents the validation rules based on the length of the input.
9
+ *
10
+ * @property {'equal' | 'notEqual' | 'less' | 'lessOrEqual' | 'greater' | 'greaterOrEqual'} rule - The rule to apply.
11
+ * @property {number} target - The target value to compare against.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const lengthValidation: TLengthValidation = { rule: 'greaterOrEqual', target: 8 };
16
+ * ```
17
+ */
18
+ type TLengthValidation = {
19
+ rule: 'equal' | 'notEqual' | 'less' | 'lessOrEqual' | 'greater' | 'greaterOrEqual';
20
+ target: number;
21
+ };
22
+ /**
23
+ * @type TCallbackValidation
24
+ * A custom validation function.
25
+ *
26
+ * @param {unknown} value - The value to validate.
27
+ * @returns {boolean} - The result of the validation.
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * const callbackValidation: TCallbackValidation = (value) => typeof value === 'string';
32
+ * ```
33
+ */
34
+ type TCallbackValidation = (value: unknown) => boolean;
35
+ /**
36
+ * @type TBetweenValidation
37
+ * Represents validation rules that check if a value is between a range.
38
+ *
39
+ * @property {number} start - The start of the range.
40
+ * @property {number} end - The end of the range.
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * const betweenValidation: TBetweenValidation = { start: 1, end: 10 };
45
+ * ```
46
+ */
47
+ type TBetweenValidation = {
48
+ start: number;
49
+ end: number;
50
+ };
51
+ /**
52
+ * @type TCreditCardMatch
53
+ * Represents the options for credit card matching.
54
+ *
55
+ * @property {string} numberCard - The credit card number.
56
+ * @property {string[]} availableOptions - The available options for matching.
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * const creditCardMatch: TCreditCardMatch = { numberCard: '1234', availableOptions: ['Visa', 'MasterCard'] };
61
+ * ```
62
+ */
63
+ type TCreditCardMatch = {
64
+ numberCard: string;
65
+ availableOptions: string[];
66
+ };
67
+ /**
68
+ * @type TDocumentValidation
69
+ * Represents validation for specific document types.
70
+ *
71
+ * @property {'NIF' | 'NIE' | 'CIF' | 'IBAN'} type - The type of document.
72
+ * @property {TCurrencyLocalCode} [locale] - The locale code for validation.
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * const documentValidation: TDocumentValidation = { type: 'NIF', locale: 'ES' };
77
+ * ```
78
+ */
79
+ type TDocumentValidation = {
80
+ type: 'NIF' | 'NIE' | 'CIF' | 'IBAN';
81
+ locale?: TCurrencyLocalCode;
82
+ };
83
+ /**
84
+ * @type TDateOperatorsValidation
85
+ * Represents the operators used for date validation conditions.
86
+ *
87
+ * @property {'<' | '>' | '===' | '>=' | '<=' | '!==' | '!!origin'}
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * const operator: TDateOperatorsValidation = '<';
92
+ * ```
93
+ */
94
+ type TDateOperatorsValidation = '<' | '>' | '===' | '>=' | '<=' | '!==' | '!!origin';
95
+ /**
96
+ * @type TConditionsValidationSet
97
+ * Represents a single validation condition set.
98
+ *
99
+ * @property {boolean} [forceDefinedOrigin] - Flag to force the origin value to be defined.
100
+ * @property {boolean} [forceDefinedTarget] - Flag to force the target value to be defined.
101
+ * @property {string | number | boolean} [origin] - The origin value for the condition.
102
+ * @property {TDateOperatorsValidation} condition - The validation condition operator.
103
+ * @property {string | number | boolean} [target] - The target value for the condition.
104
+ *
105
+ * @example
106
+ * ```typescript
107
+ * const conditionSet: TConditionsValidationSet = {
108
+ * forceDefinedOrigin: true,
109
+ * forceDefinedTarget: true,
110
+ * origin: '2023-01-01',
111
+ * condition: '>',
112
+ * target: '2022-01-01'
113
+ * };
114
+ * ```
115
+ */
116
+ type TConditionsValidationSet = {
117
+ forceDefinedOrigin?: boolean;
118
+ forceDefinedTarget?: boolean;
119
+ origin?: string | number | boolean;
120
+ condition: TDateOperatorsValidation;
121
+ target?: string | number | boolean;
122
+ };
123
+ /**
124
+ * @type TConditionsValidation
125
+ * Represents a set of validation conditions.
126
+ *
127
+ * @property {'and' | 'or'} rule - The logical rule to combine the conditions (AND/OR).
128
+ * @property {TConditionsValidationSet[]} set - The array of validation condition sets.
129
+ * @property {TConditionsValidation} [conditions] - Nested conditions for more complex validation logic.
130
+ *
131
+ * @example
132
+ * ```typescript
133
+ * const conditionsValidation: TConditionsValidation = {
134
+ * rule: 'and',
135
+ * set: [
136
+ * {
137
+ * forceDefinedOrigin: true,
138
+ * forceDefinedTarget: true,
139
+ * origin: '2023-01-01',
140
+ * condition: '>',
141
+ * target: '2022-01-01'
142
+ * }
143
+ * ],
144
+ * conditions: {
145
+ * rule: 'or',
146
+ * set: [
147
+ * {
148
+ * origin: true,
149
+ * condition: '!!origin',
150
+ * target: false
151
+ * }
152
+ * ]
153
+ * }
154
+ * };
155
+ * ```
156
+ */
157
+ type TConditionsValidation = {
158
+ rule: 'and' | 'or';
159
+ set: TConditionsValidationSet[];
160
+ conditions?: TConditionsValidation;
161
+ };
162
+ type TAvailableValidations = Omit<TValidationMethods, 'multipleValidations'>;
163
+ /**
164
+ * @type TMultipleValidation
165
+ * Represents a set of multiple validation methods combined with a logical rule.
166
+ *
167
+ * @property {'AND' | 'OR' | 'NOT'} rule - The logical rule to combine the validation methods (AND, OR, NOT).
168
+ * @property {TAvailableValidations} validations - The validation methods to be combined.
169
+ *
170
+ * @example
171
+ * ```typescript
172
+ * const multipleValidation: TMultipleValidation = {
173
+ * rule: 'AND',
174
+ * validations: {
175
+ * required: true,
176
+ * min: 5,
177
+ * max: 10
178
+ * }
179
+ * };
180
+ * ```
181
+ */
182
+ type TMultipleValidation = {
183
+ rule: 'AND' | 'OR' | 'NOT';
184
+ validations: TAvailableValidations;
185
+ };
186
+ /**
187
+ * @type TBetweenDatesValidation
188
+ * Represents a validation method to check if a value falls between specified dates.
189
+ *
190
+ * @property {TDateValidation[]} [TBetweenDatesValidation] - An array of date validation methods.
191
+ *
192
+ * @example
193
+ * ```typescript
194
+ * const betweenDatesValidation: TBetweenDatesValidation = [
195
+ * {
196
+ * onlyValidDate: true,
197
+ * operator: '>=',
198
+ * origin: {
199
+ * format: 'MMDDYYYY',
200
+ * intervals: {
201
+ * years: 1
202
+ * }
203
+ * },
204
+ * target: {
205
+ * value: Date.now(),
206
+ * format: 'timestamp',
207
+ * value: '01/01/2023',
208
+ * }
209
+ * },
210
+ * {
211
+ * onlyValidDate: true,
212
+ * operator: '<=',
213
+ * origin: {
214
+ * format: 'MMDDYYYY',
215
+ * intervals: {
216
+ * years: 1
217
+ * }
218
+ * },
219
+ * target: {
220
+ * format: 'timestamp',
221
+ * value: '31/12/2023',
222
+ * }
223
+ * }
224
+ * ];
225
+ * ```
226
+ */
227
+ type TBetweenDatesValidation = TDateValidation[];
228
+ /**
229
+ * @type TDateFormatsValidation
230
+ * Represents the supported date formats for validation.
231
+ *
232
+ * @type {'MMDDYYYY' | 'DDMMYYYY' | 'YYYYMMDD' | 'YYYYDDMM' | 'timestamp'}
233
+ *
234
+ * @example
235
+ * ```typescript
236
+ * const dateFormat: TDateFormatsValidation = 'MMDDYYYY';
237
+ * ```
238
+ */
239
+ type TDateFormatsValidation = 'MMDDYYYY' | 'DDMMYYYY' | 'YYYYMMDD' | 'YYYYDDMM' | 'timestamp';
240
+ type TDateInterval = {
241
+ years?: number;
242
+ months?: number;
243
+ days?: number;
244
+ };
245
+ /**
246
+ * @type TDateValidation
247
+ * Represents a validation method for date values.
248
+ *
249
+ * @property {boolean} [onlyValidDate] - Flag to validate only if the date is valid.
250
+ * @property {TDateOperatorsValidation} operator - The validation operator to be used.
251
+ * @property {Object} origin - The origin date configuration.
252
+ * @property {string | number} [origin.value] - The origin date value.
253
+ * @property {TDateFormatsValidation} origin.format - The format of the origin date.
254
+ * @property {Object} [origin.intervals] - The intervals to add to the origin date for comparison.
255
+ * @property {number} [origin.intervals.years] - The number of years to add.
256
+ * @property {number} [origin.intervals.months] - The number of months to add.
257
+ * @property {number} [origin.intervals.days] - The number of days to add.
258
+ * @property {Object} [target] - The target date configuration.
259
+ * @property {string | number} target.value - The target date value.
260
+ * @property {TDateFormatsValidation} target.format - The format of the target date.
261
+ *
262
+ * @example
263
+ * ```typescript
264
+ * const dateValidation: TDateValidation = {
265
+ * onlyValidDate: true,
266
+ * operator: '===',
267
+ * origin: {
268
+ * value: '10/10/2022',
269
+ * format: 'MMDDYYYY',
270
+ * intervals: {
271
+ * years: 1
272
+ * }
273
+ * },
274
+ * target: {
275
+ * value: Date.now(),
276
+ * format: 'timestamp'
277
+ * }
278
+ * };
279
+ * ```
280
+ */
281
+ type TDateValidation = {
282
+ onlyValidDate?: boolean;
283
+ operator: TDateOperatorsValidation;
284
+ origin: {
285
+ value?: string | number;
286
+ format: TDateFormatsValidation;
287
+ /**
288
+ * Intervals to compare with the original date.
289
+ *
290
+ * It will use today's date for comparison.
291
+ *
292
+ * @example
293
+ * ```typescript
294
+ * origin date = 10/10/2022
295
+ * interval.year = 1
296
+ * operator = '==='
297
+ * ```
298
+ *
299
+ * It will compare (10/10/2022 + 1) with the current date and check if they are the same
300
+ */
301
+ intervals?: TDateInterval;
302
+ };
303
+ target?: {
304
+ value: string | number;
305
+ format: TDateFormatsValidation;
306
+ };
307
+ };
308
+ /**
309
+ * @type TValidationMethods
310
+ * Represents the various validation methods that can be applied to form fields.
311
+ *
312
+ * @property {number} [max] - Maximum value or length.
313
+ * @property {number} [min] - Minimum value or length.
314
+ * @property {TLengthValidation} [length] - Length validation rule.
315
+ * @property {boolean} [required] - Indicates if the field is required.
316
+ * @property {number} [greaterThan] - Value must be greater than this number.
317
+ * @property {unknown} [value] - Specific value to match.
318
+ * @property {string} [regex] - Regular expression for validation.
319
+ * @property {boolean} [email] - Indicates if the value should be a valid email.
320
+ * @property {boolean} [url] - Indicates if the value should be a valid URL.
321
+ * @property {boolean} [onlyLetters] - Indicates if the value should contain only letters.
322
+ * @property {boolean} [notAllowSpaces] - Indicates if spaces are not allowed.
323
+ * @property {TCallbackValidation} [callback] - Custom validation callback function.
324
+ * @property {boolean} [isNumber] - Indicates if the value should be a number.
325
+ * @property {boolean} [bool] - Indicates if the value should be a boolean or a string that can be converted to a boolean.
326
+ * @property {boolean | string} [exists] - Indicates if the value should exist or match a specific existence condition.
327
+ * @property {boolean} [hasNoExtraSpaces] - Indicates if there should be no extra spaces.
328
+ * @property {boolean} [notEmpty] - Indicates if the field should not be empty.
329
+ * @property {TBetweenValidation} [between] - Validation rule for range between two values.
330
+ * @property {boolean} [sequential] - Indicates if the value should be sequential.
331
+ * @property {boolean} [repeated] - Indicates if the value should not be repeated.
332
+ * @property {string[] | number[]} [includes] - Array of values that should be included.
333
+ * @property {string[]} [isCreditCard] - Array of valid credit card numbers.
334
+ * @property {TCreditCardMatch} [isCreditCodeMatch] - Validation rule for credit card matching.
335
+ * @property {string[]} [isCreditCardAndLength] - Array of valid credit card numbers with length check.
336
+ * @property {TDocumentValidation} [document] - Document validation rule.
337
+ * @property {TConditionsValidation} [conditions] - Conditional validation rules.
338
+ * @property {TMultipleValidation} [multipleValidations] - Multiple validation rules combined with a logical rule.
339
+ * @property {TBetweenDatesValidation} [betweenDates] - Validation rule for checking if a date falls between two dates.
340
+ * @property {TDateValidation} [date] - Validation rule for date values.
341
+ * @property {TDateFormatsValidation} [validDate] - Validation rule for valid date formats.
342
+ *
343
+ * @example
344
+ * ```typescript
345
+ * const validationMethods: TValidationMethods = {
346
+ * max: 100,
347
+ * min: 1,
348
+ * length: { rule: 'greaterOrEqual', target: 8 },
349
+ * required: true,
350
+ * regex: '^[a-zA-Z0-9]+$',
351
+ * email: true,
352
+ * conditions: {
353
+ * rule: 'and',
354
+ * set: [
355
+ * {
356
+ * forceDefinedOrigin: true,
357
+ * forceDefinedTarget: true,
358
+ * origin: '2023-01-01',
359
+ * condition: '>',
360
+ * target: '2022-01-01'
361
+ * }
362
+ * ]
363
+ * },
364
+ * multipleValidations: {
365
+ * rule: 'AND',
366
+ * validations: {
367
+ * required: true,
368
+ * min: 5,
369
+ * max: 10
370
+ * }
371
+ * },
372
+ * betweenDates: {
373
+ * start: Date.parse('2023-01-01'),
374
+ * end: Date.parse('2023-12-31'),
375
+ * isIncludedBoundaries: true
376
+ * },
377
+ * date: {
378
+ * operator: '===',
379
+ * origin: {
380
+ * value: '10/10/2022',
381
+ * format: 'MMDDYYYY',
382
+ * intervals: {
383
+ * years: 1
384
+ * }
385
+ * },
386
+ * target: {
387
+ * value: Date.now(),
388
+ * format: 'timestamp'
389
+ * }
390
+ * },
391
+ * validDate: 'MMDDYYYY'
392
+ * };
393
+ * ```
394
+ */
395
+ type TValidationMethods = {
396
+ max?: number;
397
+ min?: number;
398
+ length?: TLengthValidation;
399
+ required?: boolean;
400
+ greaterThan?: number;
401
+ value?: unknown;
402
+ regex?: string;
403
+ email?: boolean;
404
+ url?: boolean;
405
+ onlyLetters?: boolean;
406
+ notAllowSpaces?: boolean;
407
+ callback?: TCallbackValidation;
408
+ isNumber?: boolean;
409
+ bool?: boolean | string;
410
+ exists?: boolean | string;
411
+ hasNoExtraSpaces?: boolean;
412
+ notEmpty?: boolean;
413
+ between?: TBetweenValidation;
414
+ sequential?: boolean;
415
+ repeated?: boolean;
416
+ includes?: (string | number)[];
417
+ isCreditCard?: string[];
418
+ isCreditCodeMatch?: TCreditCardMatch;
419
+ isCreditCardAndLength?: string[];
420
+ document?: TDocumentValidation;
421
+ conditions?: TConditionsValidation;
422
+ multipleValidations?: TMultipleValidation;
423
+ betweenDates?: TBetweenDatesValidation;
424
+ date?: TDateValidation;
425
+ validDate?: TDateFormatsValidation;
426
+ };
427
+ /**
428
+ * Formatter types
429
+ * @type TSplitterFormatterValue
430
+ * Represents a value and its position for splitting or formatting purposes.
431
+ *
432
+ * @property {string} value - The value to be split or formatted.
433
+ * @property {number} position - The position for splitting or formatting.
434
+ *
435
+ * @example
436
+ * ```typescript
437
+ * const splitterFormatter: TSplitterFormatterValue = { value: '-', position: 3 };
438
+ * ```
439
+ */
440
+ type TSplitterFormatterValue = {
441
+ value: string;
442
+ position: number;
443
+ };
444
+ /**
445
+ * @type TFormatters
446
+ * Represents the various formatting options that can be applied to form field values.
447
+ *
448
+ * @property {boolean} [dotEvery3chars] - Add a dot every 3 characters.
449
+ * @property {boolean} [capitalize] - Capitalize the value.
450
+ * @property {boolean} [uppercase] - Convert the value to uppercase.
451
+ * @property {boolean} [onlyNumbers] - Allow only numbers.
452
+ * @property {boolean} [onlyLetters] - Allow only letters.
453
+ * @property {Pick<TCurrencyMask, 'precision' | 'decimal'>} [onlyFloatNumber] - Allow only float numbers with specific precision and decimal.
454
+ * @property {string} [regex] - Regular expression for formatting.
455
+ * @property {string[]} [gapsCreditCard] - Gaps to insert in credit card numbers.
456
+ * @property {(value: unknown) => unknown} [callback] - Custom formatter callback function.
457
+ * @property {TSplitterFormatterValue[]} [splitter] - Splitter values for formatting.
458
+ * @property {boolean} [trim] - Removes whitespace from both ends of this string and returns a new string, without modifying the original string.
459
+ * @property {number} [maxLength] - Truncates the input value to a specified maximum length if necessary.
460
+ *
461
+ * @example
462
+ * ```typescript
463
+ * const formatters: TFormatters = {
464
+ * dotEvery3chars: true,
465
+ * capitalize: true,
466
+ * uppercase: true,
467
+ * onlyNumbers: true,
468
+ * regex: '^[a-zA-Z0-9]+$',
469
+ * gapsCreditCard: [' ', ' '],
470
+ * callback: (value) => value.toString().toUpperCase(),
471
+ * splitter: [{ value: '-', position: 3 }],
472
+ * trim: true,
473
+ * maxLength: 15
474
+ * };
475
+ * ```
476
+ */
477
+ type TFormatters = {
478
+ dotEvery3chars?: boolean;
479
+ capitalize?: boolean;
480
+ uppercase?: boolean;
481
+ onlyNumbers?: boolean;
482
+ onlyLetters?: boolean;
483
+ onlyFloatNumber?: Pick<TCurrencyMask, 'precision' | 'decimal'>;
484
+ regex?: string;
485
+ gapsCreditCard?: string[];
486
+ callback?: (value: unknown) => unknown;
487
+ splitter?: TSplitterFormatterValue[];
488
+ trim?: boolean;
489
+ maxLength?: number;
490
+ };
491
+ /**
492
+ * Mask types
493
+ * @type TCurrencyMask
494
+ * Represents the mask configuration for currency values.
495
+ *
496
+ * @property {'left' | 'right'} [align] - The alignment of the currency symbol. (default: right)
497
+ * @property {string} [decimal] - The decimal separator. (default: '.')
498
+ * @property {number} [precision] - The number of decimal places. (default: 2)
499
+ * @property {TCurrencyCode} [prefix] - The currency symbol prefix. (default: '$')
500
+ * @property {string} [thousands] - The thousands separator. (default: ',')
501
+ *
502
+ * @example
503
+ * ```typescript
504
+ * const currencyMask: TCurrencyMask = {
505
+ * align: 'left',
506
+ * decimal: '.',
507
+ * precision: 2,
508
+ * prefix: '$',
509
+ * thousands: ','
510
+ * };
511
+ * ```
512
+ */
513
+ type TCurrencyMask = {
514
+ align?: 'left' | 'right';
515
+ decimal?: string;
516
+ precision?: number;
517
+ prefix?: TCurrencyCode;
518
+ thousands?: string;
519
+ };
520
+ /**
521
+ * @type TMaskGeneric
522
+ * Represents a generic mask configuration.
523
+ *
524
+ * @property {number} to - The ending position of the mask.
525
+ * @property {number} from - The starting position of the mask.
526
+ * @property {string} mask - The mask pattern to apply.
527
+ *
528
+ * @example
529
+ * ```typescript
530
+ * const maskGeneric: TMaskGeneric = { to: 4, from: 0, mask: '****' };
531
+ * ```
532
+ */
533
+ type TMaskGeneric = {
534
+ to: number;
535
+ from: number;
536
+ mask: string;
537
+ };
538
+ /**
539
+ * @type TMasks
540
+ * Represents the different types of masks that can be applied to form field values.
541
+ *
542
+ * @property {TCurrencyMask} [currency] - Mask for currency values.
543
+ * @property {TMaskGeneric[]} [generic] - Array of generic masks.
544
+ * @property {string} [custom] - Custom mask pattern.
545
+ * @property {boolean} [secureCreditCard] - Mask for securing credit card values.
546
+ * @property {boolean} [card] - Mask for card values.
547
+ * @property {boolean} [cardDate] - Mask for card date values.
548
+ * @property {boolean} [fein] - Mask for FEIN (Federal Employer Identification Number).
549
+ * @property {string | number} [replaceAll] - Value to replace all matches.
550
+ * @property {(value: unknown) => string} [callback] - Custom mask callback function.
551
+ *
552
+ * @example
553
+ * ```typescript
554
+ * const masks: TMasks = {
555
+ * currency: { align: 'left', decimal: '.', precision: 2, prefix: '$', thousands: ',' },
556
+ * generic: [{ to: 4, from: 0, mask: '****' }],
557
+ * custom: '###-##-####',
558
+ * secureCreditCard: true,
559
+ * card: true,
560
+ * cardDate: true,
561
+ * fein: true,
562
+ * replaceAll: '*',
563
+ * callback: (value) => value.toString().replace(/\d/g, '*')
564
+ * };
565
+ * ```
566
+ */
567
+ type TMasks = {
568
+ currency?: TCurrencyMask;
569
+ generic?: TMaskGeneric[];
570
+ custom?: string;
571
+ secureCreditCard?: boolean;
572
+ card?: boolean;
573
+ cardDate?: boolean;
574
+ fein?: boolean;
575
+ replaceAll?: string | number;
576
+ callback?(value: unknown): string;
577
+ };
578
+ /**
579
+ * @type TVisibility
580
+ * Represents the visibility conditions for form fields based on validations.
581
+ *
582
+ * @property {TValidationMethods} validations - The validation methods to determine visibility.
583
+ * @property {string[] | string} fields - The fields to be shown or hidden based on validations.
584
+ *
585
+ * @example
586
+ * ```typescript
587
+ * const visibility: TVisibility = {
588
+ * validations: { required: true },
589
+ * fields: ['fieldName']
590
+ * };
591
+ * ```
592
+ */
593
+ type TVisibility = {
594
+ validations: TValidationMethods;
595
+ fields: string[] | string;
596
+ events: Partial<TEvents>[];
597
+ };
598
+ /**
599
+ * @type TResetValueMethods
600
+ * Extends TVisibility with methods to reset values.
601
+ *
602
+ * @property {string[] | string} resettledValue - The values to reset.
603
+ *
604
+ * @example
605
+ * ```typescript
606
+ * const resetValueMethods: TResetValueMethods = {
607
+ * validations: { required: true },
608
+ * fields: ['fieldName'],
609
+ * resettledValue: ['']
610
+ * };
611
+ * ```
612
+ */
613
+ type TResetValueMethods = TVisibility & {
614
+ resettledValue: unknown[] | unknown;
615
+ };
616
+ /**
617
+ * @type TApiConfig
618
+ * Represents the configuration for an API request.
619
+ *
620
+ * @property {'GET' | 'POST'} method - The HTTP method for the request.
621
+ * @property {string} url - The URL for the request.
622
+ * @property {OutgoingHttpHeaders} [headers] - The headers for the request.
623
+ * @property {string} [resultPath] - The path to extract the result from the response.
624
+ * @property {unknown} [fallbackValue] - The fallback value if the request fails.
625
+ * @property {TValidationMethods} preConditions - validation conditions to execute the API call
626
+ * @property {boolean} blockRequestWhenInvalid - blocks request when field validation fails
627
+ *
628
+ * @example
629
+ * ```typescript
630
+ * const apiConfig: TApiConfig = {
631
+ * method: 'POST',
632
+ * url: 'https://api.example.com/data',
633
+ * headers: { 'Content-Type': 'application/json' },
634
+ * resultPath: 'data.results',
635
+ * fallbackValue: [],
636
+ * preConditions: {
637
+ * required: true,
638
+ * }
639
+ * blockRequestWhenInvalid: true,
640
+ * };
641
+ * ```
642
+ */
643
+ type TApiConfig = {
644
+ method: 'GET' | 'POST';
645
+ url: string;
646
+ body?: Record<string, unknown>;
647
+ headers?: OutgoingHttpHeaders;
648
+ resultPath?: string;
649
+ fallbackValue?: unknown;
650
+ preConditions?: TValidationMethods;
651
+ blockRequestWhenInvalid?: boolean;
652
+ };
653
+ /**
654
+ * @type TProps
655
+ * Represents the properties for a component.
656
+ */
657
+ type TProps = Record<string, unknown>;
658
+ /**
659
+ * @type TValidations
660
+ * Represents the validation methods for different events.
661
+ *
662
+ * @example
663
+ * ```typescript
664
+ * const validations: TValidations = {
665
+ * ON_FIELD_BLUR: { required: true }
666
+ * };
667
+ * ```
668
+ */
669
+ type TValidations = Partial<Record<TEvents, TValidationMethods>>;
670
+ /**
671
+ * @type TVisibilityConditions
672
+ * Represents the visibility conditions for different events.
673
+ *
674
+ * @example
675
+ * ```typescript
676
+ * const visibilityConditions: TVisibilityConditions = {
677
+ * ON_FIELD_BLUR: [{ validations: { required: true }, fields: ['fieldName'] }]
678
+ * };
679
+ * ```
680
+ */
681
+ type TVisibilityConditions = Partial<Record<TEvents, TVisibility[]>>;
682
+ /**
683
+ * @type TResetValues
684
+ * Represents the reset value methods for different events.
685
+ *
686
+ * @example
687
+ * ```typescript
688
+ * const resetValues: TResetValues = {
689
+ * ON_FIELD_BLUR: [{ validations: { required: true }, fields: ['fieldName'], resettledValue: [''] }]
690
+ * };
691
+ * ```
692
+ */
693
+ type TResetValues = Partial<Record<TEvents, TResetValueMethods[]>>;
694
+ /**
695
+ * @type TErrorMessages
696
+ * Represents the error messages for different validation methods.
697
+ *
698
+ * @example
699
+ * ```typescript
700
+ * const errorMessages: TErrorMessages = {
701
+ * required: 'This field is required.',
702
+ * max: 'The value cannot exceed the maximum limit.'
703
+ * };
704
+ * ```
705
+ */
706
+ type TErrorMessages = Partial<Record<keyof TValidationMethods, string>>;
707
+ /**
708
+ * Represents an event configuration with a specific type.
709
+ *
710
+ * @template T
711
+ * @property {T} config - The configuration of the event.
712
+ * @property {Partial<TEvents>[]} events - The events associated with the configuration.
713
+ */
714
+ type TEvent<T> = {
715
+ config: T;
716
+ events: Partial<TEvents>[];
717
+ };
718
+ /**
719
+ * Represents the API event configurations.
720
+ *
721
+ * @property {TEvent<TApiConfig>} [defaultConfig] - The default event configuration.
722
+ * @property {Record<string, TEvent<TApiConfig>>} [configs] - Named event configurations.
723
+ */
724
+ type TApiEvent = {
725
+ defaultConfig?: TEvent<TApiConfig>;
726
+ configs?: Record<string, TEvent<TApiConfig>>;
727
+ };
728
+ /**
729
+ * Represents the API response structure.
730
+ *
731
+ * @property {{ response: unknown }} default - The default response.
732
+ * @property {Record<string, { response: unknown }>} [named] - Named responses.
733
+ */
734
+ type TApiResponse = {
735
+ default: {
736
+ response: unknown;
737
+ };
738
+ named?: Record<string, {
739
+ response: unknown;
740
+ }>;
741
+ };
742
+ export { TApiConfig, TErrorMessages, TResetValues, TVisibilityConditions, TValidations, TMasks, TProps, TResetValueMethods, TFormatters, TValidationMethods, TEvent, TVisibility, TApiEvent, TApiResponse, TLengthValidation, TCreditCardMatch, TDocumentValidation, TCallbackValidation, TBetweenValidation, TMaskGeneric, TSplitterFormatterValue, TCurrencyMask, TDateOperatorsValidation, TConditionsValidationSet, TConditionsValidation, TMultipleValidation, TAvailableValidations, TDateValidation, TBetweenDatesValidation, TDateFormatsValidation, TDateInterval, };