From 801781327763ee4c3508c9ebe063a41b44050bbd Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Fri, 27 Sep 2024 08:46:05 +0100 Subject: [PATCH] WIP --- backend/server.cask.scala | 2 ++ backend/server.http4s.scala | 2 ++ 2 files changed, 4 insertions(+) diff --git a/backend/server.cask.scala b/backend/server.cask.scala index 7bf2396..422a86e 100644 --- a/backend/server.cask.scala +++ b/backend/server.cask.scala @@ -98,6 +98,8 @@ object OptimizerServer extends cask.MainRoutes: error(s"Population size above maximum [${Limits.MaxPopulation}]") else if attrs.generations > Limits.MaxGenerations then error(s"Number of generations above maximum [${Limits.MaxGenerations}]") + else if attrs.generations <= 0 || attrs.populationSize <=0 then + error(s"Generations and population size must both be non-negative") else val (id, job) = createJob(attrs) cask.Response(id.toString(), 200) diff --git a/backend/server.http4s.scala b/backend/server.http4s.scala index 3c26382..7c7c5c5 100644 --- a/backend/server.http4s.scala +++ b/backend/server.http4s.scala @@ -180,6 +180,8 @@ def routes( error( s"Number of generations above maximum [${Limits.MaxGenerations}]" ) + else if attrs.generations <= 0 || attrs.populationSize <=0 then + error(s"Generations and population size must both be non-negative") else manager.createJob(attrs).flatMap((id, _) => Ok(id.toString())) end if