Skip to content

Commit 036bac7

Browse files
committed
refactor: 'zod' function() instead of self made refine()
1 parent b61e1f9 commit 036bac7

1 file changed

Lines changed: 4 additions & 12 deletions

File tree

packages/integrations/sitemap/src/schema.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,9 @@ import { SITEMAP_CONFIG_DEFAULTS } from './config-defaults';
44

55
const localeKeySchema = () => z.string().min(1);
66

7-
const isFunction = (fn: any) => fn instanceof Function;
8-
9-
const fnSchema = () =>
10-
z
11-
.any()
12-
.refine((val) => !val || isFunction(val), { message: 'Not a function' })
13-
.optional();
14-
157
export const SitemapOptionsSchema = z
168
.object({
17-
filter: fnSchema(),
9+
filter: z.function().optional(),
1810
customPages: z.string().url().array().optional(),
1911
canonicalURL: z.string().url().optional(),
2012

@@ -32,12 +24,12 @@ export const SitemapOptionsSchema = z
3224
),
3325
})
3426
.refine((val) => !val || val.locales[val.defaultLocale], {
35-
message: '`defaultLocale` must exists in `locales` keys',
27+
message: '`defaultLocale` must exist in `locales` keys',
3628
})
3729
.optional(),
3830

39-
entryLimit: z.number().nonnegative().default(SITEMAP_CONFIG_DEFAULTS.entryLimit),
40-
serialize: fnSchema(),
31+
entryLimit: z.number().nonnegative().optional().default(SITEMAP_CONFIG_DEFAULTS.entryLimit),
32+
serialize: z.function().optional(),
4133

4234
changefreq: z.enum(changefreqValues).optional(),
4335
lastmod: z.date().optional(),

0 commit comments

Comments
 (0)