Skip to content

Commit

Permalink
fixed validation
Browse files Browse the repository at this point in the history
  • Loading branch information
AmasiaNalbandian committed Dec 16, 2021
1 parent 3925230 commit f33158b
Showing 1 changed file with 16 additions and 29 deletions.
45 changes: 16 additions & 29 deletions src/api/search/src/bin/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
];

/**
Expand Down

0 comments on commit f33158b

Please sign in to comment.