chore: use z.coerce.date()
to pass input through new Date(input)
. (#8383)
This commit is contained in:
parent
535a458999
commit
77922ae5db
3 changed files with 6 additions and 18 deletions
|
@ -6,14 +6,8 @@ const blog = defineCollection({
|
||||||
title: z.string(),
|
title: z.string(),
|
||||||
description: z.string(),
|
description: z.string(),
|
||||||
// Transform string to Date object
|
// Transform string to Date object
|
||||||
pubDate: z
|
pubDate: z.coerce.date(),
|
||||||
.string()
|
updatedDate: z.coerce.date().optional(),
|
||||||
.or(z.date())
|
|
||||||
.transform((val) => new Date(val)),
|
|
||||||
updatedDate: z
|
|
||||||
.string()
|
|
||||||
.optional()
|
|
||||||
.transform((str) => (str ? new Date(str) : undefined)),
|
|
||||||
heroImage: z.string().optional(),
|
heroImage: z.string().optional(),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,11 +4,8 @@ const blog = defineCollection({
|
||||||
schema: z.object({
|
schema: z.object({
|
||||||
title: z.string(),
|
title: z.string(),
|
||||||
description: z.string(),
|
description: z.string(),
|
||||||
pubDate: z.string().transform((str) => new Date(str)),
|
pubDate: z.coerce.date(),
|
||||||
updatedDate: z
|
updatedDate: z.coerce.date().optional(),
|
||||||
.string()
|
|
||||||
.optional()
|
|
||||||
.transform((str) => (str ? new Date(str) : undefined)),
|
|
||||||
heroImage: z.string().optional(),
|
heroImage: z.string().optional(),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,11 +4,8 @@ const blog = defineCollection({
|
||||||
schema: z.object({
|
schema: z.object({
|
||||||
title: z.string(),
|
title: z.string(),
|
||||||
description: z.string(),
|
description: z.string(),
|
||||||
pubDate: z.string().transform((str) => new Date(str)),
|
pubDate: z.coerce.date(),
|
||||||
updatedDate: z
|
updatedDate: z.coerce.date().optional(),
|
||||||
.string()
|
|
||||||
.optional()
|
|
||||||
.transform((str) => (str ? new Date(str) : undefined)),
|
|
||||||
heroImage: z.string().optional(),
|
heroImage: z.string().optional(),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue