Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
commons-validator-es
Advanced tools
Apache Commons Validator ported to TypeScript as a tree-shakable ES6 module
Install the library with npm install commons-validator-es
To use as an ES6 module:
import { isEmail } from 'commons-validator-es';
isEmail('test@test.com'); // => true
isEmail('test@test.con'); // => false!
It works as a CommonJS module too, for backwards compatibility
const validator = require('commons-validator-es');
validator.isEmail('test@test.com'); // => true
validator.isEmail('test@test.con'); // => false!
Validator | Description |
---|---|
isEmail(email, allowLocal?, allowTld?) | Checks if email is a valid email address. Ensures fields like the TLD are valid (no .con !)If allowLocal is true, emails like test@localhost are validIf allowTld is true, emails like test@com are valid |
isDomain(domain, allowLocal?) | Checks if domain is a valid domain nameIf allowLocal is true, domains like localhost.localdomain are valid, as are single name labels (like hostname ) |
isTld(tld, allowLocal?) | Checks if tld is a valid tld (.com is allowed but .con is not, for example)If allowLocal is true, tlds like localdomain are valid |
isIpAddress(address) | Checks if address is a valid IPv4 or IPv6 address |
isIpv4Address(address) | Checks if address is a valid IPv4 address |
isIpv6Address(address) | Checks if address is a valid IPv6 address |
isCountryCodeTld(ccTld) | Checks if ccTld is a valid country code TLD (like .au ) |
isGenericTld(gTld) | Checks if gTld is a valid generic TLD (like .com ) |
isInfrastructureTld(iTld) | Checks if iTld is a valid infrastructure TLD (only valid is .arpa ) |
isLocalTld(lTld) | Checks if lTld is a valid local TLD (like .localdomain ) |
commons-validator-js hasn't been updated in a while and does not export an ES6 module. I'll be continuing to add more validators to this to bring it to parity with Apache Commons Validator
FAQs
Apache Commons Validator ported to TypeScript
We found that commons-validator-es demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.