New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

magic-validator

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

magic-validator

A simple validation package for common data types.

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

magic-validate

A simple validation package for common data types in Node.js.

Installation

Install the package via npm:

npm install magic-validator

Usage

const { validateEmail, validateURL, validatePhoneNumber, validateUsername, validatePassword, validateName, validateIPAddress, validateMACAddress, validateJWTToken } = require('magic-validator');

// Validate an email address
const email = 'test@example.com';
console.log('Email validation:', validateEmail(email)); // true

// Validate a URL
const url = 'https://example.com';
console.log('URL validation:', validateURL(url)); // true

// Validate a phone number (validate 10 numbers)
const phoneNumber = '1234567890';
console.log('Phone number validation:', validatePhoneNumber(phoneNumber)); // true

// Validate a username
const username = 'user123';
console.log('Username validation:', validateUsername(username)); // true

// Validate a password
const password = 'Passw0rd!';
console.log('Password validation:', validatePassword(password)); // true

// Validate a name
const name = 'John Doe';
console.log('Name validation:', validateName(name)); // true

// Validate an IP address
const ipAddress = '192.168.0.1';
console.log('IP address validation:', validateIPAddress(ipAddress)); // true

// Validate a MAC address
const macAddress = '00:1A:2B:3C:4D:5E';
console.log('MAC address validation:', validateMACAddress(macAddress)); // true

// Validate a JWT token
const jwtToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';
console.log('JWT token validation:', validateJWTToken(jwtToken)); // true

Keywords

FAQs

Package last updated on 22 Mar 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