Skip to content

Commit

Permalink
Merge pull request #82 from indec-it/fix/currencySchemaType
Browse files Browse the repository at this point in the history
fix(buildYupSchema): change currency to number
  • Loading branch information
maximilianoforlenza authored Aug 29, 2023
2 parents 35869b3 + 92f3920 commit c9dc3d8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@indec/form-builder",
"version": "2.4.1",
"version": "2.4.3",
"description": "Form builder",
"main": "index.js",
"private": false,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Currency/Currency.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down
2 changes: 1 addition & 1 deletion src/utils/buildYupSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit c9dc3d8

Please sign in to comment.