From a153d4f6048b4e2e805c37d813cc87a793701d2c Mon Sep 17 00:00:00 2001 From: Sergio Clebal Date: Wed, 22 Jun 2022 10:31:54 +0200 Subject: [PATCH] Fix FormulaWidget column check (#437) --- CHANGELOG.md | 2 ++ packages/react-widgets/src/widgets/utils/propTypesFns.js | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61828236a..f3359994c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Not released +- Fix FormulaWidget column check [#437](https://github.com/CartoDB/carto-react/pull/437) + ## 1.3 ### 1.3.0-beta.2 (2022-06-20) diff --git a/packages/react-widgets/src/widgets/utils/propTypesFns.js b/packages/react-widgets/src/widgets/utils/propTypesFns.js index 70ca6466d..2e966ad36 100644 --- a/packages/react-widgets/src/widgets/utils/propTypesFns.js +++ b/packages/react-widgets/src/widgets/utils/propTypesFns.js @@ -20,10 +20,12 @@ export const checkFormulaColumn = (props, propName) => { const isValidString = !!propValue && typeof propValue === 'string'; const isValidArray = Array.isArray(propValue) && propValue.length; + const isValid = isValidString || isValidArray; + const validationError = new Error(`Prop ${propName} must be a string or an array`); if (props.operation === AggregationTypes.COUNT) { - if (propValue && !(isValidString || isValidArray)) { + if (propValue && !isValid) { return validationError; } } else { @@ -31,7 +33,7 @@ export const checkFormulaColumn = (props, propName) => { return new Error(`Prop ${propName} must be defined`); } - if (!isValidArray || !isValidString) { + if (!isValid) { return validationError; } }