Openstatus www.openstatus.dev

๐Ÿ› page slug can't be empty (#169)

* ๐Ÿ› page slug can't be empty

* ๐Ÿ˜ pr checked

authored by

Thibault Le Ouay and committed by
GitHub
637c729e c2bdf1ea

+12 -8
+12 -8
packages/db/src/schema/page.ts
··· 38 38 }), 39 39 })); 40 40 41 + const slugSchema = z 42 + .string() 43 + .regex( 44 + new RegExp("^[A-Za-z0-9-]+$"), 45 + "Only use digits (0-9), hyphen (-) or characters (A-Z, a-z).", 46 + ) 47 + .min(3) 48 + .toLowerCase(); 49 + 41 50 // Schema for inserting a Page - can be used to validate API requests 42 51 export const insertPageSchema = createInsertSchema(page, { 43 52 customDomain: z.string().optional(), 44 - slug: z 45 - .string() 46 - .regex( 47 - new RegExp("^[A-Za-z0-9-]+$"), 48 - "Only use digits (0-9), hyphen (-) or characters (A-Z, a-z).", 49 - ) 50 - .min(3), 53 + slug: slugSchema, 51 54 }); 52 55 53 56 export const insertPageSchemaWithMonitors = insertPageSchema.extend({ 54 57 customDomain: z.string().optional().default(""), 55 58 monitors: z.array(z.number()).optional(), 56 59 workspaceSlug: z.string().optional(), 57 - slug: z.string().toLowerCase(), 60 + slug: slugSchema, 58 61 }); 62 + 59 63 // Schema for selecting a Page - can be used to validate API responses 60 64 export const selectPageSchema = createSelectSchema(page);