@mintlify/validation 0.1.124 → 0.1.126
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -327
- package/dist/index.js +2 -9
- package/dist/mint-config/customErrorMap.d.ts +2 -0
- package/dist/mint-config/customErrorMap.js +13 -0
- package/dist/mint-config/formatIssue.d.ts +3 -0
- package/dist/mint-config/formatIssue.js +15 -0
- package/dist/mint-config/schemas/analytics.d.ts +1 -1
- package/dist/mint-config/schemas/analytics.js +16 -88
- package/dist/mint-config/schemas/anchorColors.js +4 -9
- package/dist/mint-config/schemas/anchors.js +10 -51
- package/dist/mint-config/schemas/apiReference.js +9 -42
- package/dist/mint-config/schemas/basics.d.ts +1 -1
- package/dist/mint-config/schemas/basics.js +28 -89
- package/dist/mint-config/schemas/colors.js +7 -9
- package/dist/mint-config/schemas/config.d.ts +3 -3
- package/dist/mint-config/schemas/config.js +3 -3
- package/dist/mint-config/schemas/favicon.js +3 -7
- package/dist/mint-config/schemas/hexColor.d.ts +1 -1
- package/dist/mint-config/schemas/hexColor.js +3 -3
- package/dist/mint-config/schemas/integrations.js +3 -7
- package/dist/mint-config/schemas/navigation.js +8 -26
- package/dist/mint-config/schemas/tabs.js +5 -26
- package/dist/mint-config/schemas/versions.js +5 -7
- package/dist/mint-config/validateMintConfig.d.ts +328 -0
- package/dist/mint-config/validateMintConfig.js +17 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -1,48 +1,21 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export const openApiSchema = z
|
|
3
|
-
z.string(
|
|
4
|
-
|
|
5
|
-
}),
|
|
6
|
-
z.array(z.string({
|
|
7
|
-
invalid_type_error: 'openapi must be a string or an array of strings of absolute or relative URLs pointing to your OpenAPI file.',
|
|
8
|
-
})),
|
|
9
|
-
]);
|
|
2
|
+
export const openApiSchema = z
|
|
3
|
+
.union([z.string(), z.array(z.string())])
|
|
4
|
+
.describe('A string or an array of strings of absolute or relative urls pointing to your OpenAPI files');
|
|
10
5
|
export const apiSchema = z
|
|
11
6
|
.object({
|
|
12
|
-
baseUrl: z
|
|
13
|
-
.union([
|
|
14
|
-
z.string().url('api.baseUrl must be a valid URL.'),
|
|
15
|
-
z.array(z.string().url('api.baseUrl array entries must be valid URLs.')),
|
|
16
|
-
])
|
|
17
|
-
.optional(),
|
|
7
|
+
baseUrl: z.union([z.string().url(), z.array(z.string().url())]).optional(),
|
|
18
8
|
auth: z
|
|
19
9
|
.object({
|
|
20
|
-
method: z
|
|
21
|
-
.enum(['bearer', 'basic', 'key', 'cobo'], {
|
|
22
|
-
errorMap: () => {
|
|
23
|
-
return {
|
|
24
|
-
message: 'api.auth.method has to be one of: bearer, basic, or key',
|
|
25
|
-
};
|
|
26
|
-
},
|
|
27
|
-
})
|
|
28
|
-
.optional(),
|
|
10
|
+
method: z.enum(['bearer', 'basic', 'key', 'cobo']).optional(),
|
|
29
11
|
name: z.string().optional(),
|
|
30
12
|
inputPrefix: z.string().optional(),
|
|
31
13
|
})
|
|
32
|
-
.strict(
|
|
14
|
+
.strict()
|
|
33
15
|
.optional(),
|
|
34
16
|
playground: z
|
|
35
17
|
.object({
|
|
36
|
-
mode: z
|
|
37
|
-
.enum(['show', 'simple', 'hide'], {
|
|
38
|
-
errorMap: () => {
|
|
39
|
-
return {
|
|
40
|
-
message: 'api.playground.mode must be one of the following strings: show, simple, or hide',
|
|
41
|
-
};
|
|
42
|
-
},
|
|
43
|
-
})
|
|
44
|
-
.optional()
|
|
45
|
-
.default('show'),
|
|
18
|
+
mode: z.enum(['show', 'simple', 'hide']).optional().default('show'),
|
|
46
19
|
})
|
|
47
20
|
.optional(),
|
|
48
21
|
request: z
|
|
@@ -54,12 +27,6 @@ export const apiSchema = z
|
|
|
54
27
|
.optional(),
|
|
55
28
|
})
|
|
56
29
|
.optional(),
|
|
57
|
-
maintainOrder: z
|
|
58
|
-
.boolean({
|
|
59
|
-
invalid_type_error: 'maintainOrder must be a boolean. Try writing true or false without the quotes.',
|
|
60
|
-
})
|
|
61
|
-
.optional(),
|
|
62
|
-
}, {
|
|
63
|
-
invalid_type_error: 'api must be an object. The object can have baseUrl, auth, and playground as properties.',
|
|
30
|
+
maintainOrder: z.boolean().optional(),
|
|
64
31
|
})
|
|
65
|
-
.strict(
|
|
32
|
+
.strict();
|
|
@@ -71,7 +71,7 @@ export declare const redirectsSchema: z.ZodEffects<z.ZodArray<z.ZodObject<{
|
|
|
71
71
|
source: string;
|
|
72
72
|
destination: string;
|
|
73
73
|
}[]>;
|
|
74
|
-
export declare const
|
|
74
|
+
export declare const ctaButtonSchema: z.ZodUnion<[z.ZodObject<{
|
|
75
75
|
type: z.ZodOptional<z.ZodLiteral<"link">>;
|
|
76
76
|
name: z.ZodString;
|
|
77
77
|
url: z.ZodString;
|
|
@@ -1,120 +1,59 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export const nameSchema = z
|
|
3
|
-
.string({ required_error: 'Name is missing.' })
|
|
4
|
-
.min(1, 'Name cannot be empty.')
|
|
5
|
-
.trim();
|
|
2
|
+
export const nameSchema = z.string().trim().nonempty();
|
|
6
3
|
export const logoSchema = z.union([
|
|
7
|
-
z.string().min(3, '
|
|
4
|
+
z.string().min(3, 'Must be a path to your logo file including the file extension'),
|
|
8
5
|
z.object({
|
|
9
6
|
light: z.string(),
|
|
10
7
|
dark: z.string(),
|
|
11
8
|
href: z.string().optional(),
|
|
12
9
|
}),
|
|
13
|
-
]
|
|
14
|
-
invalid_type_error: 'Logo must be a string or an object with light and dark properties.',
|
|
15
|
-
});
|
|
10
|
+
]);
|
|
16
11
|
export const modeToggleSchema = z.object({
|
|
17
|
-
default: z
|
|
18
|
-
|
|
19
|
-
errorMap: () => {
|
|
20
|
-
return {
|
|
21
|
-
message: 'modeToggleSchema.default must be one of the following: light or dark',
|
|
22
|
-
};
|
|
23
|
-
},
|
|
24
|
-
})
|
|
25
|
-
.optional(),
|
|
26
|
-
isHidden: z
|
|
27
|
-
.boolean({
|
|
28
|
-
invalid_type_error: 'isHidden must be a boolean. Try writing true or false without the quotes.',
|
|
29
|
-
})
|
|
30
|
-
.optional(),
|
|
12
|
+
default: z.enum(['light', 'dark']).optional(),
|
|
13
|
+
isHidden: z.boolean().optional(),
|
|
31
14
|
});
|
|
32
|
-
export const isWhiteLabeledSchema = z.boolean(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
.string({ invalid_type_error: 'metadata values must be strings' })
|
|
37
|
-
.min(1, 'metadata values must not be empty'));
|
|
38
|
-
export const footerSocialsSchema = z.union([
|
|
15
|
+
export const isWhiteLabeledSchema = z.boolean();
|
|
16
|
+
export const metadataSchema = z.record(z.string(), z.string().nonempty());
|
|
17
|
+
export const footerSocialsSchema = z
|
|
18
|
+
.union([
|
|
39
19
|
// TO DO: deprecate array types
|
|
40
20
|
z.array(z.object({
|
|
41
21
|
type: z.string(),
|
|
42
|
-
url: z.string().url('
|
|
22
|
+
url: z.string().url('Must be a valid url'),
|
|
43
23
|
})),
|
|
44
|
-
z.record(z.string().trim().
|
|
45
|
-
]
|
|
46
|
-
|
|
47
|
-
});
|
|
24
|
+
z.record(z.string().trim().nonempty(), z.string().url('Must be a valid url')),
|
|
25
|
+
])
|
|
26
|
+
.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: { "twitter": "https://twitter.com/mintlify" }');
|
|
48
27
|
export const feedbackSchema = z.object({
|
|
49
|
-
thumbsRating: z
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
})
|
|
53
|
-
.optional(),
|
|
54
|
-
suggestEdit: z
|
|
55
|
-
.boolean({
|
|
56
|
-
invalid_type_error: 'suggestEdit must be a boolean. Try writing true or false without the quotes.',
|
|
57
|
-
})
|
|
58
|
-
.optional(),
|
|
59
|
-
raiseIssue: z
|
|
60
|
-
.boolean({
|
|
61
|
-
invalid_type_error: 'raiseIssue must be a boolean. Try writing true or false without the quotes.',
|
|
62
|
-
})
|
|
63
|
-
.optional(),
|
|
28
|
+
thumbsRating: z.boolean().optional(),
|
|
29
|
+
suggestEdit: z.boolean().optional(),
|
|
30
|
+
raiseIssue: z.boolean().optional(),
|
|
64
31
|
});
|
|
65
32
|
export const searchSchema = z.object({
|
|
66
|
-
prompt: z
|
|
67
|
-
.string({
|
|
68
|
-
invalid_type_error: 'search.prompt must be a string. If this field is undefined, the default prompt is `Search or ask...`',
|
|
69
|
-
})
|
|
70
|
-
.optional(),
|
|
33
|
+
prompt: z.string().optional(),
|
|
71
34
|
});
|
|
72
35
|
const redirectSchema = z.object({
|
|
73
36
|
source: z.string(),
|
|
74
37
|
destination: z.string(),
|
|
75
38
|
});
|
|
76
|
-
export const redirectsSchema = z
|
|
77
|
-
.array(redirectSchema, {
|
|
78
|
-
invalid_type_error: 'redirects must be an array of objects with source and destination properties',
|
|
79
|
-
})
|
|
80
|
-
.refine((value) => {
|
|
39
|
+
export const redirectsSchema = z.array(redirectSchema).refine((value) => {
|
|
81
40
|
const keys = value.map((obj) => obj.source);
|
|
82
41
|
return new Set(keys).size === keys.length;
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
export const createCtaButtonSchema = (ctaButtonName) => z.union([
|
|
42
|
+
}, 'Sources in the array must be unique');
|
|
43
|
+
export const ctaButtonSchema = z
|
|
44
|
+
.union([
|
|
87
45
|
z
|
|
88
46
|
.object({
|
|
89
47
|
type: z.literal('link').optional(),
|
|
90
|
-
name: z.string(
|
|
91
|
-
|
|
92
|
-
invalid_type_error: 'Name must be a string',
|
|
93
|
-
}),
|
|
94
|
-
url: z
|
|
95
|
-
.string({
|
|
96
|
-
required_error: ctaButtonName + '.url is missing',
|
|
97
|
-
invalid_type_error: ctaButtonName + '.url must be a string',
|
|
98
|
-
})
|
|
99
|
-
.min(1, ctaButtonName + '.url cannot be empty'),
|
|
48
|
+
name: z.string(),
|
|
49
|
+
url: z.string().nonempty(),
|
|
100
50
|
})
|
|
101
|
-
.strict(
|
|
102
|
-
' can only contain name, url, and type properties. Set a different type if you need to set other fields.'),
|
|
51
|
+
.strict(),
|
|
103
52
|
z
|
|
104
53
|
.object({
|
|
105
54
|
type: z.literal('github'),
|
|
106
|
-
url: z
|
|
107
|
-
.string({
|
|
108
|
-
required_error: ctaButtonName +
|
|
109
|
-
'.url is missing. Please set the url to a link to your GitHub repository.',
|
|
110
|
-
invalid_type_error: ctaButtonName +
|
|
111
|
-
'.url must be a string. Specifically, set the url to a link to your GitHub repository.',
|
|
112
|
-
})
|
|
113
|
-
.url(ctaButtonName + '.url must be a valid url pointing to your GitHub repository.'),
|
|
55
|
+
url: z.string().url('Must be a valid URL').describe('A link to your GitHub repository'),
|
|
114
56
|
})
|
|
115
|
-
.strict(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
invalid_type_error: ctaButtonName +
|
|
119
|
-
' must be an object. The object can have type="link" (the default) if you define a url and a name. You can also have type="github" if you define a url pointing to your GitHub repo and set the type in the object.',
|
|
120
|
-
});
|
|
57
|
+
.strict(),
|
|
58
|
+
])
|
|
59
|
+
.describe('An object containing the configuration for a Call-to-Action button. The object can have { "type": "link" } (the default) if you define a url and a name. For links to your GitHub repo, use { "type": "github" }');
|
|
@@ -3,21 +3,19 @@ import { anchorColorSchema } from './anchorColors.js';
|
|
|
3
3
|
import { hexColor } from './hexColor.js';
|
|
4
4
|
export const colorsSchema = z
|
|
5
5
|
.object({
|
|
6
|
-
primary: hexColor
|
|
7
|
-
light: hexColor
|
|
8
|
-
dark: hexColor
|
|
6
|
+
primary: hexColor,
|
|
7
|
+
light: hexColor.optional(),
|
|
8
|
+
dark: hexColor.optional(),
|
|
9
9
|
background: z
|
|
10
10
|
.object({
|
|
11
|
-
light: hexColor
|
|
12
|
-
dark: hexColor
|
|
11
|
+
light: hexColor.optional(),
|
|
12
|
+
dark: hexColor.optional(),
|
|
13
13
|
})
|
|
14
14
|
.optional(),
|
|
15
15
|
anchors: anchorColorSchema.optional(),
|
|
16
16
|
// Prevent strict() from throwing an error when the user defines a deprecated ultraLight / ultraDark color.
|
|
17
17
|
ultraLight: z.any().optional(),
|
|
18
18
|
ultraDark: z.any().optional(),
|
|
19
|
-
}, {
|
|
20
|
-
required_error: 'Colors are missing. You need to define at least the primary color. For example: { "colors": { "primary": "#ff0000" } }',
|
|
21
|
-
invalid_type_error: 'Colors must be an object.',
|
|
22
19
|
})
|
|
23
|
-
.strict(
|
|
20
|
+
.strict()
|
|
21
|
+
.describe('The colors to use in your documentation. At the very least, you must define the primary color. For example: { "colors": { "primary": "#ff0000" } }');
|
|
@@ -366,7 +366,7 @@ export declare const mintConfigSchema: z.ZodObject<{
|
|
|
366
366
|
hjsv: string;
|
|
367
367
|
}>>;
|
|
368
368
|
koala: z.ZodOptional<z.ZodObject<{
|
|
369
|
-
publicApiKey: z.
|
|
369
|
+
publicApiKey: z.ZodString;
|
|
370
370
|
}, "strip", z.ZodTypeAny, {
|
|
371
371
|
publicApiKey: string;
|
|
372
372
|
}, {
|
|
@@ -531,7 +531,6 @@ export declare const mintConfigSchema: z.ZodObject<{
|
|
|
531
531
|
indexHiddenPages?: boolean | undefined;
|
|
532
532
|
}>>;
|
|
533
533
|
}, "strip", z.ZodTypeAny, {
|
|
534
|
-
navigation: import("@mintlify/models").NavigationGroup[];
|
|
535
534
|
name: string;
|
|
536
535
|
$schema: string;
|
|
537
536
|
favicon: string;
|
|
@@ -551,6 +550,7 @@ export declare const mintConfigSchema: z.ZodObject<{
|
|
|
551
550
|
ultraLight?: any;
|
|
552
551
|
ultraDark?: any;
|
|
553
552
|
};
|
|
553
|
+
navigation: import("@mintlify/models").NavigationGroup[];
|
|
554
554
|
mintlify?: string | undefined;
|
|
555
555
|
logo?: string | {
|
|
556
556
|
light: string;
|
|
@@ -692,7 +692,6 @@ export declare const mintConfigSchema: z.ZodObject<{
|
|
|
692
692
|
indexHiddenPages?: boolean | undefined;
|
|
693
693
|
} | undefined;
|
|
694
694
|
}, {
|
|
695
|
-
navigation: import("@mintlify/models").NavigationGroup[];
|
|
696
695
|
name: string;
|
|
697
696
|
favicon: string;
|
|
698
697
|
colors: {
|
|
@@ -711,6 +710,7 @@ export declare const mintConfigSchema: z.ZodObject<{
|
|
|
711
710
|
ultraLight?: any;
|
|
712
711
|
ultraDark?: any;
|
|
713
712
|
};
|
|
713
|
+
navigation: import("@mintlify/models").NavigationGroup[];
|
|
714
714
|
$schema?: string | undefined;
|
|
715
715
|
mintlify?: string | undefined;
|
|
716
716
|
logo?: string | {
|
|
@@ -2,7 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
import { analyticsSchema } from './analytics.js';
|
|
3
3
|
import { anchorSchema, topAnchorSchema } from './anchors.js';
|
|
4
4
|
import { apiSchema, openApiSchema } from './apiReference.js';
|
|
5
|
-
import { nameSchema, logoSchema, modeToggleSchema, isWhiteLabeledSchema, footerSocialsSchema, feedbackSchema, metadataSchema,
|
|
5
|
+
import { nameSchema, logoSchema, modeToggleSchema, isWhiteLabeledSchema, footerSocialsSchema, feedbackSchema, metadataSchema, ctaButtonSchema, searchSchema, redirectsSchema, } from './basics.js';
|
|
6
6
|
import { colorsSchema } from './colors.js';
|
|
7
7
|
import { faviconSchema } from './favicon.js';
|
|
8
8
|
import { integrationsSchema } from './integrations.js';
|
|
@@ -22,8 +22,8 @@ export const mintConfigSchema = z.object({
|
|
|
22
22
|
versions: versionsSchema.optional(),
|
|
23
23
|
metadata: metadataSchema.optional(),
|
|
24
24
|
colors: colorsSchema,
|
|
25
|
-
topbarCtaButton:
|
|
26
|
-
topbarLinks:
|
|
25
|
+
topbarCtaButton: ctaButtonSchema.optional(),
|
|
26
|
+
topbarLinks: ctaButtonSchema.array().optional(),
|
|
27
27
|
navigation: navigationSchema,
|
|
28
28
|
primaryTab: primaryTabSchema.optional(),
|
|
29
29
|
topAnchor: topAnchorSchema.optional(),
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export const faviconSchema = z
|
|
3
|
-
.string(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
})
|
|
7
|
-
.refine((val) => val.split('.').pop() !== 'ico', {
|
|
8
|
-
message: 'Favicon cannot be an .ico file.',
|
|
9
|
-
});
|
|
3
|
+
.string()
|
|
4
|
+
.refine((val) => !val.endsWith('.ico'), 'Favicon cannot be an .ico file')
|
|
5
|
+
.describe('A path pointing to the favicon file in your docs folder, including the file extension. We recommend using an .svg or .png file. The favicon will automatically be resized to the appropriate sizes');
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export declare const hexColor:
|
|
2
|
+
export declare const hexColor: z.ZodString;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
const hexColorRegex = /^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/;
|
|
3
|
-
export const hexColor =
|
|
4
|
-
.string(
|
|
5
|
-
.regex(hexColorRegex,
|
|
3
|
+
export const hexColor = z
|
|
4
|
+
.string()
|
|
5
|
+
.regex(hexColorRegex, 'Must be a hex color string, with a leading #');
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
const intercomSchema = z
|
|
3
|
-
|
|
4
|
-
.min(6, 'integrations.intercom must be a valid Intercom app ID');
|
|
5
|
-
const frontchatSchema = z
|
|
6
|
-
.string({ invalid_type_error: 'integrations.frontchat must be a string' })
|
|
7
|
-
.min(6, 'integrations.frontchat must be a valid Front chat snippet id');
|
|
2
|
+
const intercomSchema = z.string().min(6, 'Must be a valid Intercom app ID');
|
|
3
|
+
const frontchatSchema = z.string().min(6, 'Must be a valid Front chat snippet id');
|
|
8
4
|
export const integrationsSchema = z.object({
|
|
9
5
|
intercom: intercomSchema.optional(),
|
|
10
6
|
frontchat: frontchatSchema.optional(),
|
|
11
|
-
}
|
|
7
|
+
});
|
|
@@ -5,31 +5,13 @@ export const baseNavigationGroupSchema = z
|
|
|
5
5
|
.object({
|
|
6
6
|
// We allow top-level groups to be an empty string if the user wants to hide the title.
|
|
7
7
|
// Future work should refactor this so nested groups are non-empty strings.
|
|
8
|
-
group: z.string(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
.enum(iconTypes, {
|
|
15
|
-
errorMap: () => {
|
|
16
|
-
return {
|
|
17
|
-
message: 'group iconType must be one of the following strings: brands, duotone, light, sharp-solid, solid, thin',
|
|
18
|
-
};
|
|
19
|
-
},
|
|
20
|
-
})
|
|
21
|
-
.optional(),
|
|
22
|
-
version: z.string({ invalid_type_error: 'Version must be a string.' }).optional(),
|
|
23
|
-
}, { invalid_type_error: 'Navigation entry must be an object.' })
|
|
24
|
-
.strict('Navigation entry can only contain group, pages, icon, and version.');
|
|
8
|
+
group: z.string().describe('The label for this group in the navigation sidebar'),
|
|
9
|
+
icon: z.string().optional(),
|
|
10
|
+
iconType: z.enum(iconTypes).optional(),
|
|
11
|
+
version: z.string().optional(),
|
|
12
|
+
})
|
|
13
|
+
.strict();
|
|
25
14
|
const navigationGroupSchema = baseNavigationGroupSchema.extend({
|
|
26
|
-
pages: z.lazy(() => z
|
|
27
|
-
.array(z.union([navigationGroupSchema, z.string().min(1, 'Page cannot be an empty string.')]))
|
|
28
|
-
.min(1, "Pages array can't be empty.")),
|
|
15
|
+
pages: z.lazy(() => z.array(z.union([navigationGroupSchema, z.string().nonempty()])).nonempty()),
|
|
29
16
|
});
|
|
30
|
-
export const navigationSchema = z
|
|
31
|
-
.array(navigationGroupSchema, {
|
|
32
|
-
required_error: 'Navigation is missing.',
|
|
33
|
-
invalid_type_error: 'Navigation must be an array.',
|
|
34
|
-
})
|
|
35
|
-
.min(1, 'Navigation cannot be an empty array. Please add at least one group.');
|
|
17
|
+
export const navigationSchema = z.array(navigationGroupSchema).min(1);
|
|
@@ -1,33 +1,12 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
const tabSchema = z.object({
|
|
3
|
-
name: z
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
invalid_type_error: 'Tab name must be a string.',
|
|
7
|
-
})
|
|
8
|
-
.trim()
|
|
9
|
-
.min(1, 'Tab name is empty.'),
|
|
10
|
-
url: z
|
|
11
|
-
.string({
|
|
12
|
-
required_error: 'Every tab must have a url',
|
|
13
|
-
invalid_type_error: 'Tab url must be a string.',
|
|
14
|
-
})
|
|
15
|
-
.trim()
|
|
16
|
-
.min(1, 'Tab URL is missing.'),
|
|
17
|
-
version: z
|
|
18
|
-
.string({
|
|
19
|
-
invalid_type_error: 'Version must be a string in the versions array.',
|
|
20
|
-
})
|
|
21
|
-
.optional(),
|
|
3
|
+
name: z.string().trim().nonempty(),
|
|
4
|
+
url: z.string().trim().nonempty(),
|
|
5
|
+
version: z.string().optional(),
|
|
22
6
|
});
|
|
23
7
|
export const tabsSchema = tabSchema.array();
|
|
24
8
|
export const primaryTabSchema = z
|
|
25
9
|
.object({
|
|
26
|
-
name: z.string(
|
|
27
|
-
required_error: 'primaryTab.name is missing, set it or delete the entire primaryTab property.',
|
|
28
|
-
invalid_type_error: 'primaryTab.name must be a string',
|
|
29
|
-
}),
|
|
30
|
-
}, {
|
|
31
|
-
invalid_type_error: 'primaryTab must be an object with a name property.',
|
|
10
|
+
name: z.string(),
|
|
32
11
|
})
|
|
33
|
-
.strict(
|
|
12
|
+
.strict();
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
const versionSchema = z.union([
|
|
3
|
-
z.string(
|
|
3
|
+
z.string(),
|
|
4
4
|
z
|
|
5
5
|
.object({
|
|
6
|
-
name: z.string().
|
|
7
|
-
url: z.string().
|
|
6
|
+
name: z.string().nonempty(),
|
|
7
|
+
url: z.string().nonempty(),
|
|
8
8
|
})
|
|
9
|
-
.strict(
|
|
9
|
+
.strict(),
|
|
10
10
|
]);
|
|
11
|
-
export const versionsSchema = z
|
|
12
|
-
.array(versionSchema)
|
|
13
|
-
.min(1, 'Versions array cannot be empty. Either delete the property or add strings to the array.');
|
|
11
|
+
export const versionsSchema = z.array(versionSchema).min(1);
|