Schema work
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Julien Valverdé
2024-03-19 18:25:56 +01:00
parent 5e7588510d
commit 9ddda594ef
5 changed files with 12 additions and 10 deletions

View File

@@ -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(