Skip to content

Commit

Permalink
Stricter Zod validation
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlancollins committed Nov 6, 2023
1 parent 9fff772 commit f97d23f
Showing 1 changed file with 40 additions and 8 deletions.
48 changes: 40 additions & 8 deletions src/lib/schemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,63 @@ import { z } from 'zod';
export const componentsSchema = z.array(
z.object({
title: z.string(),
url: z.string().optional(),
repository: z.string(),
npm: z
.string()
.regex(/(@[\w-]+\/)?[\w-]+/)
.optional(),
url: z.string().url().optional(),
repository: z.string().url(),
description: z.string(),
npm: z.string().optional(),
category: z.string(),
category: z.enum([
'Display Components',
'Developer Experience',
'Internationalization',
'CSS and Layout',
'Icons',
'Multimedia',
'Testing',
'Data Visualisation',
'Integration',
'Design Pattern',
'Stores',
'Routers',
'SvelteKit Adapters',
'Design System',
'User Interaction',
'Forms & User Input'
]),
tags: z.array(z.string()).optional()
})
);

export const templatesSchema = z.array(
z.object({
title: z.string(),
repository: z.string(),
url: z.string().url().optional(),
repository: z.string().url(),
description: z.string(),
category: z.string(),
category: z.enum(['Svelte Add', 'SvelteKit', 'Svelte']),
tags: z.array(z.string()).optional()
})
);

export const toolsSchema = z.array(
z.object({
title: z.string(),
repository: z.string(),
npm: z
.string()
.regex(/(@[\w-]+\/)?[\w-]+/)
.optional(),
url: z.string().url().optional(),
repository: z.string().url(),
description: z.string(),
category: z.string(),
category: z.enum([
'Debugging',
'Linting and Formatting',
'Editor Extensions',
'Bundler Plugins',
'Preprocessors'
]),
tags: z.array(z.string()).optional()
})
);

0 comments on commit f97d23f

Please sign in to comment.