Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Fix: Fixed field should not allow only whitespace values issue #2318

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ const formSchema = z.object({
prefix: z
.string()
.max(8, { message: "Please limit the prefix to under 8 characters." })
.refine(prefix => !prefix.includes(' '), {
message: "Prefix cannot contain spaces.",
})
.optional(),
ownerId: z.string().optional(),
name: z.string().optional(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export const DefaultPrefix: React.FC<Props> = ({ keyAuth }) => {
},
});
async function onSubmit(values: z.infer<typeof formSchema>) {
if (values.defaultPrefix.includes(' ')) {
return toast.error("Default prefix cannot contain spaces.");
}
if (values.defaultPrefix.length > 8) {
return toast.error("Default prefix is too long, maximum length is 8 characters.");
}
Expand Down
7 changes: 6 additions & 1 deletion apps/dashboard/lib/trpc/routers/api/setDefaultPrefix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ import { rateLimitedProcedure, ratelimit } from "@/lib/trpc/ratelimitProcedure";
export const setDefaultApiPrefix = rateLimitedProcedure(ratelimit.update)
.input(
z.object({
defaultPrefix: z.string().max(8, "Prefix can be a maximum of 8 characters"),
defaultPrefix: z
.string()
.max(8, "Prefix can be a maximum of 8 characters")
.refine(prefix => !prefix.includes(' '), {
message: "Default prefix cannot contain spaces.",
}),
keyAuthId: z.string(),
workspaceId: z.string(),
}),
Expand Down
8 changes: 7 additions & 1 deletion apps/dashboard/lib/trpc/routers/key/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ import { z } from "zod";
export const createKey = rateLimitedProcedure(ratelimit.create)
.input(
z.object({
prefix: z.string().optional(),
prefix: z
.string()
.max(8, { message: "Please limit the prefix to under 8 characters." })
.refine(prefix => !prefix.includes(' '), {
message: "Prefix cannot contain spaces.",
})
.optional(),
bytes: z.number().int().gte(1).default(16),
keyAuthId: z.string(),
ownerId: z.string().nullish(),
Expand Down
Loading