Skip to main content

isString

check('password')
  .not().isEmpty().withMessage('Password can't be null')
  .isString()
  .isLength({ min: 8 }),
check('retypePassword')
  .not().isEmpty().withMessage('Password can't be null')
  .isString().withMessage('Password must be a string')
  .custom((value, { req }) => {
    if(value.trim() !== req.body.password.trim()) {
      throw new Error ('Password confirmation does not match password');
    }
  }),