@mintlify/validation
Version:
Validates mint.json files
32 lines (31 loc) • 1.34 kB
JavaScript
import { footerSocialKeys } from '@mintlify/models';
import { z } from 'zod';
export const footerLinkSchema = z.object({
label: z.string().nonempty('Link must have a non-empty label'),
url: z.union([
z.string().url('Must be a valid url'),
z.string().startsWith('/', 'Must be a valid relative url starting with /'),
]),
});
export const footerLinksColumnSchema = z.object({
title: z.string().nonempty('Column must have a non-empty title').optional(),
links: z.array(footerLinkSchema).min(1, 'Column must have at least 1 link'),
});
export const footerSocialsSchema = z
.union([
z.record(z.enum(footerSocialKeys), z.string().url('Must be a valid url')),
// deprecated, prefer using the object type
z.array(z.object({
type: z.enum(footerSocialKeys),
url: z.string().url('Must be a valid url'),
})),
])
.describe('An object in which each key is the name of a social media platform, and each value is the url to your profile. For example: { "x": "https://x.com/mintlify" }');
export const footerSchema = z.object({
socials: footerSocialsSchema.optional(),
links: z
.array(footerLinksColumnSchema)
.min(1, 'A footer must have at least 1 links column')
.max(4, 'A footer can have a maximum of 4 links columns')
.optional(),
});