From f33158b2d36ef9dd494c28c3501417aa2b056071 Mon Sep 17 00:00:00 2001 From: AmasiaNalbandian Date: Wed, 15 Dec 2021 20:32:46 -0500 Subject: [PATCH] fixed validation --- src/api/search/src/bin/validation.js | 45 ++++++++++------------------ 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/src/api/search/src/bin/validation.js b/src/api/search/src/bin/validation.js index a5d8ae27bb..c159b53849 100644 --- a/src/api/search/src/bin/validation.js +++ b/src/api/search/src/bin/validation.js @@ -51,41 +51,28 @@ const advancedQueryValidationRules = [ .isLength({ max: 100, min: 2 }) .withMessage('invalid author value') .bail(), - - check('dateEnd') - .exists({ checkFalsy: true }) - .withMessage('dateEnd should exist') - .bail() - .isLength({ max: 100, min: 2 }) - .withMessage('invalid author value') - .bail() - .isISO8601() - .withMessage('invalid date format') - .bail(), - - check('dateStart') + check('titleText') .exists({ checkFalsy: true }) - .withMessage('dateEnd should exist') + .withMessage('title should exist') .bail() .isLength({ max: 100, min: 2 }) - .withMessage('invalid author value') - .bail() - .isISO8601() - .withMessage('invalid date format') + .withMessage('invalid title value') .bail(), + ]), + check('dateEnd').optional().isISO8601().withMessage('invalid date format').bail(), - check('perPage') - .optional() - .isInt({ min: 1, max: 10 }) - .withMessage('perPage should be empty or a number between 1 to 10') - .bail(), + check('dateStart').optional().isISO8601().withMessage('invalid date format').bail(), + check('perPage') + .optional() + .isInt({ min: 1, max: 10 }) + .withMessage('perPage should be empty or a number between 1 to 10') + .bail(), - check('page') - .optional() - .isInt({ min: 0, max: 999 }) - .withMessage('page should be empty or a number between 0 to 999') - .bail(), - ]), + check('page') + .optional() + .isInt({ min: 0, max: 999 }) + .withMessage('page should be empty or a number between 0 to 999') + .bail(), ]; /**