From 9600327ab14ac2edbd4f566aefbbb4ffc912f27e Mon Sep 17 00:00:00 2001 From: P-Jeremy Date: Mon, 25 Nov 2024 11:43:59 +0100 Subject: [PATCH] :recycle: api: refactor joi validation on simulator route --- .../application/scenario-simulator-route.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/api/src/certification/flash-certification/application/scenario-simulator-route.js b/api/src/certification/flash-certification/application/scenario-simulator-route.js index d4483c55698..a5ebec53887 100644 --- a/api/src/certification/flash-certification/application/scenario-simulator-route.js +++ b/api/src/certification/flash-certification/application/scenario-simulator-route.js @@ -3,13 +3,6 @@ import Joi from 'joi'; import { securityPreHandlers } from '../../../shared/application/security-pre-handlers.js'; import { scenarioSimulatorController } from './scenario-simulator-controller.js'; -const _baseScenarioParametersValidator = Joi.object().keys({ - initialCapacity: Joi.number().integer().min(-8).max(8), - numberOfIterations: Joi.number().integer().min(0), - challengePickProbability: Joi.number().min(0).max(100), - variationPercent: Joi.number().min(0).max(1), -}); - const register = async (server) => { server.route([ { @@ -26,8 +19,12 @@ const register = async (server) => { options: { allowUnknown: true, }, - payload: _baseScenarioParametersValidator + payload: Joi.object() .keys({ + initialCapacity: Joi.number().integer().min(-8).max(8), + numberOfIterations: Joi.number().integer().min(0), + challengePickProbability: Joi.number().min(0).max(100), + variationPercent: Joi.number().min(0).max(1), capacity: Joi.number().min(-8).max(8).required(), }) .required(),