tuain-ng-forms-lib 14.0.13 → 14.0.15
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/classes/forms/field.mjs +9 -7
- package/fesm2015/tuain-ng-forms-lib.mjs +8 -6
- package/fesm2015/tuain-ng-forms-lib.mjs.map +1 -1
- package/fesm2020/tuain-ng-forms-lib.mjs +8 -6
- package/fesm2020/tuain-ng-forms-lib.mjs.map +1 -1
- package/lib/classes/forms/field.d.ts +2 -2
- package/package.json +1 -1
|
@@ -683,11 +683,9 @@ class FieldDescriptor extends FormElement {
|
|
|
683
683
|
setRequired(required) { this.required = required; }
|
|
684
684
|
get required() { return this.fieldRequired; }
|
|
685
685
|
set required(required) { this.setAttr(fldAttr.required, required ?? false); }
|
|
686
|
-
get minLength() { return
|
|
686
|
+
get minLength() { return this._minLength; }
|
|
687
687
|
set minLength(requiredMinLength) {
|
|
688
|
-
|
|
689
|
-
newMinLength = (isNaN(newMinLength) || newMinLength < 0) ? 0 : newMinLength;
|
|
690
|
-
this.setAttr(fldAttr.minLength, newMinLength);
|
|
688
|
+
this.setAttr(fldAttr.minLength, requiredMinLength);
|
|
691
689
|
}
|
|
692
690
|
get maxLength() { return (this._maxLength > 0) ? this._maxLength.toString() : ''; }
|
|
693
691
|
set maxLength(requiredMaxLength) {
|
|
@@ -707,7 +705,9 @@ class FieldDescriptor extends FormElement {
|
|
|
707
705
|
notifyEditionFinish() {
|
|
708
706
|
const fieldValue = this.getValue();
|
|
709
707
|
this.resetError();
|
|
710
|
-
const
|
|
708
|
+
const validationConfig = this._formConfig.fieldValidations?.[this.fieldType] ?? {};
|
|
709
|
+
const { type, validation } = validationConfig;
|
|
710
|
+
let message = validationConfig?.message;
|
|
711
711
|
let intrinsicValidation = true;
|
|
712
712
|
if (fieldValue && (validation || this.fieldFormat)) {
|
|
713
713
|
if (type === 'regexp') {
|
|
@@ -715,7 +715,9 @@ class FieldDescriptor extends FormElement {
|
|
|
715
715
|
&& (this.fieldFormat?.test(fieldValue) ?? true);
|
|
716
716
|
}
|
|
717
717
|
else if (type === 'function' && typeof validation === 'function') {
|
|
718
|
-
|
|
718
|
+
const { valid, message: customMessage } = validation(fieldValue, this);
|
|
719
|
+
intrinsicValidation = valid;
|
|
720
|
+
message = customMessage;
|
|
719
721
|
}
|
|
720
722
|
if (!intrinsicValidation) {
|
|
721
723
|
this.setError('99', message ?? this._intrinsicErrorMessage);
|