Socket
Socket
Sign inDemoInstall

safe-textify

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    safe-textify

"safe-textify: Secure your inputs effortlessly. This npm package offers robust input validation and sanitization tools, safeguarding your application against common security threats like XSS attacks. With customizable rules and clear error handling, ensur


Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
1
Install size
2.91 kB
Created
Weekly downloads
 

Readme

Source

safe-textify

safe-textify is a simple npm package for sanitizing strings and validating email addresses.

Installation

You can install safe-textify using npm:

npm install safe-textify

Usage

sanitize(input)

Sanitizes the input string by replacing special characters with specified replacements.

const { sanitize } = require('safe-textify');

const sanitizedString = sanitize('Hello <World>!');
console.log(sanitizedString); // Output: Hello __World!_

validateEmail(email)

Validates the given email address against a regular expression pattern.

const { validateEmail } = require('safe-textify');

const isValidEmail = validateEmail('test@example.com');
console.log(isValidEmail); // Output: true

API

sanitize(input)

  • input (string): The string to sanitize.

Returns the sanitized string.

validateEmail(email)

  • email (string): The email address to validate.

Returns true if the email address is valid according to the regular expression pattern, otherwise false.

Example

const { sanitize, validateEmail } = require('safe-textify');

// Sanitize string
const sanitizedString = sanitize('Hello <World>!');
console.log(sanitizedString); // Output: Hello __World!_

// Validate email
const isValidEmail = validateEmail('test@example.com');
console.log(isValidEmail); // Output: true

License

MIT

Keywords

FAQs

Last updated on 18 Mar 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc