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:
parent
d0742bcfda
commit
7356336d18
2 changed files with 12 additions and 17 deletions
5
.changeset/mighty-icons-try.md
Normal file
5
.changeset/mighty-icons-try.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"@astrojs/rss": patch
|
||||
---
|
||||
|
||||
Fixes `rssSchema` definition to allow calling standard zod object methods (like `extend`)
|
|
@ -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),
|
||||
]);
|
||||
|
|
Loading…
Reference in a new issue