question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for ISO dates ?

See original GitHub issue

Thanks for this amazing lib 🙏

I’d like to have support for ISO string dates:

const schema = z.string().date()
schema.parse("2021-06-02T16:23:50.048Z") // ✅ Ok
schema.parse("2021-06-02T16:23:50.048+02:00") // ✅ Ok
schema.parse("Not a date") // 🚫 Throws

Is it under preparation ?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:9
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

19reactions
Syttencommented, Mar 9, 2022

I mean its a bit rough auto close

12reactions
scotttrinhcommented, Aug 27, 2021

There is z.date() to handle that

Not quite: that validates that the object is a Date object, not a valid ISO string date.

I’d like to have support for ISO string dates: Is it under preparation ?

I’m not aware of any plans on adding something like that, but there is a refine method that you can use if you already have a predicate function that returns boolean, like this one from npm.

import isISODate from "is-iso-date";

const schema = z.string().refine(isISODate, { message: "Not a valid ISO string date "});
Read more comments on GitHub >

github_iconTop Results From Across the Web

ISO 8601 - Wikipedia
ISO 8601 is an international standard covering the worldwide exchange and communication of date and time-related data. It is maintained by the Geneva-based ......
Read more >
ISO 8601 — Date and time format
ISO 8601 is the internationally accepted way to represent dates and times.
Read more >
Use international date format (ISO) - Quality Web Tips - W3C
The ISO date format · YYYY is the year [all the digits, i.e. 2012] · MM is the month [01 (January) to 12...
Read more >
What is the ISO date and time format? - TechTarget
For example, the ISO representation for July 15, 2022 is either 20220715 or 2022-07-15.
Read more >
ISO 8601: The global standard for date and time formats
The ISO 8601 standard defines an internationally recognized format for representing dates and times. For times, they are expressed with the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found