z.date documentation needed
See original GitHub issueDiscussed in https://github.com/colinhacks/zod/discussions/879
<div type='discussions-op-text'>Originally posted by blocka January 24, 2022 Very surprised that I could not find anything on this.
If I have a date schema const schema = z.date()
and I pass it a date string schema.parse('2022-01-12T00:00:00.000Z')
I would expect to get back a JS Date object. Instead I get an exception that I’ve passed a string instead of a date. …</div>
There really should be some documentation in the README about how z.date works.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6
Top Results From Across the Web
DATE - IBM
You can use the following options to obtain specific date formats. (Only the bold character is needed; all other characters are ignored.).
Read more >Date and Time Formats - W3C
This profile defines a restricted range of formats, all of which are valid ISO 8601 dates and times. The aim is to simplify...
Read more >Datetime Patterns for Formatting and Parsing - Apache Spark
Spark uses pattern letters in the following table for date and timestamp parsing and formatting ... z, time-zone name, zone-name, Pacific Standard Time;...
Read more >Format Dates and Times - MuleSoft Documentation
DataWeave supports the use of formatting characters, such as the u (for the year), M , and d in the date format uuuu-MM-dd...
Read more >Date and Time Input / Output - Snowflake Documentation
Date & Time Functions. In this Topic: How Snowflake Determines the Input and Output Formats to Use. Session Parameters for Dates, Times, and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I agree completely.
I think the “parse, don’t validate” thing is confusing. I have been using Zod for awhile now and so I get how it works. But I still don’t get the reasoning behind “parse, don’t validate”. To me, leaving the implementation of parse and safeParse the way they are is fine, but renaming them to validate and safeValidate or something would help with some of the confusion. But that’s just me…
@JacobWeisenburger
Started a discussion to talk about forming a documentation working group if you’re interested: https://github.com/colinhacks/zod/discussions/911