Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

zod-joda

dasprid9.2kBSD-2-Clause1.1.3TypeScript support: included

JS-Joda integration for Zod validation library

Zod, js-joda, validation, joda, TypeScript

readme

JS-Joda integration for Zod validation library

Node.js CI codecov

This library adds additional types to Zod to parse and validate dates and times as js-joda types.

Installation

  • Install the npm package:

    npm install zod-joda

  • Additionally, you should have both zod and js-joda installed:

    npm install zod @js-joda/core

Quick Start

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.