This repository has been archived on 2024-02-08. You can view files and clone it, but cannot push or open issues or pull requests.
frontend/src/modelSchema/common/date.ts

11 lines
260 B
TypeScript

import { preprocess, date } from 'zod'
export const DateSchema = preprocess((arg) => {
if (
// FIXME: Add comment why we check for `0001`
typeof arg == 'string' && !arg.startsWith('0001') ||
arg instanceof Date
) {
return new Date(arg)
}
}, date())