improvements: prevent comma separated value usage with eq and neq checks

This commit is contained in:
Scott Wilson
2025-06-04 14:21:36 -07:00
parent caeda09b21
commit 54435d0ad9

View File

@@ -226,6 +226,23 @@ const ConditionSchema = z
: el.rhs.trim().startsWith("/")
),
{ message: "Invalid Secret Path. Must start with '/'" }
)
.refine(
(val) =>
val
.filter((el) => el.operator === PermissionConditionOperators.$EQ)
.every((el) => !el.rhs.includes(",")),
{ message: '"Equal" checks cannot contain comma separated values. Use "IN" operator instead.' }
)
.refine(
(val) =>
val
.filter((el) => el.operator === PermissionConditionOperators.$NEQ)
.every((el) => !el.rhs.includes(",")),
{
message:
'"Not Equal" checks cannot contain comma separated values. Use "IN" operator with "Forbid" instead.'
}
);
export const projectRoleFormSchema = z.object({