Date type handling?
See original GitHub issueThis lib looks like a really nice approach. I don’t see support for Date
types, though. Do you have a plan to support them?
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
<input type="date"> - HTML: HyperText Markup Language
At the moment, the best way to deal with dates in forms in a cross-browser way is to have the user enter the...
Read more >Handling date and time the right way | by Yuriy Ivon
The general rule for “pure” dates is pretty simple — such values must not be converted at any step of reading and writing....
Read more >Date & Time Data Types - Snowflake Documentation
This topic describes the data types supported in Snowflake for managing dates, times, and timestamps (combined date + time). It also describes the...
Read more >datetime — Basic date and time types — Python 3.11.1 ...
Date and time objects may be categorized as “aware” or “naive” depending on whether or not they include timezone information. With sufficient knowledge...
Read more >A Guide to Handling Date and Time for Full Stack JavaScript ...
Formatting the date ... One way to format a date is to use the getter functions like getFullYear, getMonth, getDate, etc. For example,...
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
Hey Joe,
So you want to be able to pass in, say, an ISO string to a Date field and have
.parse
return a proper Date object in its place?I’m trying to keep this library from becoming a casting library, since casting is generally messy and difficult, especially when you’re dealing with static types. Currently the above code wouldn’t pass static validation, since
zod
expectsPerson.createdAt
to be aDate
. To get it to work, I’d have to create a variant of the inferred schema type that changes allDate
fields toDate | string
, to accommodate the loosened restrictions on the input to.parse
. Over time these “loosenings” would get messier and less intuitive.I’d rather implement this is a refinement string type:
I’m already planning to implement other built-in refinement validators (
{ is: 'email' }
,{ is: 'url' }
, etc.).This way you could parse your schema, then be confident that passing
Person.createdAt
intoDate.parse
will return a valid date. Would that work for you?Great 😃