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

Property 'datetime' does not exist on type 'ZodString'. #1580

Closed
kadekkurniawan opened this issue Nov 22, 2022 · 9 comments
Closed

Property 'datetime' does not exist on type 'ZodString'. #1580

kadekkurniawan opened this issue Nov 22, 2022 · 9 comments

Comments

@kadekkurniawan
Copy link

kadekkurniawan commented Nov 22, 2022

Since i am new to zod, i've been reading the documentation for a while and found the z.string().datetime() method.

However, when I tried that method on my project, I got an error that's says Property 'datetime' does not exist on type 'ZodString'.
image

do you guys have any workaround for this problem?

@jakewtaylor
Copy link

This caught me out the other day, the docs are reflecting the main branch here, but the latest package on NPM is 2 months old - the datetime() method was added more recently, in #1494. Dunno why it hasn't been published though - could be good reason. Maybe @colinhacks could chip in?

@lfDev28
Copy link

lfDev28 commented Nov 25, 2022

Ive just been using z.date(). Works fine with datetime strings for me...

@kadekkurniawan
Copy link
Author

kadekkurniawan commented Nov 25, 2022

Ive just been using z.date(). Works fine with datetime strings for me...

z.date() method will throw an error, if the date is in a form of a string (e.g 2020-01-01T00:00:00.123Z).

Since I need to check if the date string (2020-01-01T00:00:00.123Z) is a valid date or not, the z.date() method won't work for me.

@gabrielgrover
Copy link

gabrielgrover commented Nov 26, 2022

would like to see this available as well. In the meantime @Esa-Kurniawan you can unblock yourself by following the documentation here https://github.com/colinhacks/zod#dates.
Screen Shot 2022-11-26 at 12 37 30 PM

@kadekkurniawan
Copy link
Author

kadekkurniawan commented Nov 27, 2022

would like to see this available as well. In the meantime @Esa-Kurniawan you can unblock yourself by following the documentation here https://github.com/colinhacks/zod#dates. Screen Shot 2022-11-26 at 12 37 30 PM

Yeah, I think I can use this dateSchema for validating a date string for now, until the z.string().datetime() method is released.

@mauriciabad
Copy link

I see 2 important problems here:

  1. Documentation should be only about released code. It doesn't make any sense that it explains how to use a function that's not implemented.
  2. The npm release process is ineffective. The code has been merged 1 month ago but not released yet.

@padge
Copy link

padge commented Dec 9, 2022

I had to install version 3.20.0-beta.0 to access .string().datetime().

https://github.com/colinhacks/zod/releases/tag/v3.20.0

@FabioCingottini
Copy link

z.string().datetime() is now available due to v3.20.2 of zod being available!

@kadekkurniawan
Copy link
Author

kadekkurniawan commented Dec 21, 2022

The z.string().datetime() method has been released

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

7 participants