Skip to content

Commit 9aa8907

Browse files
authored
feat: Check for negative shares in voting
1 parent bef7c84 commit 9aa8907

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/routes/api/[sessionKey]/+server.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ export const POST: RequestHandler = async ({ params, request, platform }) => {
168168
badRequestError('All participants must have a description before voting');
169169
}
170170

171+
const negativeShare = vote.participants.some((p) => p.share < 0);
172+
if (negativeShare) {
173+
badRequestError('No share can be nagative');
174+
}
175+
171176
const totalShares = vote.participants.reduce((sum, s) => sum + s.share, 0);
172177
if (totalShares != session.stake) {
173178
badRequestError('Total shares must equal session stake');

0 commit comments

Comments
 (0)