Category Archives: validation

How to do String validation in Node.js?

In all real time application we need to use validation so that proper data is been entered by user. Lets see how we can do it in Node.js:

Node.js provides ‘validator‘ library to do validation. To install validator do following:

npm install validator

This package covers most of the string sanitization and validation.

For example, isEmail(), isURL(), isIP(), etc.

On server side you need to check validation as shown below:

var validator = require(validator);
validator.isEmail(mail_id _from_params); 
On client side do following:
Add <script type=”text/javascript” src=”validator.min.js”></script>
validator.isEmail(; // return true

ProsperaSoft offers Node.js development solutions. You can email at to get in touch with ProsperaSoft Node.js experts and consultants.