This commit is contained in:
@@ -6,11 +6,11 @@ import { z } from "zod"
|
||||
export type JsonifiedDate = Opaque<string, "@thilawyn/zod-schema-class/JsonifiedDate">
|
||||
|
||||
|
||||
export function jsonifyDateSchema<S extends z.ZodDate>(schema: S) {
|
||||
export function jsonifyDateSchema<S extends z.ZodType<Date>>(schema: S) {
|
||||
return schema.transform(v => v.toString() as JsonifiedDate)
|
||||
}
|
||||
|
||||
export function dejsonifyDateSchema<S extends z.ZodDate>(schema: S) {
|
||||
export function dejsonifyDateSchema<S extends z.ZodType<Date>>(schema: S) {
|
||||
return z
|
||||
.custom<JsonifiedDate>(identity)
|
||||
.pipe(
|
||||
|
||||
Reference in New Issue
Block a user