@alfresco/adf-core 8.4.0-17396068206 → 8.4.0-17399835374

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.
@@ -21186,23 +21186,27 @@ class MinLengthFieldValidator {
21186
21186
  }
21187
21187
  }
21188
21188
  class MaxLengthFieldValidator {
21189
- constructor() {
21190
- this.supportedTypes = [FormFieldTypes.TEXT, FormFieldTypes.MULTILINE_TEXT];
21189
+ constructor(supportedTypes = [FormFieldTypes.TEXT, FormFieldTypes.MULTILINE_TEXT], maxLength) {
21190
+ this.supportedTypes = supportedTypes;
21191
+ this.maxLength = maxLength;
21191
21192
  }
21192
21193
  isSupported(field) {
21193
- return field && this.supportedTypes.indexOf(field.type) > -1 && field.maxLength > 0;
21194
+ return field && this.supportedTypes.indexOf(field.type) > -1 && this.getMaxLength(field) > 0;
21194
21195
  }
21195
21196
  validate(field) {
21196
21197
  if (this.isSupported(field) && field.value && field.isVisible) {
21197
- if (field.value.length <= field.maxLength) {
21198
+ if (field.value.toString().length <= this.getMaxLength(field)) {
21198
21199
  return true;
21199
21200
  }
21200
21201
  field.validationSummary.message = `FORM.FIELD.VALIDATOR.NO_LONGER_THAN`;
21201
- field.validationSummary.attributes.set('maxLength', field.maxLength.toLocaleString());
21202
+ field.validationSummary.attributes.set('maxLength', this.getMaxLength(field).toLocaleString());
21202
21203
  return false;
21203
21204
  }
21204
21205
  return true;
21205
21206
  }
21207
+ getMaxLength(field) {
21208
+ return this.maxLength ?? field.maxLength;
21209
+ }
21206
21210
  }
21207
21211
  class MinValueFieldValidator {
21208
21212
  constructor() {
@@ -21333,6 +21337,7 @@ const FORM_FIELD_VALIDATORS = [
21333
21337
  new NumberFieldValidator(),
21334
21338
  new MinLengthFieldValidator(),
21335
21339
  new MaxLengthFieldValidator(),
21340
+ new MaxLengthFieldValidator([FormFieldTypes.NUMBER], 10),
21336
21341
  new MinValueFieldValidator(),
21337
21342
  new MaxValueFieldValidator(),
21338
21343
  new RegExFieldValidator(),