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

@types/validator

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/validator

TypeScript definitions for validator

  • 13.12.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.8M
decreased by-11.22%
Maintainers
1
Weekly downloads
 
Created

What is @types/validator?

The @types/validator package provides TypeScript type definitions for the validator.js library, which is a tool for string validation and sanitization. This package does not contain functionality by itself but offers type support for TypeScript users of validator.js, enabling them to utilize the library in a type-safe manner.

What are @types/validator's main functionalities?

Email Validation

This feature allows you to validate whether a string is a valid email address.

import validator from 'validator';

const email = 'test@example.com';
const isValidEmail = validator.isEmail(email);
console.log(isValidEmail); // true or false

URL Validation

This feature enables you to check if a string is a valid URL.

import validator from 'validator';

const url = 'https://www.example.com';
const isValidUrl = validator.isURL(url);
console.log(isValidUrl); // true or false

Sanitize Data

This feature allows you to sanitize input to prevent XSS attacks by escaping HTML characters.

import validator from 'validator';

const dirtyString = '<script>Alert('XSS')</script>'; 
const cleanString = validator.escape(dirtyString);
console.log(cleanString); // '&lt;script&gt;Alert(&#x27;XSS&#x27;)&lt;/script&gt;'

Other packages similar to @types/validator

FAQs

Package last updated on 26 Aug 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