Fix decimal separator issue in numeric form fields (#115)

* Revert 5b65b8f, fix comma issue with type="text" and onChange

* Fix comma issue in "paid for" input

* Run prettier autoformat

* Allow only digits and dots in currency inputs

* Fix behaviour in paidFor field

* Fix duplicated onChange prop

---------

Co-authored-by: Sebastien Castiel <sebastien@castiel.me>
This commit is contained in:
Jan T
2024-02-28 17:57:55 +02:00
committed by GitHub
parent c2b591349b
commit 4c5f8a6aa5
2 changed files with 22 additions and 6 deletions

View File

@@ -51,8 +51,7 @@ export const expenseFormSchema = z
[
z.number(),
z.string().transform((value, ctx) => {
const normalizedValue = value.replace(/,/g, '.')
const valueAsNumber = Number(normalizedValue)
const valueAsNumber = Number(value)
if (Number.isNaN(valueAsNumber))
ctx.addIssue({
code: z.ZodIssueCode.custom,