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 decimal point issue in expense form schema amount field #90

Merged
merged 1 commit into from
Feb 13, 2024

Conversation

jantuomi
Copy link
Contributor

@jantuomi jantuomi commented Feb 10, 2024

Problem

The amount input field in the "add expense" view uses the decimal inputMode. This renders a numbers-only keyboard that on some locales only allows the user to input a comma as the decimal point. However, the zod schema does not permit a comma as the decimal point, since Number(value) will return NaN for such numbers.

E.g. Number("1.23") === 1.23, but Number("1,23") === NaN.

Solution

Replace commas with dots in the user-inputted amount value before casting it to a JS number. The rest of the schema validation will proceed as normal.

Fixes #78

Copy link
Member

@scastiel scastiel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 🥳

@scastiel scastiel merged commit 5b65b8f into spliit-app:main Feb 13, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Decimal separator for locales where decimal point is a comma
2 participants