From 4e1fae5b5f2e75bd379d4688bf8761c270b1d5d8 Mon Sep 17 00:00:00 2001 From: James Grugett Date: Sun, 14 Aug 2022 20:51:10 -0500 Subject: [PATCH] Require a whole percentage for limitProb in back end --- functions/src/place-bet.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/functions/src/place-bet.ts b/functions/src/place-bet.ts index 7501309a..8fb5179d 100644 --- a/functions/src/place-bet.ts +++ b/functions/src/place-bet.ts @@ -30,7 +30,15 @@ const bodySchema = z.object({ const binarySchema = z.object({ outcome: z.enum(['YES', 'NO']), - limitProb: z.number().gte(0.001).lte(0.999).optional(), + limitProb: z + .number() + .gte(0.001) + .lte(0.999) + .refine( + (p) => Math.round(p * 100) === p * 100, + 'limitProb must be in increments of 0.01 (i.e. whole percentage points)' + ) + .optional(), }) const freeResponseSchema = z.object({