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

useDecimalJs = true does not work #123

Open
michiim opened this issue May 23, 2022 · 1 comment
Open

useDecimalJs = true does not work #123

michiim opened this issue May 23, 2022 · 1 comment

Comments

@michiim
Copy link

michiim commented May 23, 2022

if useDecimalJs = true is defined, the helper schema for Decimal fields is created but not used.

details:

creates Helper (without assignment to const)

z
  .instanceof(Decimal)
  .or(z.string())
  .or(z.number())
  .refine((value) => {
    try {
      return new Decimal(value)
    } catch (error) {
      return false
    }
  })
  .transform((value) => new Decimal(value))

does not use it in schema (ex. property price)

export const product = z.object({
  id: z.string(),
  name: z.string(),
  price: z.number().nullish(),
})
@ElhanM
Copy link

ElhanM commented May 25, 2024

@michiim @CarterGrimmeisen Did you find a fix for this? Is it possible for me to use the 1.0-beta branch instead on my project (which has this fix)

Can I do this?

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

No branches or pull requests

2 participants