![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
magic-validator
Advanced tools
A simple validation package for common data types in Node.js.
Install the package via npm:
npm install magic-validator
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
FAQs
A simple validation package for common data types.
The npm package magic-validator receives a total of 0 weekly downloads. As such, magic-validator popularity was classified as not popular.
We found that magic-validator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.