Search code examples
node.jsexpressmiddleware

What does the express-validator escape() function?


What exactly does the express-validator escape() sanitizer? Can't understand. For example:

check('name')
  .trim()
  .escape()
  .notEmpty()
  .withMessage('User name can not be empty!')
  .bail()
  .isLength({ min: 3 })
  .withMessage('Minimum 3 characters required!')
  .bail(),

Why there is a need to escape() after trim()?


Solution

  • Thanks to robertklep. Every sanitizer is described here:

    Sanitizers