@investorphem/validator-tools
v1.0.3
Published
Lightweight JS validation library for emails, phone numbers, URLs, and strong passwords.
Maintainers
Readme
@investorphem/validator-tools
🚀 Description
@investorphem/validator-tools is a lightweight JavaScript library for common validation tasks. It provides simple, fast, and secure functions to validate emails, phone numbers, URLs, and strong passwords.
✨ Features
- 📧 Validate emails with
isEmail - 📱 Validate international phone numbers with
isPhoneNumber - 🔗 Check URLs with
isUrl - 🔐 Enforce strong passwords with
isStrongPassword - 🛡️ Type-Safe: Automatically catches
null,undefined, or non-string inputs without crashing. - ⚡ Modern ESM: Native ES Module support (
import/export) - 🍃 Zero dependencies (ultra-lightweight)
- 🤖 Fully automated GitHub Actions publishing workflow
📦 Installation
npm install @investorphem/validator-toolsor via yarn:
yarn add @investorphem/validator-tools🧠 Usage (ES Modules)
Since version 1.0.2, this package uses standard ES Modules.
import { isEmail, isPhoneNumber, isUrl, isStrongPassword } from '@investorphem/validator-tools';
console.log(isEmail('[email protected]')); // true
console.log(isPhoneNumber('+12345678901')); // true
console.log(isUrl('[https://google.com](https://google.com)')); // true
console.log(isStrongPassword('Passw0rd!')); // true
// Safely handles invalid types without throwing regex errors
console.log(isEmail(null)); // false📚 API
isEmail(str)
Checks if a string is a valid email format.
Parameters:
str(string) – Email string to validate
Returns:
- (boolean) – True if valid email
isPhoneNumber(str)
Checks if a string is a valid international phone number (allows optional + and requires 7-15 digits).
Parameters:
str(string) – Phone number string
Returns:
- (boolean) – True if valid phone number
isUrl(str)
Checks if a string is a properly formatted URL.
Parameters:
str(string) – URL string
Returns:
- (boolean) – True if valid URL
isStrongPassword(str)
Checks if a string meets strong password criteria:
- Minimum 8 characters
- At least 1 lowercase letter
- At least 1 uppercase letter
- At least 1 number
- At least 1 special character
Parameters:
str(string) – Password string
Returns:
- (boolean) – True if strong password
⚙️ Automated Releases
This project uses an automated release script. To publish a new version:
- Commit your changes:
git commit -m "update validations" - Run the release command:
npm run release
This will automatically bump the patch version, create a git tag, and push to GitHub, triggering the automated NPM publish action.
🛠️ Contributing
Contributions are welcome! Please fork the repo, make improvements, and submit a pull request. Ensure code follows StandardJS style.
📄 License
This project is licensed under the MIT License.
🏷️ Badges Explained
- npm version: Current package version on npm
- npm downloads: Total downloads from npm
- License: License type
- Build Status: GitHub Actions workflow status
- JavaScript Style Guide: Code style standard
- Contributors: Number of contributors
Maintained by Oluwafemi Olagoke
