diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/settings/update-key-remaining.tsx b/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/settings/update-key-remaining.tsx index 35101c393..478497271 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/settings/update-key-remaining.tsx +++ b/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/settings/update-key-remaining.tsx @@ -107,7 +107,14 @@ export const UpdateKeyRemaining: React.FC = ({ apiKey }) => { if (values.refill?.interval === "none") { delete values.refill; } - + // make sure they aren't sent to the server if they are disabled. + if (values.refill?.interval !== "none" && !values.refill?.amount) { + form.setError("refill.amount", { + type: "manual", + message: "Please enter a value if interval is selected", + }); + return; + } if (!values.refill?.amount && values.refill?.refillDay && values.limitEnabled) { form.setError("refill.amount", { message: "Please enter the number of uses per interval or remove the refill day", diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/new/client.tsx b/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/new/client.tsx index 9f3b84648..1cf452c24 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/new/client.tsx +++ b/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/new/client.tsx @@ -85,7 +85,13 @@ export const CreateKey = ({ apiId, keyAuthId, defaultBytes, defaultPrefix }: Pro }); async function onSubmit(values: z.infer) { - // make sure they aren't sent to the server if they are disabled. + if (values.limit?.refill?.interval !== "none" && !values.limit?.refill?.amount) { + form.setError("limit.refill.amount", { + type: "manual", + message: "Please enter a value if interval is selected", + }); + return; + } if (!values.expireEnabled) { delete values.expires; }