fix: workspace name validation added (#1702)

This commit is contained in:
Anmol Singh Bhatia
2023-07-31 12:03:16 +05:30
committed by GitHub
parent d9ce042dff
commit 47838a506a
2 changed files with 23 additions and 13 deletions

View File

@@ -140,6 +140,10 @@ export const CreateWorkspaceForm: React.FC<Props> = ({
validate: (value) => validate: (value) =>
/^[\w\s-]*$/.test(value) || /^[\w\s-]*$/.test(value) ||
`Name can only contain (" "), ( - ), ( _ ) & alphanumeric characters.`, `Name can only contain (" "), ( - ), ( _ ) & alphanumeric characters.`,
maxLength: {
value: 80,
message: "Workspace name should not exceed 80 characters",
},
}} }}
placeholder="Enter workspace name..." placeholder="Enter workspace name..."
error={errors.name} error={errors.name}

View File

@@ -224,12 +224,13 @@ const WorkspaceSettings: NextPage = () => {
<p className="text-sm text-custom-text-200">Your workspace URL.</p> <p className="text-sm text-custom-text-200">Your workspace URL.</p>
</div> </div>
<div className="col-span-12 flex items-center gap-2 sm:col-span-6"> <div className="col-span-12 flex items-center gap-2 sm:col-span-6">
<div className="flex flex-col gap-1">
<Input <Input
id="url" id="url"
name="url" name="url"
autoComplete="off" autoComplete="off"
register={register} register={register}
error={errors.name} error={errors.url}
className="w-full" className="w-full"
value={`${ value={`${
typeof window !== "undefined" && typeof window !== "undefined" &&
@@ -237,6 +238,7 @@ const WorkspaceSettings: NextPage = () => {
}/${activeWorkspace.slug}`} }/${activeWorkspace.slug}`}
disabled disabled
/> />
</div>
<SecondaryButton <SecondaryButton
className="h-min" className="h-min"
onClick={() => onClick={() =>
@@ -273,6 +275,10 @@ const WorkspaceSettings: NextPage = () => {
error={errors.name} error={errors.name}
validations={{ validations={{
required: "Name is required", required: "Name is required",
maxLength: {
value: 80,
message: "Workspace name should not exceed 80 characters",
},
}} }}
/> />
</div> </div>