feat: corrected validation

This commit is contained in:
=
2025-06-12 16:01:48 +05:30
parent 841408042e
commit 547ef17c10
2 changed files with 4 additions and 6 deletions

View File

@@ -39,7 +39,8 @@ export const registerAccessApprovalPolicyRouter = async (server: FastifyZodProvi
.max(100, "Cannot have more than 100 approvers")
.min(1, { message: "At least one approver should be provided" })
.refine(
(el) => el.every((i) => Object.hasOwn(i, "id") || Object.hasOwn(i, "username")),
// @ts-expect-error this is ok
(el) => el.every((i) => Boolean(i?.id) || Boolean(i?.username)),
"Must provide either username or id"
),
bypassers: z
@@ -193,7 +194,8 @@ export const registerAccessApprovalPolicyRouter = async (server: FastifyZodProvi
.min(1, { message: "At least one approver should be provided" })
.max(100, "Cannot have more than 100 approvers")
.refine(
(el) => el.every((i) => Object.hasOwn(i, "id") || Object.hasOwn(i, "username")),
// @ts-expect-error this is ok
(el) => el.every((i) => Boolean(i?.id) || Boolean(i?.username)),
"Must provide either username or id"
),
bypassers: z

View File

@@ -95,9 +95,6 @@ export const accessApprovalPolicyServiceFactory = ({
(approver) => approver.type === ApproverType.User && approver.username
) as { username: string; sequence?: number }[];
if (!groupApprovers && approvals > userApprovers.length + userApproverNames.length)
throw new BadRequestError({ message: "Approvals cannot be greater than approvers" });
const { permission } = await permissionService.getProjectPermission({
actor,
actorId,
@@ -137,7 +134,6 @@ export const accessApprovalPolicyServiceFactory = ({
}))
);
}
let groupBypassers: string[] = [];
let bypasserUserIds: string[] = [];