Skip to content
Merged
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 @@ -88,7 +88,7 @@ export const CreateKey = ({ apiId, keyAuthId, defaultBytes, defaultPrefix }: Pro
},
onError(err) {
console.error(err);
toast.error(err.message);
toast.error(err.message || "An unknown error occurred");
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ export const formSchema = z.object({
.number({
errorMap: (issue, { defaultError }) => ({
message:
issue.code === "invalid_type"
? "Amount must be a number and greater than 0"
: defaultError,
issue.code === "invalid_type" ? "Key must be between 8 and 255 bytes long" : defaultError,
}),
})
.min(16)
.min(8, { message: "Key must be between 8 and 255 bytes long" })
.max(255, { message: "Key must be between 8 and 255 bytes long" })
.default(16),
prefix: z
.string()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const formSchema = z.object({
keyAuthId: z.string(),
defaultBytes: z
.number()
.min(16, "Byte size needs to be at least 16")
.max(255, "Byte size cannot exceed 255")
.min(8, "Key must be between 8 and 255 bytes long")
.max(255, "Key must be between 8 and 255 bytes long")
.optional(),
});

Expand Down
7 changes: 6 additions & 1 deletion apps/dashboard/lib/trpc/routers/key/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ export const createKey = t.procedure
message: "Prefixes cannot contain spaces.",
})
.optional(),
bytes: z.number().int().gte(16).default(16),
bytes: z
.number()
.int()
.min(8, { message: "Key must be between 8 and 255 bytes long" })
.max(255, { message: "Key must be between 8 and 255 bytes long" })
.default(16),
keyAuthId: z.string(),
ownerId: z.string().nullish(),
meta: z.record(z.unknown()).optional(),
Expand Down
Loading