Make credential optional

This commit is contained in:
Fang-Pen Lin
2026-01-05 17:15:53 -08:00
parent 4964e60793
commit 56d545a187
3 changed files with 24 additions and 4 deletions

View File

@@ -25,8 +25,17 @@ export const RedisResourceConnectionDetailsSchema = z.object({
});
export const RedisAccountCredentialsSchema = z.object({
username: z.string().trim().min(1).max(63),
password: z.string().trim().min(1).max(256)
username: z
.string()
.trim()
.max(256, "Username must be 255 characters or less")
.transform((value) => (value === "" ? undefined : value))
.optional(),
password: z
.string()
.max(256, "Password must be 256 characters or less")
.transform((value) => (value === "" ? undefined : value))
.optional()
});
const BaseRedisResourceSchema = BasePamResourceSchema.extend({ resourceType: z.literal(PamResource.Redis) });

View File

@@ -18,8 +18,17 @@ type Props = {
const formSchema = genericAccountFieldsSchema.extend({
credentials: z.object({
username: z.string().trim().max(256, "Username must be 255 characters or less"),
password: z.string().max(256, "Password must be 256 characters or less")
username: z
.string()
.trim()
.max(256, "Username must be 255 characters or less")
.transform((value) => (value === "" ? undefined : value))
.optional(),
password: z
.string()
.max(256, "Password must be 256 characters or less")
.transform((value) => (value === "" ? undefined : value))
.optional()
}),
// We don't support rotation for now, just feed a false value to
// make the schema happy

View File

@@ -26,6 +26,7 @@ export const UsernamePasswordFields = ({ isUpdate }: { isUpdate: boolean }) => {
errorText={error?.message}
isError={Boolean(error?.message)}
label="Username"
isOptional
>
<Input {...field} autoComplete="off" />
</FormControl>
@@ -40,6 +41,7 @@ export const UsernamePasswordFields = ({ isUpdate }: { isUpdate: boolean }) => {
errorText={error?.message}
isError={Boolean(error?.message)}
label="Password"
isOptional
>
<Input
{...field}