Author Topic: maxLen validation is failing on empty text from editor  (Read 1755 times)

ralph1996

  • Pro Ultimate
  • Jr. Member
  • *
  • Posts: 80
    • View Profile
maxLen validation is failing on empty text from editor
« on: October 03, 2020, 01:34:17 am »
I have set the validations on a column to be maxLen = 8000.  I have traced the validation code in fn._digestNewRow to the point where it does the validations:

Code: [Select]
                if (validate && column.validations) {
                    if (source == "edit" && allowInvalid === false) {
                        var objRet = this.isValid({
                            focusInvalid: true,
                            dataIndx: dataIndx,
                            rowIndx: rowIndx,
                            value: newVal
                        });

which eventually gets to this code in _isValidCell

Code: [Select]
                               var valid = valids[j],
                    on = valid.on,
                    type = valid.type,
                    _valid = false,
                    msg = valid.msg,
                    reqVal = valid.value;
                if (on === false) {
                    continue
                }
                if (fn = pq.validations[type]) {
                    _valid = value == null ? false : fn(value, reqVal, getValue)
                } else if (type) {

The issue is that with an empty text the value is null so the validation fails.  I have verified above that type is maxLen and reqVal is 8000.

I will say this is somewhat erratic as I have seen cases where it does not generate the error although in most cases it is happening for us.  I assume when it succeeds the value is an empty string instead of null.

The column definition is as follows:

Code: [Select]
dataIndx: "Notes"
dataType: "html"
doExpand: true
doFlex: true
editModel: {clicksToEdit: 1, saveKey: "", keyUpDown: false}
editable: true
editor:
  attr: "rows=6"
  select: true
  type: "textarea"
render_Notes: ƒ (grid, ui)
title: "Notes"
validations: Array(1)
  0:
    msg: "Maximum length is 8000"
    type: "maxLen"
    value: 8000

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: maxLen validation is failing on empty text from editor
« Reply #1 on: October 04, 2020, 09:22:49 pm »
Could you please share a test case via jsfiddle or stackblitz.