diff --git a/apps/app/components/workspace/create-workspace-form.tsx b/apps/app/components/workspace/create-workspace-form.tsx index a18d63840..65c365a1a 100644 --- a/apps/app/components/workspace/create-workspace-form.tsx +++ b/apps/app/components/workspace/create-workspace-form.tsx @@ -42,6 +42,7 @@ export const CreateWorkspaceForm: React.FC = ({ setDefaultValues, }) => { const [slugError, setSlugError] = useState(false); + const [invalidSlug, setInvalidSlug] = useState(false); const { setToastAlert } = useToast(); @@ -130,11 +131,20 @@ export const CreateWorkspaceForm: React.FC = ({ name="slug" register={register} className="block w-full rounded-md bg-transparent py-2 px-0 text-sm" + validations={{ + required: "Workspace URL is required", + }} + onChange={(e) => + /^[a-zA-Z0-9_-]+$/.test(e.target.value) ? setInvalidSlug(false) : setInvalidSlug(true) + } /> {slugError && ( Workspace URL is already taken! )} + {invalidSlug && ( + {`URL can only contain ( - ), ( _ ) & Alphanumeric characters.`} + )}