validation

This commit is contained in:
mantikoros 2022-07-02 15:26:07 -04:00
parent d7c26662ca
commit 8b2a654d0c

View File

@ -53,13 +53,19 @@ const numericSchema = z.object({
value: z.number().optional(),
})
const pseudoNumericSchema = z.object({
outcome: z.union([z.literal('CANCEL'), z.literal('MKT')]),
value: z.number(),
probabilityInt: z.number().gte(0).lte(100),
})
const pseudoNumericSchema = z.union([
z.object({
outcome: z.literal('CANCEL'),
}),
z.object({
outcome: z.literal('MKT'),
value: z.number(),
probabilityInt: z.number().gte(0).lte(100),
}),
])
const opts = { secrets: ['MAILGUN_KEY'] }
export const resolvemarket = newEndpoint(opts, async (req, auth) => {
const { contractId } = validate(bodySchema, req.body)
const userId = auth.uid