From d48d27b71d80d602fe56a77e2b22d71702c4962a Mon Sep 17 00:00:00 2001 From: VitaliiDC8 Date: Fri, 25 Aug 2023 11:57:39 +0300 Subject: [PATCH 1/2] fix: convert empty string value to undefined for Number Field --- src/lib/core/components/Form/hooks/useField.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/core/components/Form/hooks/useField.tsx b/src/lib/core/components/Form/hooks/useField.tsx index e3bdb4d7..2aa46ea0 100644 --- a/src/lib/core/components/Form/hooks/useField.tsx +++ b/src/lib/core/components/Form/hooks/useField.tsx @@ -96,7 +96,7 @@ export const useField = ({ let value = transformArrIn(_value); if (isNumberSpec(spec) && value && !error) { - value = Number(value) as Value; + value = (value ? Number(value) : undefined) as Value; } let newChildErrors: Record = {...state.childErrors}; From 923c7a4f3237ff66590e48bbec78ab5ffb3e8bf8 Mon Sep 17 00:00:00 2001 From: VitaliiDC8 Date: Fri, 25 Aug 2023 12:03:08 +0300 Subject: [PATCH 2/2] fix: removed value in if --- src/lib/core/components/Form/hooks/useField.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/core/components/Form/hooks/useField.tsx b/src/lib/core/components/Form/hooks/useField.tsx index 2aa46ea0..525a95f5 100644 --- a/src/lib/core/components/Form/hooks/useField.tsx +++ b/src/lib/core/components/Form/hooks/useField.tsx @@ -95,7 +95,7 @@ export const useField = ({ const error = validate?.(_value); let value = transformArrIn(_value); - if (isNumberSpec(spec) && value && !error) { + if (isNumberSpec(spec) && !error) { value = (value ? Number(value) : undefined) as Value; }