0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-30 22:03:56 -05:00

fix(rss): rssSchema definition to allow calling standard zod object methods (#9746)

* fix(rss): rssSchema definition to allow calling standard zod object methods

* fix: condition
This commit is contained in:
Florian Lefebvre 2024-01-22 13:07:29 +01:00 committed by GitHub
parent d0742bcfda
commit 7356336d18
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 17 deletions

View file

@ -0,0 +1,5 @@
---
"@astrojs/rss": patch
---
Fixes `rssSchema` definition to allow calling standard zod object methods (like `extend`)

View file

@ -1,6 +1,8 @@
import { z } from 'astro/zod';
const sharedSchema = z.object({
export const rssSchema = z.object({
title: z.string().optional(),
description: z.string().optional(),
pubDate: z
.union([z.string(), z.number(), z.date()])
.optional()
@ -20,19 +22,7 @@ const sharedSchema = z.object({
.optional(),
link: z.string().optional(),
content: z.string().optional(),
});
export const rssSchema = z.union([
z
.object({
title: z.string(),
description: z.string().optional(),
}).refine(val => val.title || val.description, {
message: "At least title or description must be provided.",
path: ["title", "description"]
})
.merge(sharedSchema),
z
.object({
title: z.string().optional(),
description: z.string(),
})
.merge(sharedSchema),
]);