Skip to content

Added support for date and date-time#4

Open
gius wants to merge 1 commit into
josejulio:mainfrom
gius:feature/date-time
Open

Added support for date and date-time#4
gius wants to merge 1 commit into
josejulio:mainfrom
gius:feature/date-time

Conversation

@gius

@gius gius commented May 20, 2022

Copy link
Copy Markdown
Contributor

I have added a simple date and date-time support. Unfortunately, I was not able to figure out how to properly add a shared type

export const ParsedDate = z.preprocess(arg => (typeof arg == "string" || arg instanceof Date ? new Date(arg) : undefined), z.date());

So I have inlined the logic. (based on https://github.com/colinhacks/zod#dates)

Could you please have a look?
Because of that, I have not updated test snapshots. :-(

@josejulio

Copy link
Copy Markdown
Owner

Hello- I'll take a look - I suppose we should have a function to do this that deals with the adding the type if not found and just returning it.

@josejulio

Copy link
Copy Markdown
Owner

I guess this is good for now. Created #7 to add a way to add shared types.

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

Successfully merging this pull request may close these issues.

2 participants