arktype icon indicating copy to clipboard operation
arktype copied to clipboard

Allow more specific "date" keywords

Open plehnen opened this issue 11 months ago • 0 comments

Support type.keywords.date.only (i.e. "only a date without the time like "YYYY-MM-DD")

🤷 Motivation

In our project we use a generator that can convert swagger files to zod types. I would love to migrate this to arktype as it sounds very promising. But I noticed that some of the swagger formats aren't currently supported out of the box. For example we distinguish between z.optional(z.string().datetime({ local: true, offset: true }) (I guess that's equivalent to type.keywords.string.date.iso.root?) and z.optional(z.string().date()) (only allowing "YYYY-MM-DD")

💡 Solution

It would be great to be able to define what kind of date we allow, especially the ones which can already be defined via swagger:

NOTE: I don't want to parse it to date. I keep this as string (eventually being parsed to dayjs later on)

plehnen avatar Feb 12 '25 14:02 plehnen