Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
better validation
Roman Pominov76c49ebefee7
diff --git a/apps/designer/app/routes/rest/pages.$projectId.ts b/apps/designer/app/routes/rest/pages.$projectId.tsindex d2ce939e7a..de3913590d 100644--- a/apps/designer/app/routes/rest/pages.$projectId.ts+++ b/apps/designer/app/routes/rest/pages.$projectId.ts@@ -6,23 +6,27 @@ import { z } from "zod";import { PutPageData } from "~/designer/features/sidebar-left/panels/pages/settings";import { sentryException } from "~/shared/sentry";-const nonEmptyString = (fieldName: string) => {- const message = `${fieldName} can't be empty`;- return z- .string({ invalid_type_error: message, required_error: message })- .transform((v) => v.trim())- .refine((val) => val !== "", message);-};+const nonEmptyString = z+ .string({+ invalid_type_error: "Can't be empty",+ required_error: "Can't be empty",+ })+ .transform((v) => v.trim())+ .refine((val) => val !== "", "Can't be empty");const CreatePageInput = zfd.formData({- name: nonEmptyString("Page Name"),- path: nonEmptyString("Path")- .refine((path) => path !== "/", "Path can't be /")+ name: nonEmptyString,+ path: nonEmptyString+ .refine((path) => path !== "/", "Can't be just a /").transform((path) => (path.endsWith("/") ? path.slice(0, -1) : path)).transform((path) => path.replace(/\/\//g, "/")).refine((path) => path === "" || path.startsWith("/"),- "Path must start with a /"+ "Must start with a /"+ )+ .refine(+ (path) => /^[-_a-z0-9\\/]*$/.test(path),+ "Only a-z, 0-9, -, _ and / are allowed"),});@@ -44,9 +48,7 @@ const handlePUT = async (errors: {formErrors: [],fieldErrors: {- path: [- `The path ${data.path} is already used for another page "${existingPage.name}"`,- ],+ path: [`Already used for "${existingPage.name}"`],},},};