From the course: Building a Website with Node.js and Express.js
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Validating and sanitizing user input
From the course: Building a Website with Node.js and Express.js
Validating and sanitizing user input
- [Instructor] We can now receive the form date of when a form is posted. How can we make sure that this date is complete and also doesn't contain malicious data, like JavaScript malware? Regardless of which measures you take in the browser to validate a form, a malicious user can always circumvent that. In short, you cannot trust data from the client. This means that we need to add measures to the service site to make sure that the data the user sent to us is valid. And for that we will use the module, express-validator. It makes input validation pretty easy. So I'm just stopping my server again and I type npm install express-validator. And in my feedback module, I can now add const and curly brackets because it's, again, destructuring assignment, check, validationResult equals require express-validator. And this will all make sense to you in a second. Check is a routing malware. This means it accepts the same request…