Skip to content

Commit 7356336

Browse files
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
1 parent d0742bc commit 7356336

2 files changed

Lines changed: 12 additions & 17 deletions

File tree

.changeset/mighty-icons-try.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@astrojs/rss": patch
3+
---
4+
5+
Fixes `rssSchema` definition to allow calling standard zod object methods (like `extend`)

packages/astro-rss/src/schema.ts

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { z } from 'astro/zod';
22

3-
const sharedSchema = z.object({
3+
export const rssSchema = z.object({
4+
title: z.string().optional(),
5+
description: z.string().optional(),
46
pubDate: z
57
.union([z.string(), z.number(), z.date()])
68
.optional()
@@ -20,19 +22,7 @@ const sharedSchema = z.object({
2022
.optional(),
2123
link: z.string().optional(),
2224
content: z.string().optional(),
23-
});
24-
25-
export const rssSchema = z.union([
26-
z
27-
.object({
28-
title: z.string(),
29-
description: z.string().optional(),
30-
})
31-
.merge(sharedSchema),
32-
z
33-
.object({
34-
title: z.string().optional(),
35-
description: z.string(),
36-
})
37-
.merge(sharedSchema),
38-
]);
25+
}).refine(val => val.title || val.description, {
26+
message: "At least title or description must be provided.",
27+
path: ["title", "description"]
28+
})

0 commit comments

Comments
 (0)