|
1 | 1 | import { z } from 'astro/zod'; |
2 | 2 |
|
3 | | -export const rssSchema = z |
4 | | - .object({ |
5 | | - title: z.string().optional(), |
6 | | - description: z.string().optional(), |
7 | | - pubDate: z |
8 | | - .union([z.string(), z.number(), z.date()]) |
9 | | - .optional() |
10 | | - .transform((value) => (value === undefined ? value : new Date(value))) |
11 | | - .refine((value) => (value === undefined ? value : !isNaN(value.getTime()))), |
12 | | - customData: z.string().optional(), |
13 | | - categories: z.array(z.string()).optional(), |
14 | | - author: z.string().optional(), |
15 | | - commentsUrl: z.string().optional(), |
16 | | - source: z.object({ url: z.string().url(), title: z.string() }).optional(), |
17 | | - enclosure: z |
18 | | - .object({ |
19 | | - url: z.string(), |
20 | | - length: z.number().positive().int().finite(), |
21 | | - type: z.string(), |
22 | | - }) |
23 | | - .optional(), |
24 | | - link: z.string().optional(), |
25 | | - content: z.string().optional(), |
26 | | - }) |
27 | | - .refine((val) => val.title || val.description, { |
28 | | - message: 'At least title or description must be provided.', |
29 | | - path: ['title', 'description'], |
30 | | - }); |
| 3 | +export const rssSchema = z.object({ |
| 4 | + title: z.string().optional(), |
| 5 | + description: z.string().optional(), |
| 6 | + pubDate: z |
| 7 | + .union([z.string(), z.number(), z.date()]) |
| 8 | + .optional() |
| 9 | + .transform((value) => (value === undefined ? value : new Date(value))) |
| 10 | + .refine((value) => (value === undefined ? value : !isNaN(value.getTime()))), |
| 11 | + customData: z.string().optional(), |
| 12 | + categories: z.array(z.string()).optional(), |
| 13 | + author: z.string().optional(), |
| 14 | + commentsUrl: z.string().optional(), |
| 15 | + source: z.object({ url: z.string().url(), title: z.string() }).optional(), |
| 16 | + enclosure: z |
| 17 | + .object({ |
| 18 | + url: z.string(), |
| 19 | + length: z.number().positive().int().finite(), |
| 20 | + type: z.string(), |
| 21 | + }) |
| 22 | + .optional(), |
| 23 | + link: z.string().optional(), |
| 24 | + content: z.string().optional(), |
| 25 | +}); |
0 commit comments