I refer the post How to do form field validation in node.js ?(express-validator)
I want to ask is if I implement code as answered by @agm1984 in above post then,
What is use of this code in Nodejs program ?
Why to use expressValidator ?
When we write a server, we can never trust the data that the clients send us. And, sometimes, users might send wrong data like for email, they might send some random string which will pollute your database. Sometimes, they can also send a SQL command like string that will probably execute something on you SQL db (read SQL Injection).
So, to make sure that the data that you get from client is good, you have to validate it.
And, express-validator
provides an easy interface for validating the request in Express and also gives good error messages as to why the validation failed. And, yes, you can use express-validator
like in the answer you mentioned.