Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

validator

Package Overview
Dependencies
Maintainers
2
Versions
211
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

validator

String validation and sanitization

  • 13.12.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11M
decreased by-9.97%
Maintainers
2
Weekly downloads
 
Created

What is validator?

The validator npm package is a library of string validators and sanitizers. It provides a variety of functions to validate and sanitize strings, such as checking if a string is in a certain format (e.g., email, URL) or transforming strings to ensure they are safe for use in different contexts.

What are validator's main functionalities?

Email Validation

Checks if the input string is an email.

const validator = require('validator');
console.log(validator.isEmail('test@example.com')); // true

URL Validation

Checks if the input string is a URL.

const validator = require('validator');
console.log(validator.isURL('https://www.example.com')); // true

Sanitizing Strings

Escapes HTML characters in the input string to prevent XSS attacks.

const validator = require('validator');
console.log(validator.escape('<script>alert("xss")</script>')); // '&lt;script&gt;alert(&quot;xss&quot;)&lt;/script&gt;'

Checking String Length

Checks if the input string's length falls within a specified range.

const validator = require('validator');
console.log(validator.isLength('Hello', {min: 2, max: 10})); // true

Blacklisting Characters

Removes specified characters from the input string.

const validator = require('validator');
console.log(validator.blacklist('abc123', '123')); // 'abc'

Other packages similar to validator

Keywords

FAQs

Package last updated on 09 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc