@esfaenza/forms-and-validations 15.2.51 → 15.2.52
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/esm2020/lib/forms/form-adaptive/form-adaptive.component.mjs +30 -3
- package/fesm2015/esfaenza-forms-and-validations.mjs +29 -2
- package/fesm2015/esfaenza-forms-and-validations.mjs.map +1 -1
- package/fesm2020/esfaenza-forms-and-validations.mjs +29 -2
- package/fesm2020/esfaenza-forms-and-validations.mjs.map +1 -1
- package/lib/forms/form-adaptive/form-adaptive.component.d.ts +8 -1
- package/package.json +1 -1
|
@@ -2623,13 +2623,38 @@ class FormAdaptiveComponent extends BaseFormControl {
|
|
|
2623
2623
|
break;
|
|
2624
2624
|
}
|
|
2625
2625
|
// A quanto pare la creazione del validatore rompe il caso d'uso classico...
|
|
2626
|
-
|
|
2626
|
+
pv._validator = this.customPatternValidator(pv.pattern);
|
|
2627
2627
|
this.ngControl._setValidators(validators);
|
|
2628
2628
|
this.ngControl.control.setValidators(validators);
|
|
2629
2629
|
this.ngControl.control.updateValueAndValidity();
|
|
2630
2630
|
}
|
|
2631
2631
|
super.ngOnInit();
|
|
2632
2632
|
}
|
|
2633
|
+
/**
|
|
2634
|
+
* Validator that requires the control's value to match a regex pattern.
|
|
2635
|
+
* See `Validators.pattern` for additional information.
|
|
2636
|
+
*/
|
|
2637
|
+
customPatternValidator(pattern) {
|
|
2638
|
+
if (!pattern)
|
|
2639
|
+
return (_) => null;
|
|
2640
|
+
let regex;
|
|
2641
|
+
let regexStr;
|
|
2642
|
+
if (typeof pattern === 'string') {
|
|
2643
|
+
regexStr = '';
|
|
2644
|
+
if (pattern.charAt(0) !== '^')
|
|
2645
|
+
regexStr += '^';
|
|
2646
|
+
regexStr += pattern;
|
|
2647
|
+
if (pattern.charAt(pattern.length - 1) !== '$')
|
|
2648
|
+
regexStr += '$';
|
|
2649
|
+
regex = new RegExp(regexStr);
|
|
2650
|
+
}
|
|
2651
|
+
return (control) => {
|
|
2652
|
+
if (!control.value) {
|
|
2653
|
+
return null;
|
|
2654
|
+
}
|
|
2655
|
+
return regex.test(this.floatValuePreAdjustmente) ? null : { 'pattern': { 'requiredPattern': regexStr, 'actualValue': this.floatValuePreAdjustmente } };
|
|
2656
|
+
};
|
|
2657
|
+
}
|
|
2633
2658
|
/** @ignore */
|
|
2634
2659
|
async ngOnChanges(changes) {
|
|
2635
2660
|
const newSource = changes["Source"];
|
|
@@ -2786,8 +2811,10 @@ class FormAdaptiveComponent extends BaseFormControl {
|
|
|
2786
2811
|
: JSON.parse(JSON.stringify(this.Model)))
|
|
2787
2812
|
: null;
|
|
2788
2813
|
if ((this.Type == "float" || this.Type == "number") && toEmit) {
|
|
2789
|
-
if (this.AdjustNumber)
|
|
2814
|
+
if (this.AdjustNumber) {
|
|
2815
|
+
this.floatValuePreAdjustmente = toEmit;
|
|
2790
2816
|
toEmit = toEmit.replace(".", "").replace(",", ".");
|
|
2817
|
+
}
|
|
2791
2818
|
this.EvaluatedModel = toEmit;
|
|
2792
2819
|
}
|
|
2793
2820
|
else if (this.Type == "boolean") {
|