Validator module is popular for validation. Validation is necessary to check whether the data is correct or not, so this module is easy to use and validates data quickly and easily.
Feature of validator module:
- It is easy to get started and easy to use.
- It is widely used and popular module for validation.
- Simple functions for validation like isEmail(), isEmpty(), etc.
Installation of validator module:
- You can visit the link Install validator module. You can install this package by using this command.
npm install validator
- After installing validator module you can check your validator version in command prompt using the command.
npm version validator
- After that, you can just create a folder and add a file for example index.js, To run this file you need to run the following command.
Steps to run the program:
- The project structure will look like this:
- Make sure you have install express and validator module using the following commands:
npm install validator npm install express
- Run index.js file using below command:
So this is how you can use the validator module for validation. There are also other modules available in market for validation like hapi-joi, express-validator, etc.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.