Persian Date (Zod)
zPersianDate coerces an ISO-8601 string, a shamsi yyyy/MM/dd string, an epoch number, or a native Date into a validated Date, with inclusive min/max bounds. zPersianDateRange wraps a from/to pair with persian-date's validateRange rules -- ordering, minimum/maximum stay length, past dates, and blocked dates.
Last updated August 12, 2026
Overview
Type an ISO date (2026-08-10) or a shamsi date (1405/05/19) below -- both parse to the same schema.
Installation
$ npx shadcn@latest add https://ui.persian-labs.ir/r/persian-date-zod.jsonUsage
import { z } from "zod"
import { zPersianDate, zPersianDateRange } from "@/lib/persian-date-zod"
const Booking = z.object({
checkIn: zPersianDate({ min: "2026-01-01" }),
checkOut: zPersianDate(),
})
Booking.parse({ checkIn: "1405/10/01", checkOut: new Date() })
// -> { checkIn: Date, checkOut: Date } -- both coerced to native Date
const Stay = zPersianDateRange({ minDays: 1, maxDays: 14, disablePast: true })
Stay.parse({ checkIn: "2026-08-10", checkOut: "2026-08-12" })Both schemas are plain zod schemas, so they drop into any zod-based form resolver (react-hook-form, VeeValidate, Felte, ...) the same way any other zod field would.
Examples
Bounds
The demo above is bounded to 2026 (min: "2026-01-01", max: "2026-12-31") -- try a date outside that range to see the bound violation message.
Range validation
zPersianDateRange validates a check-in/check-out pair in one schema -- the same reservation-form use case persian-date's validateRange targets, just expressed as a zod schema you can plug into a form resolver.