How to Validate Data using validator Module in Node.js ? Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report The 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 a 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 the validator module you can check your validator version in the 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. node index.js Project Structure: Filename: index.js javascript const validator = require('validator') // Check whether given email is valid or not let email = '[email protected]' console.log(validator.isEmail(email)) // true email = 'test@' console.log(validator.isEmail(email)) // false // Check whether string is in lowercase or not let name = 'geeksforgeeks' console.log(validator.isLowercase(name)) // true name = 'GEEKSFORGEEKS' console.log(validator.isLowercase(name)) // false // Check whether string is empty or not let name = '' console.log(validator.isEmpty(name)) // true name = 'geeksforgeeks' console.log(validator.isEmpty(name)) // false // Other functions also available in // this module like isBoolean() // isCurrency(), isDecimal(), isJSON(), // isJWT(), isFloat(), isCreditCard(), etc. Steps to run the program: Make sure you have to install the express and validator modules using the following commands: npm install validator npm install express Run the index.js file using the below command: node index.js Output: So this is how you can use the validator module for validation. There are also other modules available in the market for validation like hapi-joi, express-validator, etc. Comment More infoAdvertise with us Next Article How to Validate Data using validator Module in Node.js ? gouravhammad Follow Improve Article Tags : JavaScript Web Technologies Node.js Write From Home Node.js-Misc +1 More Similar Reads How to Validate Data using express-validator Module in Node.js ? Validation in node.js can be easily done by using the express-validator module. This module is popular for data validation. There are other modules available in market like hapi/joi, etc but express-validator is widely used and popular among them.Steps to install express-validator module:  You can 3 min read How to Validate Data using joi Module in Node.js ? Joi module is a popular module for data validation. This module validates the data based on schemas. There are various functions like optional(), required(), min(), max(), etc which make it easy to use and a user-friendly module for validating the data. Introduction to joi It's easy to get started a 3 min read How to Validate Nested Objects with Class-Validator in Nest.js? Validating nested objects in Nest.js using the class validator is crucial for ensuring the integrity and structure of incoming data, especially when dealing with complex data models. Class validator works seamlessly with Nest.js to validate incoming request data using Data Transfer Objects (DTOs). T 4 min read How to validate if input in input field has float number only using express-validator ? In HTML forms, we often required validation of different types. Validate existing email, validate password length, validate confirm password, validate to allow only integer inputs, these are some examples of validation. In a certain input field, only float numbers are allowed i.e. there not allowed 5 min read How to validate if input in input field is a valid date using express-validator ? In HTML forms, we often required validation of different types. Validate existing email, validate password length, validate confirm password, validate to allow only integer inputs, these are some examples of validation. In a certain input field, only a valid date is allowed i.e. there is not allowed 4 min read How to validate if input in input field has alphabets only using express-validator ? In HTML forms, we often required validation of different types. Validate existing email, validate password length, validate confirm password, validate to allow only integer inputs, these are some examples of validation. In a certain input field, only alphabets are allowed i.e. there not allowed any 5 min read How to validate if input in input field has integer number only using express-validator ? In HTML forms, we often required validation of different types. Validate existing email, validate password length, validate confirm password, validate to allow only integer inputs, these are some examples of validation. In a certain input field, only integer numbers are allowed i.e. there not allowe 5 min read How to validate if input in input field has decimal number only using express-validator ? In HTML forms, we often required validation of different types. Validate existing email, validate password length, validate confirm password, validate to allow only integer inputs, these are some examples of validation. In a certain input field, only decimal numbers are allowed i.e. there not allowe 5 min read How to validate if input in input field must contains a seed word using express-validator ? In HTML forms, we often required validation of different types. Validate existing email, validate password length, validate confirm password, validate to allow only integer inputs, these are some examples of validation. In a certain input field, we often need to validate input so that it must contai 5 min read How to validate if input in input field has lowercase letters only using express-validator ? In HTML forms, we often required validation of different types. Validate existing email, validate password length, validate confirm password, validate to allow only integer inputs, these are some examples of validation. In a certain input field, only lowercase letters are allowed. We can also valida 5 min read Like