Question

I am using this amazing JavaScript SQL Query Builder UI REDQueryBuilder and I am able to generate the query. However I wish to validate the input textbox.

for e.g. If I have configured a column type as Integer, I wish to handle it in client side itself. The problem is it generates the textboxe's dynamically so it's difficult to validate it.

As you can see below I have CUSTOMER_ID as Integer, So when we input the data in the textbox I want to read the meta config: tables > columns > type with the textbox input. similarly I can move further for other types like boolean, char etc...

meta looks something like this

{
  "tables": [{
    "name": "CUSTOMER_DETAILS",
    "label": "Customer Details",
    "columns": [{
      "name": "CUSTOMER_ID",
      "label": "Customer Id",
      "type": "INTEGER",
      "size": 20
    }, {
      "name": "ACCOUNT_NO",
      "label": "Account No",
      "type": "TEXT",
      "size": 20
    }, {
      "name": "CITY_NAME",
      "label": "City",
      "type": "TEXT",
      "size": 100
    }, {
      "name": "NAME",
      "label": "NAME",
      "type": "TEXT",
      "size": 100
    }],
  "fks": []
}], 
"types": [{ 
  ...
  }]
}
Was it helpful?

Solution

The current recommended approach is to add css class/style names to the elements via the meta data then use your normal approach validate in the client.

If you think it should be a core part of the product then best to raise a ticket for discussion?

https://github.com/salk31/RedQueryBuilder/issues?state=open

Does seem like a common thing to want to do (although not in all cases). A related thing might be more in built data types as you suggest.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top