From f459aa10d403867c1b86e5586352e8a068a21a30 Mon Sep 17 00:00:00 2001 From: vashjs Date: Wed, 21 Feb 2024 00:45:14 +0100 Subject: [PATCH] update validation --- src/QueryBuilder/QueryBuilder/helpers/query.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/QueryBuilder/QueryBuilder/helpers/query.js b/src/QueryBuilder/QueryBuilder/helpers/query.js index 4926eb91..dda68529 100644 --- a/src/QueryBuilder/QueryBuilder/helpers/query.js +++ b/src/QueryBuilder/QueryBuilder/helpers/query.js @@ -32,9 +32,21 @@ export const getQueryStr = (rows, fieldOptions) => { }; export const isQueryValid = (source) => { + const isValueValid = (value) => { + if (Array.isArray(value)) { + return value.length > 0; + } + + if (typeof value === 'boolean') { + return true; + } + + return Boolean(value); + }; + return source.every(item => item[COLUMN_KEYS.FIELD].current && item[COLUMN_KEYS.OPERATOR].current - && Boolean(item[COLUMN_KEYS.VALUE].current?.length)); + && isValueValid(item[COLUMN_KEYS.VALUE].current)); }; export const getTransformedValue = (val) => {