From 8c35d399c657a6d8b06c0c28a4b4f7760f291ec5 Mon Sep 17 00:00:00 2001 From: mahyargdz Date: Tue, 31 Dec 2024 16:25:51 +0330 Subject: [PATCH] fix --- server/controllers/GPS.User.js | 36 +++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/server/controllers/GPS.User.js b/server/controllers/GPS.User.js index 4e79f54..85c438d 100644 --- a/server/controllers/GPS.User.js +++ b/server/controllers/GPS.User.js @@ -409,8 +409,6 @@ module.exports.updateUserByAdmin = [ }) }), - body('shopName').optional().notEmpty().withMessage(_faSr.required.address), - body('mobile_number') .optional() .notEmpty() @@ -431,9 +429,37 @@ module.exports.updateUserByAdmin = [ }) }), - body('cell_number').optional().notEmpty().withMessage(_faSr.required.phone_number).bail(), - body('birthDate').optional().notEmpty().withMessage(_faSr.required.birthdate).bail(), - body('address').optional().notEmpty().withMessage(_faSr.required.address).bail() + body('shopName') + .optional() + .custom((value, { req }) => { + if (value === '') return true + return value ? true : Promise.reject(_faSr.required.shop_name) + }) + .bail(), + + body('cell_number') + .optional() + .custom((value, { req }) => { + if (value === '') return true + return value ? true : Promise.reject(_faSr.required.phone_number) + }) + .bail(), + + body('birthDate') + .optional() + .custom((value, { req }) => { + if (value === '') return true + return value ? true : Promise.reject(_faSr.required.birthdate) + }) + .bail(), + + body('address') + .optional() + .custom((value, { req }) => { + if (value === '') return true + return value ? true : Promise.reject(_faSr.required.address) + }) + .bail() ], checkValidations(validationResult), async (req, res) => {