Skip to content

Commit eed36e5

Browse files
authored
Merge pull request #3348 from Bima42/feat/3345-allow-services-to-end-with-numbers
fix: update regex to allow number at the end of app name
2 parents da23967 + dd28a8e commit eed36e5

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

apps/dokploy/components/dashboard/project/add-application.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import {
4343
} from "@/components/ui/tooltip";
4444
import { slugify } from "@/lib/slug";
4545
import { api } from "@/utils/api";
46+
import { APP_NAME_MESSAGE, APP_NAME_REGEX } from "@/utils/schema";
4647

4748
const AddTemplateSchema = z.object({
4849
name: z.string().min(1, {
@@ -53,9 +54,8 @@ const AddTemplateSchema = z.object({
5354
.min(1, {
5455
message: "App name is required",
5556
})
56-
.regex(/^[a-z](?!.*--)([a-z0-9-]*[a-z])?$/, {
57-
message:
58-
"App name supports lowercase letters, numbers, '-' and can only start and end letters, and does not support continuous '-'",
57+
.regex(APP_NAME_REGEX, {
58+
message: APP_NAME_MESSAGE,
5959
}),
6060
description: z.string().optional(),
6161
serverId: z.string().optional(),

apps/dokploy/components/dashboard/project/add-compose.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import {
4343
} from "@/components/ui/tooltip";
4444
import { slugify } from "@/lib/slug";
4545
import { api } from "@/utils/api";
46+
import { APP_NAME_MESSAGE, APP_NAME_REGEX } from "@/utils/schema";
4647

4748
const AddComposeSchema = z.object({
4849
composeType: z.enum(["docker-compose", "stack"]).optional(),
@@ -54,9 +55,8 @@ const AddComposeSchema = z.object({
5455
.min(1, {
5556
message: "App name is required",
5657
})
57-
.regex(/^[a-z](?!.*--)([a-z0-9-]*[a-z])?$/, {
58-
message:
59-
"App name supports lowercase letters, numbers, '-' and can only start and end letters, and does not support continuous '-'",
58+
.regex(APP_NAME_REGEX, {
59+
message: APP_NAME_MESSAGE,
6060
}),
6161
description: z.string().optional(),
6262
serverId: z.string().optional(),
@@ -78,9 +78,6 @@ export const AddCompose = ({ environmentId, projectName }: Props) => {
7878
const { mutateAsync, isPending, error, isError } =
7979
api.compose.create.useMutation();
8080

81-
// Get environment data to extract projectId
82-
// const { data: environment } = api.environment.one.useQuery({ environmentId });
83-
8481
const hasServers = servers && servers.length > 0;
8582
// Show dropdown logic based on cloud environment
8683
// Cloud: show only if there are remote servers (no Dokploy option)

apps/dokploy/components/dashboard/project/add-database.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import {
5252
} from "@/components/ui/tooltip";
5353
import { slugify } from "@/lib/slug";
5454
import { api } from "@/utils/api";
55+
import { APP_NAME_MESSAGE, APP_NAME_REGEX } from "@/utils/schema";
5556

5657
type DbType = z.infer<typeof mySchema>["type"];
5758

@@ -82,9 +83,8 @@ const baseDatabaseSchema = z.object({
8283
.min(1, {
8384
message: "App name is required",
8485
})
85-
.regex(/^[a-z](?!.*--)([a-z0-9-]*[a-z])?$/, {
86-
message:
87-
"App name supports lowercase letters, numbers, '-' and can only start and end letters, and does not support continuous '-'",
86+
.regex(APP_NAME_REGEX, {
87+
message: APP_NAME_MESSAGE,
8888
}),
8989
databasePassword: z
9090
.string()

apps/dokploy/utils/schema.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ if (typeof window === "undefined") {
1010
})();
1111
}
1212

13+
export const APP_NAME_REGEX = /^[a-z](?!.*--)([a-z0-9-]*[a-z0-9])?$/;
14+
export const APP_NAME_MESSAGE =
15+
"App name supports lowercase letters, numbers, '-' and must start with a letter, end with a letter or number, and cannot contain consecutive '-'";
16+
1317
export const uploadFileSchema = zfd.formData({
1418
applicationId: z.string().optional(),
1519
zip: zfd.file(),

0 commit comments

Comments
 (0)