Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7843413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:32:37+00:00 2026-06-02T16:32:37+00:00

In my nodejs app to filter all input data I use express-validator. Something like

  • 0

In my nodejs app to filter all input data I use express-validator. Something like this:

app.post('/', function (req, res) {
   req.sanitize('login').xss();
   req.sanitize('password').xss();

   //etc.
});

So my view is as:

form(action='/', method='POST')
  input(name='login', type='text')
  input(name='password', type='password')
  input(type='submit')

All works fine but if I omit login field for example:

form(action='/', method='POST')
  input(name='login', type='text')
  input(name='password', type='password')
  input(type='submit')

then I get exception. Why doesn’t express-validator check param existing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:32:38+00:00Added an answer on June 2, 2026 at 4:32 pm

    According to the documentation you’re using it wrong.

    Validation errors

    You have two choices on how to get the validation errors:

    req.assert('email', 'required').notEmpty();
    req.assert('email', 'valid email required').isEmail();
    req.assert('password', '6 to 20 characters required').len(6, 20);
    
    var errors = req.validationErrors();
    var mappedErrors = req.validationErrors(true);
    

    You’ll need to use req.assert to validate. req.sanitize is to sanitize input, like so:

    req.sanitize('postparam').toBoolean();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following express node.js app. It's using the 'redis' npm package. app.get(/test,function(req,res){
I have nodejs application with mongodb(mongoose). like this: var mongoose = require('mongoose'); var express
I'd like to watch for certain changes on a couchdb in a NodeJS app,
after install Express.js, I wrote this on node: var express = require('express'), app =express.createServer();
I have this NodeJS app which fetches JSON-type response from a web application and
I have a nodejs app, is there a module or a function that returns
I have an NodeJS Express app that is getting really big in just one
In my NodeJS express application I have app.js that has a few common routes.
Is it possible to compress multiple files with UglifyJS? Something like... uglifyjs -o app.build.js
I'm writing a simple NodeJS app with mongo. For connecting to mongo I use:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.