Skip to content

Commit

Permalink
update validation
Browse files Browse the repository at this point in the history
  • Loading branch information
vashjs committed Feb 20, 2024
1 parent 350141e commit f459aa1
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/QueryBuilder/QueryBuilder/helpers/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit f459aa1

Please sign in to comment.