This library adds additional types to Zod to parse and validate dates and times as js-joda types.
-
Install the npm package:
npm install zod-joda
-
Additionally, you should have both zod and js-joda installed:
npm install zod @js-joda/core
Import the schema types from this package. You can either import individual types or import all types via convenience method:
import {zj} from 'zod-joda';
This library supplies the following types:
zj.localDate()
zj.localDateTime()
zj.localTime()
zj.zonedDateTime()
All constructors take an optional object with a dateTimeFormatter
property, which allows you to change the default
behavior of how dates and times will be parsed. By default, every value should be in an ISO 8601 format.