diff --git a/package.json b/package.json index 47e9c48..251973f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@indec/form-builder", - "version": "2.4.1", + "version": "2.4.3", "description": "Form builder", "main": "index.js", "private": false, diff --git a/src/components/Currency/Currency.js b/src/components/Currency/Currency.js index 0470186..e219d45 100644 --- a/src/components/Currency/Currency.js +++ b/src/components/Currency/Currency.js @@ -7,7 +7,7 @@ import TextField from '../TextField'; function Currency({form, field, label, ...props}) { const handleChange = values => { const {floatValue} = values; - form.setFieldValue(field.name, floatValue); + form.setFieldValue(field.name, typeof floatValue === 'number' ? floatValue : ''); form.setFieldTouched(field.name, false); }; diff --git a/src/utils/buildYupSchema.js b/src/utils/buildYupSchema.js index 14ad64a..9554b5e 100644 --- a/src/utils/buildYupSchema.js +++ b/src/utils/buildYupSchema.js @@ -11,8 +11,8 @@ const getValidatorType = (type, options, metadata) => { case questionTypes.TEXT_FIELD: case questionTypes.DROPDOWN: case questionTypes.RADIO: - case questionTypes.CURRENCY: return Yup.string().default(''); + case questionTypes.CURRENCY: case questionTypes.NUMERIC_FIELD: return Yup.number() .transform(value => (Number.isNaN(value) || value === null || value === undefined || value === '' ? 0 : value));