Skip to content

Commit 537d5f6

Browse files
arteria32Denis Ryabko
andauthored
fix(utils): imporve nullish-checking for number inputs (#327)
Co-authored-by: Denis Ryabko <[email protected]>
1 parent dd8217a commit 537d5f6

File tree

1 file changed

+2
-2
lines changed
  • src/lib/core/components/Form/Controller

1 file changed

+2
-2
lines changed

src/lib/core/components/Form/Controller/utils.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ export const getFieldInitials = <
239239
}
240240

241241
if (isNil(value)) {
242-
if (spec.defaultValue) {
242+
if (!isNil(spec.defaultValue)) {
243243
value = transformArrIn(spec.defaultValue) as DirtyValue;
244244
}
245245
// if the spec with type array or object, and this spec has "required === true",
@@ -298,7 +298,7 @@ export const getFieldMethods = <
298298
let value = transformArrIn(_value);
299299

300300
if (isNumberSpec(spec) && !error) {
301-
value = (value ? Number(value) : undefined) as DirtyValue;
301+
value = (isNil(value) || value === '' ? undefined : Number(value)) as DirtyValue;
302302
}
303303

304304
let newChildErrors: Record<string, ValidateError> = {...state.childErrors};

0 commit comments

Comments
 (0)