mistic100 / jQuery-QueryBuilder

jQuery plugin offering an interface to create complex queries
https://querybuilder.js.org
MIT License
1.69k stars 552 forks source link

TypeError: str.replace is not a function #1007

Closed robertrachita closed 2 months ago

robertrachita commented 2 months ago

I get this error in my TypeScript project whenever I try to define a custom validation for a filter.

For instance, this also happens with this minimal callback function:

 {    
    id: 'test',
    label: 'test',
    type: 'double',
    operators: ['equal', 'not_equal', 'less'],
    validation: {
        callback: function(value: string, rule: any) {
              console.log(value);
              return true;
            }
       }
}

Stacktrace: Utils.fmt

QueryBuilder.prototype.updateError

update

dispatc

add/v.handle

trigger

triggerHandler

trigger

set

QueryBuilder.prototype.triggerValidationError

QueryBuilder.prototype.validate

robertrachita commented 2 months ago

solved it by declaring the query builder div element beforehand as any const queryBuilderElement: any = $('#query-builder');