This repository contains an example application that shows how to use zod
library together with TypeScript. To illustrate the differences, also a solution in TypeScript without zod
is implemented.
Following is included:
To get started execute pnpm install
to install dependencies. Then run pnpm dev
to start the application.
The application is separated in TypeScript and zod
sections. All related files are either located in typescript/*
or zod/*
folders.
- JSON data
- can't contain data types like
Date
,Map
, etc. - has to be processed to desired format (e.g. convert a date from
string
toDate
) - can contain just a subset of data (e.g. when calling REST APIs)
- can't contain data types like
- Input data has to transformed to be usable in input fields of a form
- Usually a validation of the input is needed
- Form data that was entered has to be transformed into a usable output data