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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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,19 +224,21 @@ 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">
<Input <div className="flex flex-col gap-1">
id="url" <Input
name="url" id="url"
autoComplete="off" name="url"
register={register} autoComplete="off"
error={errors.name} register={register}
className="w-full" error={errors.url}
value={`${ className="w-full"
typeof window !== "undefined" && value={`${
window.location.origin.replace("http://", "").replace("https://", "") typeof window !== "undefined" &&
}/${activeWorkspace.slug}`} window.location.origin.replace("http://", "").replace("https://", "")
disabled }/${activeWorkspace.slug}`}
/> 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>