From 49ae42e4b4dfc370f048e6704a00099eb7689230 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 6 Oct 2022 15:25:33 +0530 Subject: [PATCH] refactor(gui): check default value is null or undefined Signed-off-by: Pranav C --- packages/nc-gui/utils/columnUtils.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/nc-gui/utils/columnUtils.ts b/packages/nc-gui/utils/columnUtils.ts index e6a328928d..7d1f027f05 100644 --- a/packages/nc-gui/utils/columnUtils.ts +++ b/packages/nc-gui/utils/columnUtils.ts @@ -1,4 +1,4 @@ -import { UITypes } from 'nocodb-sdk' +import { ColumnType, UITypes } from 'nocodb-sdk' import LinkVariant from '~icons/mdi/link-variant' import TableColumnPlusBefore from '~icons/mdi/table-column-plus-before' import FormatColorText from '~icons/mdi/format-color-text' @@ -167,8 +167,10 @@ const getUIDTIcon = (uidt: UITypes | string) => { ).icon } -const isColumnRequiredAndNull = (col: any, row: Record) => { - return col.rqd && (!col.cdf || !col.ai) && (row[col.title!] === undefined || row[col.title!] === null) +const isColumnRequired = (col: ColumnType) => col.rqd && (col.cdf === null || col.cdf === undefined ) && !col.ai + +const isColumnRequiredAndNull = (col: ColumnType, row: Record) => { + return isColumnRequired(col) && (row[col.title!] === undefined || row[col.title!] === null) } export { uiTypes, getUIDTIcon, isColumnRequiredAndNull }