improvement: address feedback

This commit is contained in:
Scott Wilson
2024-10-31 10:24:30 -07:00
parent b693c035ce
commit 7dd6eac20a
5 changed files with 50 additions and 39 deletions
@@ -29,7 +29,7 @@ const formSchema = z.object({
password: z.string().trim().min(1),
creationStatement: z.string().trim().min(1),
revocationStatement: z.string().trim().min(1),
renewStatement: z.string().trim().min(1)
renewStatement: z.string().trim().optional()
}),
defaultTTL: z.string().superRefine((val, ctx) => {
const valMs = ms(val);
@@ -51,7 +51,11 @@ const formSchema = z.object({
if (valMs > 24 * 60 * 60 * 1000)
ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than a day" });
}),
name: z.string().refine((val) => val.toLowerCase() === val, "Must be lowercase")
name: z
.string()
.trim()
.min(1)
.refine((val) => val.toLowerCase() === val, "Must be lowercase")
});
type TForm = z.infer<typeof formSchema>;
@@ -105,7 +109,7 @@ export const SnowflakeInputForm = ({
} catch (err) {
createNotification({
type: "error",
text: "Failed to create dynamic secret"
text: err instanceof Error ? err.message : "Failed to create dynamic secret"
});
}
};
@@ -28,9 +28,9 @@ const formSchema = z.object({
orgId: z.string().min(1),
username: z.string().min(1),
password: z.string().min(1),
creationStatement: z.string().min(1),
revocationStatement: z.string().min(1),
renewStatement: z.string().optional()
creationStatement: z.string().trim().min(1),
revocationStatement: z.string().trim().min(1),
renewStatement: z.string().trim().optional()
})
.partial(),
defaultTTL: z.string().superRefine((val, ctx) => {
@@ -53,7 +53,11 @@ const formSchema = z.object({
if (valMs > 24 * 60 * 60 * 1000)
ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than a day" });
}),
newName: z.string().refine((val) => val.toLowerCase() === val, "Must be lowercase")
newName: z
.string()
.trim()
.min(1)
.refine((val) => val.toLowerCase() === val, "Must be lowercase")
});
type TForm = z.infer<typeof formSchema>;
@@ -114,7 +118,7 @@ export const EditDynamicSecretSnowflakeForm = ({
} catch (err) {
createNotification({
type: "error",
text: "Failed to update dynamic secret"
text: err instanceof Error ? err.message : "Failed to create dynamic secret"
});
}
};