zod icon indicating copy to clipboard operation
zod copied to clipboard

Add `.numeric()` to `ZodString`

Open icecreamparlor opened this issue 2 years ago • 3 comments

Hi 👋

I think it would be great to add numericString in ZodString. It is just util for regex checker, but I belive it would be useful in many cases.

Related Issue : https://github.com/colinhacks/zod/issues/1240

icecreamparlor avatar Nov 18 '22 05:11 icecreamparlor

Deploy Preview for guileless-rolypoly-866f8a ready!

Built without sensitive environment variables

Name Link
Latest commit 462371703b8cdbc503a4b8085543942b3079e283
Latest deploy log https://app.netlify.com/sites/guileless-rolypoly-866f8a/deploys/63e24f047ac84600081f6a2a
Deploy Preview https://deploy-preview-1570--guileless-rolypoly-866f8a.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar Nov 18 '22 05:11 netlify[bot]

Numeric seems redundant given its called in z.string() context. Why not simply z.string().numeric()?

igalklebanov avatar Dec 15 '22 21:12 igalklebanov

Numeric seems redundant given its called in z.string() context. Why not simply z.string().numeric()?

I think numeric seems better. I renamed numericString to numeric

icecreamparlor avatar Dec 16 '22 11:12 icecreamparlor

(cc. @colinhacks)

icecreamparlor avatar Jan 01 '23 09:01 icecreamparlor

Great, was just looking for this! Hope it gets merged soon!

einarpersson avatar Jan 28 '23 11:01 einarpersson

Any updates ..? I think this PR can help many people : )

icecreamparlor avatar Feb 07 '23 13:02 icecreamparlor

I could really use this for one of my current projects 👀

jacksonblankenship avatar May 09 '23 19:05 jacksonblankenship

Hello, any updates on when this will be merged?

softcam-claiton avatar Jul 25 '23 19:07 softcam-claiton

Thanks for the excellent PR here, and apologies for taking so long to address it. At the moment, I'm trying to keep Zod's core feature set as small as possible; since this is achievable with .regex() or .refine() I'm inclined to keep it separate.

Zod 4 will expose a bunch of utility regexes, and I'll be sure this one is included.

colinhacks avatar Apr 07 '24 00:04 colinhacks