From 277c01cac5e55233071058196ebb83b2db45017d Mon Sep 17 00:00:00 2001 From: Kefaku <114934849+Kefaku@users.noreply.github.com> Date: Thu, 18 Jan 2024 18:27:05 +0100 Subject: [PATCH] update slug error messages --- src/routes/projects/new/+page.server.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/routes/projects/new/+page.server.ts b/src/routes/projects/new/+page.server.ts index c19deee5..639d3c71 100644 --- a/src/routes/projects/new/+page.server.ts +++ b/src/routes/projects/new/+page.server.ts @@ -8,9 +8,13 @@ const newProjectSchema = z.object({ icon: z.ostring(), url: z .string() - .regex(/^[1-9a-z]+(-[1-9a-z]+)*$/, { - message: "Slug can only contain alphanumeric characters and hyphens!" + .regex(/^-*[1-9a-z]+(-[1-9a-z]+)*$/, { + message: "Slug can only contain lower case alphanumeric characters and hyphens!" }) + .regex(/^-/, { + message: "Slug may not start with a hyphen!" + }) + .min(1, { message: "Slug is empty!" }) .max(35, { message: "Slug too long!" }), title: z.string().max(35, { message: "Title too long!" }), description: z.string().min(3).max(200, { message: "Summary too long!" }),