tuain-ng-forms-lib 14.0.14 → 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.
|
@@ -705,7 +705,9 @@ class FieldDescriptor extends FormElement {
|
|
|
705
705
|
notifyEditionFinish() {
|
|
706
706
|
const fieldValue = this.getValue();
|
|
707
707
|
this.resetError();
|
|
708
|
-
const
|
|
708
|
+
const validationConfig = this._formConfig.fieldValidations?.[this.fieldType] ?? {};
|
|
709
|
+
const { type, validation } = validationConfig;
|
|
710
|
+
let message = validationConfig?.message;
|
|
709
711
|
let intrinsicValidation = true;
|
|
710
712
|
if (fieldValue && (validation || this.fieldFormat)) {
|
|
711
713
|
if (type === 'regexp') {
|
|
@@ -713,7 +715,9 @@ class FieldDescriptor extends FormElement {
|
|
|
713
715
|
&& (this.fieldFormat?.test(fieldValue) ?? true);
|
|
714
716
|
}
|
|
715
717
|
else if (type === 'function' && typeof validation === 'function') {
|
|
716
|
-
|
|
718
|
+
const { valid, message: customMessage } = validation(fieldValue, this);
|
|
719
|
+
intrinsicValidation = valid;
|
|
720
|
+
message = customMessage;
|
|
717
721
|
}
|
|
718
722
|
if (!intrinsicValidation) {
|
|
719
723
|
this.setError('99', message ?? this._intrinsicErrorMessage);
|