0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-30 22:03:56 -05:00
astro/packages/integrations/sitemap/src/validate-options.ts
Tony Sullivan b8c6dabfb7
Enables eslint on the full repo and adds a rule for no only() tests (#3659)
* enabling eslint on the all packages and tests

* enabling for all packages

* TEMP: adding an only() test to verify it fails CI

* using our eslint config and ignore in CI

* removing the temporary .only() test

* update lock file

* lint: fixing new test with a no-shadow warning

* chore: update lock file
2022-06-22 15:59:49 +00:00

22 lines
724 B
TypeScript

import { z } from 'zod';
import type { SitemapOptions } from './index.js';
import { SitemapOptionsSchema } from './schema.js';
// @internal
export const validateOptions = (site: string | undefined, opts: SitemapOptions) => {
const result = SitemapOptionsSchema.parse(opts);
z.object({
site: z.string().optional(), // Astro takes care of `site`: how to validate, transform and refine
canonicalURL: z.string().optional(), // `canonicalURL` is already validated in prev step
})
.refine((options) => options.site || options.canonicalURL, {
message: 'Required `site` astro.config option or `canonicalURL` integration option',
})
.parse({
site,
canonicalURL: result.canonicalURL,
});
return result;
};