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.
@@ -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 (this._minLength > 0) ? this._minLength.toString() : ''; }
686
+ get minLength() { return this._minLength; }
687
687
  set minLength(requiredMinLength) {
688
- let newMinLength = +requiredMinLength;
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 { type, validation, message } = this._formConfig.fieldValidations?.[this.fieldType] ?? {};
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
- intrinsicValidation = validation(fieldValue, this);
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);