
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
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.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.