From d460d412b4cf2ee3e577b7f8318bda35a77996a3 Mon Sep 17 00:00:00 2001
From: Irakli Maisuradze <mysuradze@gmail.com>
Date: Sun, 16 Jan 2022 01:37:36 +0100
Subject: [PATCH] fixed Update an Account rout

---
 server/src/routes/accounts.routes.ts | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/server/src/routes/accounts.routes.ts b/server/src/routes/accounts.routes.ts
index 8c9c6d1..3acae1a 100644
--- a/server/src/routes/accounts.routes.ts
+++ b/server/src/routes/accounts.routes.ts
@@ -33,7 +33,12 @@ accountsRouter.get(
 //update account
 accountsRouter.patch(
   "/api/accounts/:id/",
-  handleValidationResult, //!! not working here
+  body("first_name").if(body("first_name").exists()).not().isEmpty(),
+  body("last_name").if(body("last_name").exists()).not().isEmpty(),
+  body("email").if(body("email").exists()).isEmail().normalizeEmail(),
+  body("role").if(body("role").exists()).isIn(["coordinator", "boatManager"]),
+  body("password").if(body("password").exists()).isLength({ min: 6 }),
+  handleValidationResult,
   validateToken,
   accountsControllers.updateAccount
 );
-- 
GitLab