@bolttech/form-engine 0.4.6 → 0.5.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.
- package/CHANGELOG.md +15 -0
- package/README.md +395 -2
- package/asFormField-ff27f10a.js +2 -0
- package/asFormField-ff27f10a.js.map +1 -0
- package/index.js +1 -1
- package/package.json +1 -1
- package/react.js +1 -1
- package/src/core/handlers/common/templating.d.ts +6 -0
- package/src/core/types/index.d.ts +193 -74
- package/types.js.map +1 -1
- package/asFormField-ea28b423.js +0 -2
- package/asFormField-ea28b423.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [0.5.0](http://bitbucket.org/gofrank/bolttech-frontend/compare/form-engine-0.4.7...form-engine-0.5.0) (2023-10-24)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* create boolean validation function and update readme with all validation types description ([fd17418](http://bitbucket.org/gofrank/bolttech-frontend/commit/fd17418c80cb6b85fee27eefdfa479f43e2cd76b))
|
|
11
|
+
|
|
12
|
+
## [0.4.7](http://bitbucket.org/gofrank/bolttech-frontend/compare/form-engine-0.4.6...form-engine-0.4.7) (2023-10-20)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* add stage version on readme ([4fe3eff](http://bitbucket.org/gofrank/bolttech-frontend/commit/4fe3effbbf7f28b722e88ea5cd0f8ed4163d1103))
|
|
18
|
+
* api call on mound event handler ([eca02f9](http://bitbucket.org/gofrank/bolttech-frontend/commit/eca02f980a1ee6cf8a35bae570f5ecba7f191bdf))
|
|
19
|
+
|
|
5
20
|
## [0.4.6](http://bitbucket.org/gofrank/bolttech-frontend/compare/form-engine-0.4.5...form-engine-0.4.6) (2023-09-28)
|
|
6
21
|
|
|
7
22
|
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Achieve form logic reusage with forms expressed in json format.
|
|
4
4
|
|
|
5
|
-
> version 0.
|
|
5
|
+
> stable version 0.5.0
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -327,7 +327,400 @@ If you have a named validation, you can use its name in the error messages, havi
|
|
|
327
327
|
|
|
328
328
|
### Available validations (TBD)
|
|
329
329
|
|
|
330
|
-
Refer to the types
|
|
330
|
+
Refer to the `TAvailableValidations` types here:
|
|
331
|
+
|
|
332
|
+
````typescript
|
|
333
|
+
{
|
|
334
|
+
/**
|
|
335
|
+
* The bool function is a validation function that checks if a given value indicating whether the validation has failed or not.
|
|
336
|
+
*
|
|
337
|
+
* @example - in a test environment
|
|
338
|
+
* ```
|
|
339
|
+
* const result = bool({
|
|
340
|
+
* validationValue: false,
|
|
341
|
+
* });
|
|
342
|
+
* console.log(result); // { fail: false }
|
|
343
|
+
* ```
|
|
344
|
+
*
|
|
345
|
+
* @example - real json usage with field value
|
|
346
|
+
* ```
|
|
347
|
+
* {
|
|
348
|
+
* validations: {
|
|
349
|
+
* bool: '${fields.input.value}'
|
|
350
|
+
* },
|
|
351
|
+
* },
|
|
352
|
+
* ```
|
|
353
|
+
*
|
|
354
|
+
* @example - real json usage with iVar value
|
|
355
|
+
* ```
|
|
356
|
+
* {
|
|
357
|
+
* validations: {
|
|
358
|
+
* bool: '${global.validation}'
|
|
359
|
+
* },
|
|
360
|
+
* },
|
|
361
|
+
* ```
|
|
362
|
+
*/
|
|
363
|
+
bool?: string | boolean;
|
|
364
|
+
/**
|
|
365
|
+
* Validation based on conditions
|
|
366
|
+
*
|
|
367
|
+
* @example - Compare own field to two. Origin and target default to field value
|
|
368
|
+
* ```
|
|
369
|
+
* conditions: {
|
|
370
|
+
* rule: 'and',
|
|
371
|
+
* set: [
|
|
372
|
+
* {
|
|
373
|
+
* condition: '===',
|
|
374
|
+
* target: '2',
|
|
375
|
+
* },
|
|
376
|
+
* {
|
|
377
|
+
* origin: '2',
|
|
378
|
+
* condition: '===',
|
|
379
|
+
* },
|
|
380
|
+
* ],
|
|
381
|
+
* },
|
|
382
|
+
* ```
|
|
383
|
+
* @example - Binded to Postcode field value. Must be greater than or equal two
|
|
384
|
+
* ```
|
|
385
|
+
* conditions: {
|
|
386
|
+
* rule: 'or',
|
|
387
|
+
* set: [
|
|
388
|
+
* {
|
|
389
|
+
* origin: '${fields.postcode.value}',
|
|
390
|
+
* condition: '>',
|
|
391
|
+
* target: '2',
|
|
392
|
+
* },
|
|
393
|
+
* {
|
|
394
|
+
* origin: '${fields.postcode.value}',
|
|
395
|
+
* condition: '===',
|
|
396
|
+
* target: '2',
|
|
397
|
+
* },
|
|
398
|
+
* ],
|
|
399
|
+
* },
|
|
400
|
+
* ```
|
|
401
|
+
* @example - Binded to Postcode field value. Must be equal to two
|
|
402
|
+
* ```
|
|
403
|
+
* conditions: {
|
|
404
|
+
* rule: 'or',
|
|
405
|
+
* set: [
|
|
406
|
+
* {
|
|
407
|
+
* origin: '${fields.postcode.value}',
|
|
408
|
+
* condition: '===',
|
|
409
|
+
* target: '2',
|
|
410
|
+
* },
|
|
411
|
+
* ],
|
|
412
|
+
* },
|
|
413
|
+
* ```
|
|
414
|
+
*/
|
|
415
|
+
conditions?: TVAvailableValitationConditions;
|
|
416
|
+
/**
|
|
417
|
+
* Between validations
|
|
418
|
+
*
|
|
419
|
+
* @example - Between ages
|
|
420
|
+
* ``` type teste = Pick<TVAvailableValidations, 'date'>
|
|
421
|
+
* between: {
|
|
422
|
+
* dates: [
|
|
423
|
+
* {
|
|
424
|
+
* operator: '>=',
|
|
425
|
+
* origin: {
|
|
426
|
+
* format: 'YYYYMMDD',
|
|
427
|
+
* intervals: {
|
|
428
|
+
* years: 18,
|
|
429
|
+
* },
|
|
430
|
+
* },
|
|
431
|
+
* },
|
|
432
|
+
* {
|
|
433
|
+
* operator: '<=',
|
|
434
|
+
* origin: {
|
|
435
|
+
* format: 'YYYYMMDD',
|
|
436
|
+
* intervals: {
|
|
437
|
+
* years: 75,
|
|
438
|
+
* },
|
|
439
|
+
* },
|
|
440
|
+
* }
|
|
441
|
+
* ]
|
|
442
|
+
* }
|
|
443
|
+
* ```
|
|
444
|
+
*
|
|
445
|
+
* @example - Between numbers
|
|
446
|
+
* ```
|
|
447
|
+
* between: {
|
|
448
|
+
* start: '3',
|
|
449
|
+
* end: '4',
|
|
450
|
+
* isIncludedBoundaries: true
|
|
451
|
+
* },
|
|
452
|
+
* ```
|
|
453
|
+
*
|
|
454
|
+
*/
|
|
455
|
+
between?: {
|
|
456
|
+
/**
|
|
457
|
+
* Array of date validations. To make it possible, ensure that the conditions is > and < in both date validations.
|
|
458
|
+
*/
|
|
459
|
+
dates?: TVAvailableValidations['date'][];
|
|
460
|
+
/**
|
|
461
|
+
* The first number of the validation. If the current value is grater than this number, the validation will pass.
|
|
462
|
+
*/
|
|
463
|
+
start?: number;
|
|
464
|
+
/**
|
|
465
|
+
* The second number of the validation. If the current value is lower than this number, the validation will pass.
|
|
466
|
+
*/
|
|
467
|
+
end?: number;
|
|
468
|
+
/**
|
|
469
|
+
* If it's true, the comparision is transformed to >= and <=. So, the numbers that were passed are included in the validation.
|
|
470
|
+
*/
|
|
471
|
+
isIncludedBoundaries?: boolean;
|
|
472
|
+
};
|
|
473
|
+
/**
|
|
474
|
+
* Dates validations
|
|
475
|
+
*
|
|
476
|
+
* @example - Dates should be different
|
|
477
|
+
* ```
|
|
478
|
+
* date: {
|
|
479
|
+
* operator: '!==',
|
|
480
|
+
* origin: {
|
|
481
|
+
* format: 'DDMMYYYY',
|
|
482
|
+
* },
|
|
483
|
+
* target: {
|
|
484
|
+
* format: 'DDMMYYYY',
|
|
485
|
+
* value: '10/10/2001',
|
|
486
|
+
* },
|
|
487
|
+
* },*
|
|
488
|
+
* ```
|
|
489
|
+
*
|
|
490
|
+
* @example - Compare only valid dates using intervals
|
|
491
|
+
* ```
|
|
492
|
+
* date: {
|
|
493
|
+
* onlyValidDate: true,
|
|
494
|
+
* operator: '<',
|
|
495
|
+
* origin: {
|
|
496
|
+
* format: 'DD/MM/YYYY',
|
|
497
|
+
* intervals: {
|
|
498
|
+
* years: 1,
|
|
499
|
+
* },
|
|
500
|
+
* },
|
|
501
|
+
* },
|
|
502
|
+
* ```
|
|
503
|
+
*
|
|
504
|
+
* @example - Should have at max 85 years
|
|
505
|
+
* ```
|
|
506
|
+
* {
|
|
507
|
+
* operator: '>',
|
|
508
|
+
* origin: {
|
|
509
|
+
* format: 'DDMMYYYY',
|
|
510
|
+
* value: eightyFiveYearsDate,
|
|
511
|
+
* intervals: {
|
|
512
|
+
* years: 85,
|
|
513
|
+
* },
|
|
514
|
+
* },
|
|
515
|
+
* }
|
|
516
|
+
* }
|
|
517
|
+
*
|
|
518
|
+
* ```
|
|
519
|
+
*/
|
|
520
|
+
date?: {
|
|
521
|
+
/**
|
|
522
|
+
* Flag to force only valid dates. Valid dates must be of min length of 8
|
|
523
|
+
*/
|
|
524
|
+
onlyValidDate?: boolean;
|
|
525
|
+
/**
|
|
526
|
+
* List of operations you can do
|
|
527
|
+
* - between origin and target dates
|
|
528
|
+
* - between origin and intervals
|
|
529
|
+
*/
|
|
530
|
+
operator: TValidationDateOperators;
|
|
531
|
+
/**
|
|
532
|
+
* The origin configurations
|
|
533
|
+
*/
|
|
534
|
+
origin: {
|
|
535
|
+
/**
|
|
536
|
+
* Origin date value
|
|
537
|
+
*/
|
|
538
|
+
value?: string | number;
|
|
539
|
+
/**
|
|
540
|
+
* The available date formats
|
|
541
|
+
*/
|
|
542
|
+
format: TValidationDateFormats;
|
|
543
|
+
/**
|
|
544
|
+
* Intervals to compare with the original date.
|
|
545
|
+
*
|
|
546
|
+
* It will use todays date for comparison.
|
|
547
|
+
*
|
|
548
|
+
* @example
|
|
549
|
+
*
|
|
550
|
+
* origin date = 10/10/2022
|
|
551
|
+
* interval.year = 1
|
|
552
|
+
* operator = '==='
|
|
553
|
+
*
|
|
554
|
+
* It will compare (10/10/2022 + 1) with the current date and check if they are the same
|
|
555
|
+
*/
|
|
556
|
+
intervals?: {
|
|
557
|
+
years?: number;
|
|
558
|
+
months?: number;
|
|
559
|
+
days?: number;
|
|
560
|
+
};
|
|
561
|
+
};
|
|
562
|
+
target?: {
|
|
563
|
+
value: string | number;
|
|
564
|
+
format: TValidationDateFormats;
|
|
565
|
+
};
|
|
566
|
+
};
|
|
567
|
+
/**
|
|
568
|
+
* Allow to define a maximum length for the input to have no error
|
|
569
|
+
*/
|
|
570
|
+
length?: number;
|
|
571
|
+
/**
|
|
572
|
+
* Will look into the input length and send an error if if not greater than this value
|
|
573
|
+
*/
|
|
574
|
+
greaterThan?: number | string;
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Specifies a regular expression pattern that the value should match.
|
|
578
|
+
*/
|
|
579
|
+
regex?: string;
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* Specifies the maximum length of the value (if it's a string).
|
|
583
|
+
*/
|
|
584
|
+
maxLength?: number;
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Specifies the minimum length of the value (if it's a string).
|
|
588
|
+
*/
|
|
589
|
+
minLength?: number;
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* Specifies whether the field is required.
|
|
593
|
+
*/
|
|
594
|
+
required?: boolean;
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* Specifies that the value should contain only letters.
|
|
598
|
+
*/
|
|
599
|
+
onlyLetters?: boolean;
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* Specifies a value that the field should match.
|
|
603
|
+
*/
|
|
604
|
+
value?: string | number | boolean;
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* Specifies that the field should not be empty.
|
|
608
|
+
*/
|
|
609
|
+
notEmpty?: boolean;
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* A callback function that performs custom validation on the value.
|
|
613
|
+
* @param value - The value to be validated.
|
|
614
|
+
* @returns An object with validation results.
|
|
615
|
+
*/
|
|
616
|
+
callback?(value: string | number): { fail: boolean; errorMessage?: string };
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* Specifies a numeric range for the value.
|
|
620
|
+
*/
|
|
621
|
+
numericRange?: { start: number | string; end: number | string };
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* Specifies whether the value should be a number.
|
|
625
|
+
*/
|
|
626
|
+
isNumber?: boolean;
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* Specifies that the field should not have extra spaces.
|
|
630
|
+
*/
|
|
631
|
+
hasNoExtraSpaces?: boolean;
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* Specifies that the value should be an email address.
|
|
635
|
+
*/
|
|
636
|
+
email?: boolean;
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* Specifies that the value should be less than a given number or string.
|
|
640
|
+
*/
|
|
641
|
+
lessThan?: number | string;
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* Specifies that the value should be a sequential number.
|
|
645
|
+
*/
|
|
646
|
+
sequentialNumber?: boolean;
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* Specifies that the value should not contain repeated numbers.
|
|
650
|
+
*/
|
|
651
|
+
repeatedNumbers?: boolean;
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* Specifies that the value should be a URL.
|
|
655
|
+
*/
|
|
656
|
+
url?: boolean;
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* Specifies a path error type.
|
|
660
|
+
*/
|
|
661
|
+
path?: TPathError;
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* Specifies that the value should be a valid credit card number.
|
|
665
|
+
*/
|
|
666
|
+
isCreditCard?: string[];
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* Specifies that the value should be a valid credit card number with a specific length.
|
|
670
|
+
*/
|
|
671
|
+
isCreditCardAndLength?: string[];
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* Specifies that the value should match a credit card code with available options.
|
|
675
|
+
*/
|
|
676
|
+
isCreditCodeMatch?: { numberCard: string; availableOptions: string[] };
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* Specifies custom validation options for the field.
|
|
680
|
+
*/
|
|
681
|
+
customValidation?: ICustomValidationValue[];
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* Specifies that spaces are not allowed in the field.
|
|
685
|
+
*/
|
|
686
|
+
notAllowSpaces?: true;
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* Specifies that the value should be in a predefined list of values.
|
|
690
|
+
*/
|
|
691
|
+
isInTheList?: string[] | number[] | string;
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* Specifies field validation rules for nested fields.
|
|
695
|
+
*/
|
|
696
|
+
fields?: {
|
|
697
|
+
/**
|
|
698
|
+
* The rule for validating nested fields (e.g., 'every').
|
|
699
|
+
*/
|
|
700
|
+
rule: 'every';
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* An array of nested field validation configurations.
|
|
704
|
+
*/
|
|
705
|
+
set: {
|
|
706
|
+
/**
|
|
707
|
+
* The binding for the nested field.
|
|
708
|
+
*/
|
|
709
|
+
bind: string;
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* The field name for the nested field.
|
|
713
|
+
*/
|
|
714
|
+
fieldName: string;
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* Validation options for the nested field, excluding the 'fields' property.
|
|
718
|
+
*/
|
|
719
|
+
validations: Omit<TVAvailableValidations, 'fields'>;
|
|
720
|
+
}[];
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
````
|
|
331
724
|
|
|
332
725
|
## **Formatters**
|
|
333
726
|
|