@bolttech/form-engine-core 1.0.10 → 1.1.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.
Files changed (64) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/credit-card.d.ts +743 -0
  3. package/credit-card.esm.js +1 -0
  4. package/currency.d.ts +131 -0
  5. package/currency.esm.js +1 -0
  6. package/date.d.ts +582 -0
  7. package/date.esm.js +1 -0
  8. package/document.d.ts +527 -0
  9. package/document.esm.js +1 -0
  10. package/index.d.ts +52 -5
  11. package/index.esm.js +1 -4570
  12. package/lite.d.ts +2393 -0
  13. package/lite.esm.js +1 -0
  14. package/package.json +34 -2
  15. package/src/constants/constants.d.ts +11 -0
  16. package/src/formatters/creditCard.d.ts +23 -0
  17. package/src/formatters/custom.d.ts +29 -0
  18. package/src/formatters/handler.d.ts +2 -0
  19. package/src/formatters/regex.d.ts +47 -0
  20. package/src/formatters/splitter.d.ts +17 -0
  21. package/src/formatters/string.d.ts +88 -0
  22. package/src/helpers/SafeSubject.d.ts +21 -0
  23. package/src/helpers/creditCard.d.ts +95 -0
  24. package/src/helpers/helpers.d.ts +66 -0
  25. package/src/helpers/lodash-replacements.d.ts +41 -0
  26. package/src/helpers/validation.d.ts +28 -0
  27. package/src/index.d.ts +15 -0
  28. package/src/interfaces/schema.d.ts +161 -0
  29. package/src/interfaces/state.d.ts +22 -0
  30. package/src/lite.d.ts +30 -0
  31. package/src/managers/field.d.ts +339 -0
  32. package/src/managers/form.d.ts +357 -0
  33. package/src/managers/formGroup.d.ts +110 -0
  34. package/src/managers/index.d.ts +3 -0
  35. package/src/masks/creditCard.d.ts +60 -0
  36. package/src/masks/currency.d.ts +29 -0
  37. package/src/masks/generic.d.ts +39 -0
  38. package/src/masks/handler.d.ts +2 -0
  39. package/src/masks/string.d.ts +37 -0
  40. package/src/plugins/credit-card.d.ts +4 -0
  41. package/src/plugins/currency.d.ts +2 -0
  42. package/src/plugins/date.d.ts +2 -0
  43. package/src/plugins/document.d.ts +2 -0
  44. package/src/registry.d.ts +20 -0
  45. package/src/types/event.d.ts +175 -0
  46. package/src/types/form.d.ts +55 -0
  47. package/src/types/mapper.d.ts +87 -0
  48. package/src/types/schema.d.ts +1001 -0
  49. package/src/types/template.d.ts +65 -0
  50. package/src/types/utility.d.ts +12 -0
  51. package/src/validations/creditCard.d.ts +52 -0
  52. package/src/validations/custom.d.ts +27 -0
  53. package/src/validations/date.d.ts +79 -0
  54. package/src/validations/document.d.ts +25 -0
  55. package/src/validations/handler.d.ts +2 -0
  56. package/src/validations/length.d.ts +39 -0
  57. package/src/validations/list.d.ts +32 -0
  58. package/src/validations/logical.d.ts +75 -0
  59. package/src/validations/multiple.d.ts +31 -0
  60. package/src/validations/namedRule.d.ts +22 -0
  61. package/src/validations/number.d.ts +145 -0
  62. package/src/validations/object.d.ts +44 -0
  63. package/src/validations/regex.d.ts +217 -0
  64. package/src/validations/string.d.ts +53 -0
@@ -0,0 +1,1001 @@
1
+ /** @virtual */
2
+ import { TCurrencyCode, TCurrencyLocalCode } from '@gaignoux/currency';
3
+ import { TEvents } from './event';
4
+ import { TFormValues } from './form';
5
+ import { ALLOWED_RESET_PROPS_MUTATIONS } from '../constants/constants';
6
+ type TAllowedResetPropsMutations = (typeof ALLOWED_RESET_PROPS_MUTATIONS)[number];
7
+ /**
8
+ * @type TAllowedResetPropsMutationsEnum
9
+ * Represents the allowed properties to be changed on resetPropertyValues.
10
+ *
11
+ * @property {never} api - api property
12
+ * @property {never} apiSchema - apiSchema property
13
+ * @property {never} props - props property
14
+ * @property {never} validations - validations property
15
+ * @property {never} visibilityConditions - visibilityConditions property
16
+ * @property {never} resetValues - resetValues property
17
+ *
18
+ * @interface
19
+ */
20
+ type TAllowedResetPropsMutationsEnum = Record<TAllowedResetPropsMutations, never>;
21
+ /**
22
+ * @type TLengthValidation
23
+ * Represents the validation rules based on the length of the input.
24
+ *
25
+ * @property {'equal' | 'notEqual' | 'less' | 'lessOrEqual' | 'greater' | 'greaterOrEqual'} rule - The rule to apply.
26
+ * @property {number} target - The target value to compare against.
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * const lengthValidation: TLengthValidation = { rule: 'greaterOrEqual', target: 8 };
31
+ * ```
32
+ */
33
+ type TLengthValidation = {
34
+ rule: 'equal' | 'notEqual' | 'less' | 'lessOrEqual' | 'greater' | 'greaterOrEqual';
35
+ target: number;
36
+ };
37
+ /**
38
+ * @type TCallbackValidation
39
+ * A custom validation function.
40
+ *
41
+ * @param {unknown} value - The value to validate.
42
+ * @returns {boolean} - The result of the validation.
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * const callbackValidation: TCallbackValidation = (value) => typeof value === 'string';
47
+ * ```
48
+ */
49
+ type TCallbackValidation = (value: unknown, formValues: Pick<TFormValues<unknown>, 'values' | 'metadata'>) => boolean;
50
+ /**
51
+ * @type TBetweenValidation
52
+ * Represents validation rules that check if a value is between a range.
53
+ *
54
+ * @property {number} start - The start of the range.
55
+ * @property {number} end - The end of the range.
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * const betweenValidation: TBetweenValidation = { start: 1, end: 10 };
60
+ * ```
61
+ */
62
+ type TBetweenValidation = {
63
+ start: number;
64
+ end: number;
65
+ };
66
+ /**
67
+ * @type TCreditCardMatch
68
+ * Represents the options for credit card matching.
69
+ *
70
+ * @property {string} numberCard - The credit card number.
71
+ * @property {string[]} availableOptions - The available options for matching.
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * const creditCardMatch: TCreditCardMatch = { numberCard: '1234', availableOptions: ['Visa', 'MasterCard'] };
76
+ * ```
77
+ */
78
+ type TCreditCardMatch = {
79
+ numberCard: string;
80
+ availableOptions: string[];
81
+ };
82
+ /**
83
+ * @type TDocumentValidation
84
+ * Represents validation for specific document types.
85
+ *
86
+ * @property {'NIF' | 'NIE' | 'CIF' | 'IBAN'} type - The type of document.
87
+ * @property {TCurrencyLocalCode} [locale] - The locale code for validation.
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * const documentValidation: TDocumentValidation = { type: 'NIF', locale: 'ES' };
92
+ * ```
93
+ */
94
+ type TDocumentValidation = {
95
+ type: 'NIF' | 'NIE' | 'CIF' | 'IBAN';
96
+ locale?: TCurrencyLocalCode;
97
+ };
98
+ /**
99
+ * @type TDateOperatorsValidation
100
+ * Represents the operators used for date validation conditions.
101
+ *
102
+ * @property {'<' | '>' | '===' | '>=' | '<=' | '!==' | '!!origin'}
103
+ *
104
+ * @example
105
+ * ```typescript
106
+ * const operator: TDateOperatorsValidation = '<';
107
+ * ```
108
+ */
109
+ type TDateOperatorsValidation = '<' | '>' | '===' | '>=' | '<=' | '!==' | '!!origin';
110
+ /**
111
+ * @type TConditionsValidationSet
112
+ * Represents a single validation condition set.
113
+ *
114
+ * @property {boolean} [forceDefinedOrigin] - Flag to force the origin value to be defined.
115
+ * @property {boolean} [forceDefinedTarget] - Flag to force the target value to be defined.
116
+ * @property {string | number | boolean} [origin] - The origin value for the condition.
117
+ * @property {TDateOperatorsValidation} condition - The validation condition operator.
118
+ * @property {string | number | boolean} [target] - The target value for the condition.
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * const conditionSet: TConditionsValidationSet = {
123
+ * forceDefinedOrigin: true,
124
+ * forceDefinedTarget: true,
125
+ * origin: '2023-01-01',
126
+ * condition: '>',
127
+ * target: '2022-01-01'
128
+ * };
129
+ * ```
130
+ */
131
+ type TConditionsValidationSet = {
132
+ forceDefinedOrigin?: boolean;
133
+ forceDefinedTarget?: boolean;
134
+ origin?: string | number | boolean | null;
135
+ condition: TDateOperatorsValidation;
136
+ target?: string | number | boolean;
137
+ };
138
+ /**
139
+ * @type TConditionsValidation
140
+ * Represents a set of validation conditions.
141
+ *
142
+ * @property {'and' | 'or'} rule - The logical rule to combine the conditions (AND/OR).
143
+ * @property {TConditionsValidationSet[]} set - The array of validation condition sets.
144
+ * @property {TConditionsValidation} [conditions] - Nested conditions for more complex validation logic.
145
+ *
146
+ * @example
147
+ * ```typescript
148
+ * const conditionsValidation: TConditionsValidation = {
149
+ * rule: 'and',
150
+ * set: [
151
+ * {
152
+ * forceDefinedOrigin: true,
153
+ * forceDefinedTarget: true,
154
+ * origin: '2023-01-01',
155
+ * condition: '>',
156
+ * target: '2022-01-01'
157
+ * }
158
+ * ],
159
+ * conditions: {
160
+ * rule: 'or',
161
+ * set: [
162
+ * {
163
+ * origin: true,
164
+ * condition: '!!origin',
165
+ * target: false
166
+ * }
167
+ * ]
168
+ * }
169
+ * };
170
+ * ```
171
+ */
172
+ type TConditionsValidation = {
173
+ rule: 'and' | 'or';
174
+ set: TConditionsValidationSet[];
175
+ conditions?: TConditionsValidation;
176
+ };
177
+ type TAvailableValidations = Omit<TValidationMethods, 'multipleValidations'> | TGenericValidationRule;
178
+ /**
179
+ * @type TMultipleValidation
180
+ * Represents a set of multiple validation methods combined with a logical rule.
181
+ *
182
+ * @property {'AND' | 'OR' | 'NOT'} rule - The logical rule to combine the validation methods (AND, OR, NOT).
183
+ * @property {TAvailableValidations} validations - The validation methods to be combined.
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * const multipleValidation: TMultipleValidation = {
188
+ * rule: 'AND',
189
+ * validations: {
190
+ * required: true,
191
+ * min: 5,
192
+ * max: 10
193
+ * }
194
+ * };
195
+ * ```
196
+ */
197
+ type TMultipleValidation = {
198
+ rule: 'AND' | 'OR' | 'NOT';
199
+ validations: TAvailableValidations;
200
+ };
201
+ /**
202
+ * @type TBetweenDatesValidation
203
+ * Represents a validation method to check if a value falls between specified dates.
204
+ *
205
+ * @property {TDateValidation[]} [TBetweenDatesValidation] - An array of date validation methods.
206
+ *
207
+ * @example
208
+ * ```typescript
209
+ * const betweenDatesValidation: TBetweenDatesValidation = [
210
+ * {
211
+ * onlyValidDate: true,
212
+ * operator: '>=',
213
+ * origin: {
214
+ * format: 'MMDDYYYY',
215
+ * intervals: {
216
+ * years: 1
217
+ * }
218
+ * },
219
+ * target: {
220
+ * value: Date.now(),
221
+ * format: 'timestamp',
222
+ * value: '01/01/2023',
223
+ * }
224
+ * },
225
+ * {
226
+ * onlyValidDate: true,
227
+ * operator: '<=',
228
+ * origin: {
229
+ * format: 'MMDDYYYY',
230
+ * intervals: {
231
+ * years: 1
232
+ * }
233
+ * },
234
+ * target: {
235
+ * format: 'timestamp',
236
+ * value: '31/12/2023',
237
+ * }
238
+ * }
239
+ * ];
240
+ * ```
241
+ */
242
+ type TBetweenDatesValidation = TDateValidation[];
243
+ /**
244
+ * @type TDateFormatsValidation
245
+ * Represents the supported date formats for validation.
246
+ *
247
+ * @type {'MMDDYYYY' | 'DDMMYYYY' | 'YYYYMMDD' | 'YYYYDDMM' | 'timestamp'}
248
+ *
249
+ * @example
250
+ * ```typescript
251
+ * const dateFormat: TDateFormatsValidation = 'MMDDYYYY';
252
+ * ```
253
+ */
254
+ type TDateFormatsValidation = 'MMDDYYYY' | 'DDMMYYYY' | 'YYYYMMDD' | 'YYYYDDMM' | 'timestamp';
255
+ type TDateInterval = {
256
+ years?: number;
257
+ months?: number;
258
+ days?: number;
259
+ };
260
+ /**
261
+ * @type TDateValidation
262
+ * Represents a validation method for date values.
263
+ *
264
+ * @property {boolean} [onlyValidDate] - Flag to validate only if the date is valid.
265
+ * @property {TDateOperatorsValidation} operator - The validation operator to be used.
266
+ * @property {Object} origin - The origin date configuration.
267
+ * @property {string | number} [origin.value] - The origin date value.
268
+ * @property {TDateFormatsValidation} origin.format - The format of the origin date.
269
+ * @property {Object} [origin.intervals] - The intervals to add to the origin date for comparison.
270
+ * @property {number} [origin.intervals.years] - The number of years to add.
271
+ * @property {number} [origin.intervals.months] - The number of months to add.
272
+ * @property {number} [origin.intervals.days] - The number of days to add.
273
+ * @property {Object} [target] - The target date configuration.
274
+ * @property {string | number} target.value - The target date value.
275
+ * @property {TDateFormatsValidation} target.format - The format of the target date.
276
+ *
277
+ * @example
278
+ * ```typescript
279
+ * const dateValidation: TDateValidation = {
280
+ * onlyValidDate: true,
281
+ * operator: '===',
282
+ * origin: {
283
+ * value: '10/10/2022',
284
+ * format: 'MMDDYYYY',
285
+ * intervals: {
286
+ * years: 1
287
+ * }
288
+ * },
289
+ * target: {
290
+ * value: Date.now(),
291
+ * format: 'timestamp'
292
+ * }
293
+ * };
294
+ * ```
295
+ */
296
+ type TDateValidation = {
297
+ onlyValidDate?: boolean;
298
+ operator: TDateOperatorsValidation;
299
+ origin: {
300
+ value?: string | number;
301
+ format: TDateFormatsValidation;
302
+ /**
303
+ * Intervals to compare with the original date.
304
+ *
305
+ * It will use today's date for comparison.
306
+ *
307
+ * @example
308
+ * ```typescript
309
+ * origin date = 10/10/2022
310
+ * interval.year = 1
311
+ * operator = '==='
312
+ * ```
313
+ *
314
+ * It will compare (10/10/2022 + 1) with the current date and check if they are the same
315
+ */
316
+ intervals?: TDateInterval;
317
+ };
318
+ target?: {
319
+ value: string | number;
320
+ format: TDateFormatsValidation;
321
+ };
322
+ };
323
+ /**
324
+ * @type TValidationMethods
325
+ * Represents the various validation methods that can be applied to form fields.
326
+ *
327
+ * @property {number} [max] - Maximum value or length.
328
+ * @property {number} [min] - Minimum value or length.
329
+ * @property {number} [lessThan] - Minimum value or length.
330
+ * @property {number} [greaterThan] - Minimum value or length.
331
+ * @property {TLengthValidation} [length] - Length validation rule.
332
+ * @property {boolean} [required] - Indicates if the field is required.
333
+ * @property {unknown} [value] - Specific value to match.
334
+ * @property {string} [regex] - Regular expression for validation.
335
+ * @property {boolean} [email] - Indicates if the value should be a valid email.
336
+ * @property {boolean} [url] - Indicates if the value should be a valid URL.
337
+ * @property {boolean} [onlyLetters] - Indicates if the value should contain only letters.
338
+ * @property {boolean} [notAllowSpaces] - Indicates if spaces are not allowed.
339
+ * @property {TCallbackValidation} [callback] - Custom validation callback function.
340
+ * @property {boolean} [isNumber] - Indicates if the value should be a number.
341
+ * @property {boolean} [bool] - Indicates if the value should be a boolean or a string that can be converted to a boolean.
342
+ * @property {boolean | string} [exists] - Indicates if the value should exist or match a specific existence condition.
343
+ * @property {boolean} [hasNoExtraSpaces] - Indicates if there should be no extra spaces.
344
+ * @property {boolean} [notEmpty] - Indicates if the field should not be empty.
345
+ * @property {TBetweenValidation} [between] - Validation rule for range between two values.
346
+ * @property {boolean} [sequential] - Indicates if the value should be sequential.
347
+ * @property {boolean} [repeated] - Indicates if the value should not be repeated.
348
+ * @property {string[] | number[]} [includes] - Array of values that should be included.
349
+ * @property {string[]} [isCreditCard] - Array of valid credit card numbers.
350
+ * @property {TCreditCardMatch} [isCreditCodeMatch] - Validation rule for credit card matching.
351
+ * @property {string[]} [isCreditCardAndLength] - Array of valid credit card numbers with length check.
352
+ * @property {TDocumentValidation} [document] - Document validation rule.
353
+ * @property {TConditionsValidation} [conditions] - Conditional validation rules.
354
+ * @property {TMultipleValidation} [multipleValidations] - Multiple validation rules combined with a logical rule.
355
+ * @property {TBetweenDatesValidation} [betweenDates] - Validation rule for checking if a date falls between two dates.
356
+ * @property {TDateValidation} [date] - Validation rule for date values.
357
+ * @property {TDateFormatsValidation} [validDate] - Validation rule for valid date formats.
358
+ *
359
+ * @example
360
+ * ```typescript
361
+ * const validationMethods: TValidationMethods = {
362
+ * max: 100,
363
+ * min: 1,
364
+ * lessThan: 1995,
365
+ * greaterThan: 82000,
366
+ * length: { rule: 'greaterOrEqual', target: 8 },
367
+ * required: true,
368
+ * regex: '^[a-zA-Z0-9]+$',
369
+ * email: true,
370
+ * conditions: {
371
+ * rule: 'and',
372
+ * set: [
373
+ * {
374
+ * forceDefinedOrigin: true,
375
+ * forceDefinedTarget: true,
376
+ * origin: '2023-01-01',
377
+ * condition: '>',
378
+ * target: '2022-01-01'
379
+ * }
380
+ * ]
381
+ * },
382
+ * multipleValidations: {
383
+ * rule: 'AND',
384
+ * validations: {
385
+ * required: true,
386
+ * min: 5,
387
+ * max: 10
388
+ * }
389
+ * },
390
+ * betweenDates: {
391
+ * start: Date.parse('2023-01-01'),
392
+ * end: Date.parse('2023-12-31'),
393
+ * isIncludedBoundaries: true
394
+ * },
395
+ * date: {
396
+ * operator: '===',
397
+ * origin: {
398
+ * value: '10/10/2022',
399
+ * format: 'MMDDYYYY',
400
+ * intervals: {
401
+ * years: 1
402
+ * }
403
+ * },
404
+ * target: {
405
+ * value: Date.now(),
406
+ * format: 'timestamp'
407
+ * }
408
+ * },
409
+ * validDate: 'MMDDYYYY'
410
+ * };
411
+ * ```
412
+ */
413
+ type TValidationMethods = {
414
+ /** Maximum value or length. */
415
+ max?: number;
416
+ /** Minimum value or length. */
417
+ min?: number;
418
+ /** Minimum value or length. */
419
+ lessThan?: number;
420
+ /** Minimum value or length. */
421
+ greaterThan?: number;
422
+ /** Length validation rule. */
423
+ length?: TLengthValidation;
424
+ /** Indicates if the field is required. */
425
+ required?: boolean;
426
+ /** Specific value to match. */
427
+ value?: unknown;
428
+ /** Regular expression for validation. */
429
+ regex?: string;
430
+ /** Indicates if the value should be a valid email. */
431
+ email?: boolean;
432
+ /** Indicates if the value should be a valid URL. */
433
+ url?: boolean;
434
+ /** Indicates if the value should contain only letters. */
435
+ onlyLetters?: boolean;
436
+ /** Indicates if spaces are not allowed. */
437
+ notAllowSpaces?: boolean;
438
+ /** Custom validation callback function. */
439
+ callback?: TCallbackValidation;
440
+ /** Indicates if the value should be a number. */
441
+ isNumber?: boolean;
442
+ /** Indicates if the value should be a boolean or a string that can be converted to a boolean. */
443
+ bool?: boolean | string;
444
+ /** Indicates if the value should exist or match a specific existence condition. */
445
+ exists?: boolean | string;
446
+ /** Indicates if there should be no extra spaces. */
447
+ hasNoExtraSpaces?: boolean;
448
+ /** Indicates if the field should not be empty. */
449
+ notEmpty?: boolean;
450
+ /** Validation rule for range between two values. */
451
+ between?: TBetweenValidation;
452
+ /** Indicates if the value should be sequential. */
453
+ sequential?: boolean;
454
+ /** Indicates if the value should not be repeated. */
455
+ repeated?: boolean;
456
+ /** Array of values that should be included. */
457
+ includes?: (string | number)[];
458
+ /** Array of valid credit card numbers. */
459
+ isCreditCard?: string[];
460
+ /** Validation rule for credit card matching. */
461
+ isCreditCodeMatch?: TCreditCardMatch;
462
+ /** Array of valid credit card numbers with length check. */
463
+ isCreditCardAndLength?: string[];
464
+ /** Document validation rule. */
465
+ document?: TDocumentValidation;
466
+ /** Conditional validation rules. */
467
+ conditions?: TConditionsValidation;
468
+ /** Multiple validation rules combined with a logical rule. */
469
+ multipleValidations?: TMultipleValidation;
470
+ /** Validation rule for checking if a date falls between two dates. */
471
+ betweenDates?: TBetweenDatesValidation;
472
+ /** Validation rule for date values. */
473
+ date?: TDateValidation;
474
+ /** Validation rule for valid date formats. */
475
+ validDate?: TDateFormatsValidation;
476
+ };
477
+ /**
478
+ * @type {Object.<string, TValidationMethods>} TGenericValidationRule
479
+ * Represents a generic validation rule where each key is associated with a set of validation methods.
480
+ *
481
+ * @example
482
+ * const genericValidationRule = {
483
+ * email: {
484
+ * required: true,
485
+ * email: true,
486
+ * },
487
+ * password: {
488
+ * required: true,
489
+ * minLength: 8,
490
+ * },
491
+ * };
492
+ */
493
+ type TGenericValidationRule = Record<string, TValidationMethods>;
494
+ /**
495
+ * @type {TValidationMethods | TGenericValidationRule} TSchemaValidation
496
+ * Represents the schema validation which can be either a set of validation methods or a generic validation rule.
497
+ *
498
+ * @example
499
+ * const schemaValidation = {
500
+ * required: true,
501
+ * maxLength: 10,
502
+ * };
503
+ *
504
+ * const genericSchemaValidation = {
505
+ * email: {
506
+ * required: true,
507
+ * email: true,
508
+ * },
509
+ * password: {
510
+ * required: true,
511
+ * minLength: 8,
512
+ * },
513
+ * };
514
+ * @interface
515
+ */
516
+ type TSchemaValidation = TValidationMethods | TGenericValidationRule;
517
+ /**
518
+ * Formatter types
519
+ * @type TSplitterFormatterValue
520
+ * Represents a value and its position for splitting or formatting purposes.
521
+ *
522
+ * @property {string} value - The value to be split or formatted.
523
+ * @property {number} position - The position for splitting or formatting.
524
+ *
525
+ * @example
526
+ * ```typescript
527
+ * const splitterFormatter: TSplitterFormatterValue = { value: '-', position: 3 };
528
+ * ```
529
+ */
530
+ type TSplitterFormatterValue = {
531
+ value: string;
532
+ position: number;
533
+ };
534
+ /**
535
+ * @type TFormatters
536
+ * Represents the various formatting options that can be applied to form field values.
537
+ *
538
+ * @property {boolean} [dotEvery3chars] - Add a dot every 3 characters.
539
+ * @property {boolean} [capitalize] - Capitalize the value.
540
+ * @property {boolean} [uppercase] - Convert the value to uppercase.
541
+ * @property {boolean} [onlyNumbers] - Allow only numbers.
542
+ * @property {boolean} [onlyLetters] - Allow only letters.
543
+ * @property {Pick<TCurrencyMask, 'precision' | 'decimal'>} [onlyFloatNumber] - Allow only float numbers with specific precision and decimal.
544
+ * @property {string} [regex] - Regular expression for formatting.
545
+ * @property {string[]} [gapsCreditCard] - Gaps to insert in credit card numbers.
546
+ * @property {(value: unknown) => unknown} [callback] - Custom formatter callback function.
547
+ * @property {TSplitterFormatterValue[]} [splitter] - Splitter values for formatting.
548
+ * @property {boolean} [trim] - Removes whitespace from both ends of this string and returns a new string, without modifying the original string.
549
+ * @property {number} [maxLength] - Truncates the input value to a specified maximum length if necessary.
550
+ *
551
+ * @example
552
+ * ```json
553
+ * {
554
+ * formatters: {
555
+ * dotEvery3chars: true,
556
+ * capitalize: true,
557
+ * uppercase: true,
558
+ * onlyNumbers: true,
559
+ * regex: '^[a-zA-Z0-9]+$',
560
+ * gapsCreditCard: [' ', ' '],
561
+ * callback: (value) => value.toString().toUpperCase(),
562
+ * splitter: [{ value: '-', position: 3 }],
563
+ * trim: true,
564
+ * maxLength: 15
565
+ * }
566
+ * }
567
+ * ```
568
+ */
569
+ type TFormatters = {
570
+ /** Add a dot every 3 characters. */
571
+ dotEvery3chars?: boolean;
572
+ /** Capitalize the value. */
573
+ capitalize?: boolean;
574
+ /** Convert the value to uppercase. */
575
+ uppercase?: boolean;
576
+ /** Allow only numbers. */
577
+ onlyNumbers?: boolean;
578
+ /** Allow only letters. */
579
+ onlyLetters?: boolean;
580
+ /** Allow only float numbers with specific precision and decimal. */
581
+ onlyFloatNumber?: Pick<TCurrencyMask, 'precision' | 'decimal'>;
582
+ /** Regular expression for formatting. */
583
+ regex?: string;
584
+ gapsCreditCard?: string[] | boolean;
585
+ callback?: ((value: unknown) => unknown) | null;
586
+ splitter?: TSplitterFormatterValue[];
587
+ /** Removes whitespace from both ends of this string and returns a new string, without modifying the original string. */
588
+ trim?: boolean;
589
+ /** Truncates the input value to a specified maximum length if necessary. */
590
+ maxLength?: number;
591
+ };
592
+ /**
593
+ * Mask types
594
+ * @type TCurrencyMask
595
+ * Represents the mask configuration for currency values.
596
+ *
597
+ * @property {'left' | 'right'} [align] - The alignment of the currency symbol. (default: right)
598
+ * @property {string} [decimal] - The decimal separator. (default: '.')
599
+ * @property {number} [precision] - The number of decimal places. (default: 2)
600
+ * @property {TCurrencyCode} [prefix] - The currency symbol prefix. (default: '$')
601
+ * @property {string} [thousands] - The thousands separator. (default: ',')
602
+ *
603
+ * @example
604
+ * ```typescript
605
+ * const currencyMask: TCurrencyMask = {
606
+ * align: 'left',
607
+ * decimal: '.',
608
+ * precision: 2,
609
+ * prefix: '$',
610
+ * thousands: ','
611
+ * };
612
+ * ```
613
+ */
614
+ type TCurrencyMask = {
615
+ align?: 'left' | 'right';
616
+ decimal?: string;
617
+ precision?: number;
618
+ prefix?: TCurrencyCode;
619
+ thousands?: string;
620
+ };
621
+ /**
622
+ * @type TMaskGeneric
623
+ * Represents a generic mask configuration.
624
+ *
625
+ * @property {number} to - The ending position of the mask.
626
+ * @property {number} from - The starting position of the mask.
627
+ * @property {string} mask - The mask pattern to apply.
628
+ *
629
+ * @example
630
+ * ```typescript
631
+ * const maskGeneric: TMaskGeneric = { to: 4, from: 0, mask: '****' };
632
+ * ```
633
+ */
634
+ type TMaskGeneric = {
635
+ to: number;
636
+ from: number;
637
+ mask: string;
638
+ };
639
+ /**
640
+ * @type TMasks
641
+ * Represents the different types of masks that can be applied to form field values.
642
+ *
643
+ * @property {TCurrencyMask} [currency] - Mask for currency values.
644
+ * @property {TMaskGeneric[]} [generic] - Array of generic masks.
645
+ * @property {string} [custom] - Custom mask pattern.
646
+ * @property {boolean} [secureCreditCard] - Mask for securing credit card values.
647
+ * @property {boolean} [card] - Mask for card values.
648
+ * @property {boolean} [cardDate] - Mask for card date values.
649
+ * @property {boolean} [fein] - Mask for FEIN (Federal Employer Identification Number).
650
+ * @property {string | number} [replaceAll] - Value to replace all matches.
651
+ * @property {(value: unknown) => string} [callback] - Custom mask callback function.
652
+ *
653
+ * @example
654
+ * ```typescript
655
+ * const masks: TMasks = {
656
+ * currency: { align: 'left', decimal: '.', precision: 2, prefix: '$', thousands: ',' },
657
+ * generic: [{ to: 4, from: 0, mask: '****' }],
658
+ * custom: '###-##-####',
659
+ * secureCreditCard: true,
660
+ * card: true,
661
+ * cardDate: true,
662
+ * fein: true,
663
+ * replaceAll: '*',
664
+ * callback: (value) => value.toString().replace(/\d/g, '*')
665
+ * };
666
+ * ```
667
+ */
668
+ type TMasks = {
669
+ /** Mask for currency values. */
670
+ currency?: TCurrencyMask;
671
+ /** Array of generic masks. */
672
+ generic?: TMaskGeneric[];
673
+ /** Custom mask pattern. */
674
+ custom?: string | null;
675
+ /** Mask for securing credit card values. */
676
+ secureCreditCard?: boolean;
677
+ /** Mask for card values. */
678
+ card?: boolean;
679
+ /** Mask for card date values. */
680
+ cardDate?: boolean;
681
+ /** Mask for FEIN (Federal Employer Identification Number). */
682
+ fein?: boolean;
683
+ /** Value to replace all matches. */
684
+ replaceAll?: string | number;
685
+ /** Custom mask callback function. */
686
+ callback?: (value: unknown) => string;
687
+ };
688
+ /**
689
+ * @type TVisibility
690
+ * Represents the visibility conditions for form fields based on validations.
691
+ *
692
+ * @property {boolean} showOnlyIfTrue - Enables visibility of fields only if any or all validation conditions are positive.
693
+ * @property {TSchemaValidation} validations - The validation methods to determine visibility.
694
+ * @property {string[] | string} fields - The fields to be shown or hidden based on validations.
695
+ * @property {string[]} events - Events where visibility will occur.
696
+ *
697
+ * @example
698
+ * ```typescript
699
+ * const visibility: TVisibility = {
700
+ * showOnlyIfTrue: false,
701
+ * validations: { required: true },
702
+ * fields: ['fieldName'],
703
+ * events: ['ON_FIELD_CHANGE']
704
+ * };
705
+ * ```
706
+ */
707
+ type TVisibility = {
708
+ showOnlyIfTrue?: boolean;
709
+ validations: TSchemaValidation;
710
+ fields: string[] | string;
711
+ events: TEvents[];
712
+ };
713
+ /**
714
+ * @type TResetValueMethods
715
+ * @extends TVisibility with methods to reset values.
716
+ * @summary schema method to reset values from event
717
+ * much cool such wow
718
+ *
719
+ * @property {unknown[] | unknown} resettledValue - The values to reset.
720
+ * @property {Partial<TEvents>[]} events - events that will react to the value reset
721
+ * @property {string | string[]} fields - fields that will react to the value reset
722
+ * @property {TSchemaValidation} validations - validations to trigger the property reset
723
+ *
724
+ *
725
+ * @example
726
+ * ```typescript
727
+ * const resetValueMethods: TResetValueMethods = {
728
+ * validations: { required: true },
729
+ * fields: ['fieldName'],
730
+ * resettledValue: [''],
731
+ * events: ['ON_FIELD_CHANGE]
732
+ * };
733
+ * ```
734
+ * @interface
735
+ */
736
+ type TResetValueMethods = Omit<TVisibility, 'showOnlyIfTrue' | 'validations'> & {
737
+ resettledValue: unknown[] | unknown;
738
+ validations?: TSchemaValidation;
739
+ };
740
+ /**
741
+ * @type TResetPathMethods
742
+ * Method to reset some field properties other than component props or field value
743
+ *
744
+ * @property {TAllowedResetPropsMutations} property property to be changed, ex: api, resetValues, etc..
745
+ * @property {string} path path where the property to be changed is located
746
+ * @property {string} field field that will recieve the property change
747
+ * @property {unknown} resettledValue value to be replaced onto the property
748
+ * @property {TSchemaValidation} validations validations rules to be validated to change the property value
749
+ * @property {Partial<TEvents>[]} events events to listen to apply this change
750
+ *
751
+ * @example
752
+ * ```typescript
753
+ * const resetValueMethods: TResetValueMethods = {
754
+ * validations: { required: true },
755
+ * fields: ['fieldName'],
756
+ * resettledValue: ['']
757
+ * };
758
+ * ```
759
+ */
760
+ type TResetPathMethods = {
761
+ property: TAllowedResetPropsMutations;
762
+ path: string;
763
+ field: string;
764
+ resettledValue: unknown;
765
+ validations: TSchemaValidation;
766
+ events: Partial<TEvents>[];
767
+ };
768
+ /**
769
+ * @type TApiConfig
770
+ * Represents the configuration for an API request.
771
+ *
772
+ * @property {'GET' | 'POST'} method - The HTTP method for the request.
773
+ * @property {string} url - The URL for the request.
774
+ * @property {Record<string, string>} [headers] - The headers for the request.
775
+ * @property {Record<string, string>} queryParams - query parameters for request.
776
+ * @property {string} [resultPath] - The path to extract the result from the response.
777
+ * @property {unknown} [fallbackValue] - The fallback value if the request fails.
778
+ * @property {TSchemaValidation} preConditions - validation conditions to execute the API call
779
+ * @property {boolean} blockRequestWhenInvalid - blocks request when field validation fails
780
+ *
781
+ * @example
782
+ * ```typescript
783
+ * const apiConfig: TApiConfig = {
784
+ * method: 'POST',
785
+ * url: 'https://api.example.com/data',
786
+ * headers: { 'Content-Type': 'application/json' },
787
+ * resultPath: 'data.results',
788
+ * fallbackValue: [],
789
+ * preConditions: {
790
+ * required: true,
791
+ * }
792
+ * blockRequestWhenInvalid: true,
793
+ * };
794
+ * ```
795
+ */
796
+ type TApiConfig = {
797
+ /** The HTTP method for the request. */
798
+ method: 'GET' | 'POST';
799
+ /** The URL for the request. */
800
+ url: string;
801
+ /** The body payload for the request. */
802
+ body?: Record<string, unknown>;
803
+ /** The headers for the request. */
804
+ headers?: Record<string, string>;
805
+ /** Query parameters for the request. */
806
+ queryParams?: Record<string, string>;
807
+ /** The path to extract the result from the response. */
808
+ resultPath?: string;
809
+ /** The fallback value if the request fails. */
810
+ fallbackValue?: unknown;
811
+ /** Validation conditions to execute the API call. */
812
+ preConditions?: TSchemaValidation;
813
+ /** Blocks request when field validation fails. */
814
+ blockRequestWhenInvalid?: boolean;
815
+ /** Custom transform callback for the request payload. */
816
+ transform?: {
817
+ callback(callbackPayload: {
818
+ payload: unknown;
819
+ formValues: TFormValues<unknown>;
820
+ }): unknown;
821
+ };
822
+ };
823
+ /**
824
+ * @type TProps
825
+ * Represents the properties for a component.
826
+ */
827
+ type TProps = Record<string, unknown>;
828
+ /**
829
+ * @type TValidations
830
+ * Represents the validation configuration for form fields, including methods, event-specific messages, and error messages.
831
+ *
832
+ * @property {TSchemaValidation} methods - The validation methods to be applied.
833
+ * @property {Partial<Record<TEvents, string[]>>} eventMessages - The messages to be displayed for specific validation events.
834
+ * @property {TErrorMessages} messages - The general error messages for validation methods.
835
+ *
836
+ * @interface
837
+ *
838
+ * @example
839
+ * ```typescript
840
+ * const validations: TValidations = {
841
+ * methods: {
842
+ * max: 100,
843
+ * required: true,
844
+ * regex: '^[a-zA-Z0-9]+$',
845
+ * },
846
+ * eventMessages: {
847
+ * ON_FIELD_MOUNT: ['required'],
848
+ * ON_FIELD_CHANGE: ['regex', 'required'],
849
+ * ON_FIELD_BLUR: ['max', 'required'],
850
+ * },
851
+ * messages: {
852
+ * default: 'This field is required',
853
+ * max: 'Value exceeds the maximum limit',
854
+ * regex: 'Value does not match the pattern',
855
+ * },
856
+ * };
857
+ * ```
858
+ */
859
+ type TValidations = {
860
+ methods: TSchemaValidation;
861
+ eventMessages?: TEventMessages;
862
+ messages?: TErrorMessages;
863
+ };
864
+ /**
865
+ * @type TValidations
866
+ * Represents the validation configuration for form fields, including methods, event-specific messages, and error messages.
867
+ *
868
+ * @property {TSchemaValidation} methods - The validation methods to be applied.
869
+ * @property {Partial<Record<TEvents, string[]>>} eventMessages - The messages to be displayed for specific validation events.
870
+ * @property {TErrorMessages} messages - The general error messages for validation methods.
871
+ *
872
+ * @example
873
+ * ```typescript
874
+ * const eventMessages: {
875
+ * ON_FIELD_MOUNT: ['required'],
876
+ * ON_FIELD_CHANGE: ['regex', 'required'],
877
+ * ON_FIELD_BLUR: ['max', 'required'],
878
+ * },
879
+ * ```
880
+ * @interface
881
+ */
882
+ type TEventMessages = Partial<Record<TEvents, TEventMessagesValidationMethods[]>>;
883
+ /**
884
+ * @type TEventMessagesValidationMethods
885
+ *
886
+ * allowed validation methods to trigger the event messages desc
887
+ *
888
+ * @property {keyof TValidationMethods | TAnyKey;} TEventMessagesValidationMethods - allowed validation methods to trigger the event messages
889
+ */
890
+ type TEventMessagesValidationMethods = keyof TValidationMethods | TAnyKey;
891
+ type TAnyKey = string & NonNullable<unknown>;
892
+ /**
893
+ * @type TErrorMessages
894
+ * Represents the error messages for different validation methods.
895
+ * @property {string} default - the message to display regardless the validation
896
+ *
897
+ * @example
898
+ * ```typescript
899
+ * const errorMessages: TErrorMessages = {
900
+ * required: 'This field is required.',
901
+ * max: 'The value cannot exceed the maximum limit.'
902
+ * default: 'Default error message'
903
+ * };
904
+ * ```
905
+ * @interface
906
+ */
907
+ type TErrorMessages = Partial<Record<keyof TSchemaValidation | 'default' | (string & NonNullable<unknown>), string>>;
908
+ /**
909
+ * Represents an event configuration with a specific type.
910
+ *
911
+ * @template T
912
+ * @property {T} config - The configuration of the event.
913
+ * @property {Partial<TEvents>[]} events - The events associated with the configuration.
914
+ */
915
+ type TEvent<T> = {
916
+ config: T;
917
+ events: TEvents[];
918
+ };
919
+ /**
920
+ * Represents the API event configurations.
921
+ *
922
+ * @property {TEvent<TApiConfig>} [defaultConfig] - The default event configuration.
923
+ * @property {Record<string, TEvent<TApiConfig>>} [configs] - Named event configurations.
924
+ *
925
+ * @example
926
+ * ```typescript
927
+ * const apiEvent: TApiEvent = {
928
+ * defaultConfig: {
929
+ * config: {
930
+ * method: 'POST',
931
+ * url: 'https://api.example.com/data',
932
+ * headers: { 'Content-Type': 'application/json' },
933
+ * resultPath: 'data.results',
934
+ * fallbackValue: [],
935
+ * preConditions: {
936
+ * required: true,
937
+ * },
938
+ * blockRequestWhenInvalid: true,
939
+ * },
940
+ * events: ['ON_FIELD_MOUNT', 'ON_FIELD_CHANGE'],
941
+ * },
942
+ * configs: {
943
+ * example_config_name: {
944
+ * config: {
945
+ * method: 'POST',
946
+ * url: 'https://api.example.com/data',
947
+ * headers: { 'Content-Type': 'application/json' },
948
+ * resultPath: 'data.results',
949
+ * fallbackValue: [],
950
+ * preConditions: {
951
+ * required: true,
952
+ * },
953
+ * blockRequestWhenInvalid: true,
954
+ * },
955
+ * events: ['ON_FIELD_MOUNT', 'ON_FIELD_CHANGE'],
956
+ * },
957
+ * },
958
+ * };
959
+ * ```
960
+ */
961
+ type TApiEvent = {
962
+ defaultConfig?: TEvent<TApiConfig>;
963
+ configs?: Record<string, TEvent<TApiConfig>>;
964
+ };
965
+ /**
966
+ * Represents the API response return payload for handling.
967
+ *
968
+ * @property {unknown} response - The default response.
969
+ * @property {number | null} status - response http status number.
970
+ */
971
+ type TApiResponsePayload = {
972
+ response: unknown;
973
+ status: number | null;
974
+ };
975
+ /**
976
+ * Represents the API response structure.
977
+ *
978
+ * @property {TApiResponsePayload} default - The default response.
979
+ * @property {Record<string, TApiResponsePayload>} [named] - Named responses.
980
+ */
981
+ type TApiResponse = {
982
+ default: TApiResponsePayload;
983
+ named?: Record<string, TApiResponsePayload>;
984
+ apiState: {
985
+ loading: boolean;
986
+ lastEvent?: TEvents;
987
+ };
988
+ };
989
+ /**
990
+ * Represents the schema config structure
991
+ *
992
+ * @property {number} defaultAPIdebounceTimeMS - default API debounce time between request events.
993
+ * @property {boolean} defaultLogVerbose - flag to turn warning log messages on client.
994
+ * @property {number} [defaultStateRefreshTimeMS] - default state refresh between events side effects.
995
+ */
996
+ type TSchemaFormConfig = {
997
+ defaultAPIdebounceTimeMS?: number;
998
+ defaultStateRefreshTimeMS?: number;
999
+ defaultLogVerbose?: boolean;
1000
+ };
1001
+ export { TApiConfig, TErrorMessages, TValidations, TMasks, TProps, TResetValueMethods, TResetPathMethods, TFormatters, TValidationMethods, TGenericValidationRule, TSchemaValidation, TEvent, TVisibility, TApiEvent, TApiResponsePayload, TApiResponse, TSchemaFormConfig, TLengthValidation, TCreditCardMatch, TDocumentValidation, TCallbackValidation, TBetweenValidation, TMaskGeneric, TSplitterFormatterValue, TCurrencyMask, TDateOperatorsValidation, TConditionsValidationSet, TConditionsValidation, TMultipleValidation, TAvailableValidations, TDateValidation, TBetweenDatesValidation, TDateFormatsValidation, TDateInterval, TEventMessages, TEventMessagesValidationMethods, TAllowedResetPropsMutationsEnum, };