From 70d7350474a95432090df760ae926e8761713453 Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Mon, 20 Feb 2023 20:22:06 -0700 Subject: [PATCH] Improve the guess payload validation schema --- src/endpoints/guess.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/endpoints/guess.ts b/src/endpoints/guess.ts index 1ace963..5021d40 100644 --- a/src/endpoints/guess.ts +++ b/src/endpoints/guess.ts @@ -13,7 +13,11 @@ const route: ServerRoute = { }), payload: Joi.object({ type: Joi.string().valid(`letter`, `solve`), - guess: Joi.string().length(1), + guess: Joi.when(`type`, { + is: `letter`, + then: Joi.string().length(1), + otherwise: Joi.string(), + }), }), }, },