Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(buildYupSchema): change currency to number #82

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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