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

Support different numeric types #7

Open
TonyGravagno opened this issue Jul 9, 2023 · 0 comments
Open

Support different numeric types #7

TonyGravagno opened this issue Jul 9, 2023 · 0 comments

Comments

@TonyGravagno
Copy link
Owner

MySQL has tinyint(n), smallint, bigint, float, double, etc. All of these are represented as z.number() in mysql-zod.

Add support for at least a few of the more common numeric types. Examples to enforce min, max, etc:

z.coerce.number() // Force it to be a number
  .int() // Make sure it's an integer
  .gte(10000) // Greater than or equal to the smallest 5 digit int
  .lte(99999) // Less than or equal to the largest 5 digit int
...
  someNumber: z.string().transform((val) => {
    if (val.length !== 5) ... different ways to handle issue ...
    return parseInt(val, 10)
  }),
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

1 participant