jsvalidator-2025
v1.0.0
Published
This NPM package provides two utility functions for validating email addresses and phone numbers. It's designed to be lightweight, easy to use, and suitable for various projects.
Readme
jsvalidator-2025
This NPM package provides two utility functions for validating email addresses and phone numbers. It's designed to be lightweight, easy to use, and suitable for various projects.
Features
- Email Validation: Checks if a given string is a valid email address.
- Phone Number Validation: Checks if a given string is a valid phone number, supporting various formats and international numbers.
Installation
Install the package using NPM:
npm install jsvalidator-2025Usage
Import the functions into your project and use them as needed:
Example Code
import { isValidEmail, isValidPhone } from 'jsvalidator-2025';
// Validate an email address
console.log(isValidEmail("[email protected]")); // true
console.log(isValidEmail("invalid-email")); // false
// Validate a phone number
console.log(isValidPhone("+1 123-456-7890")); // true
console.log(isValidPhone("123-456")); // falseFunctions
isValidEmail(email)
Checks if the provided string is a valid email address.
Parameters
email(string): The email address to validate.
Returns
boolean:trueif the email is valid,falseotherwise.
Example
isValidEmail("[email protected]"); // true
isValidEmail("not-an-email"); // falseisValidPhone(phone)
Checks if the provided string is a valid phone number.
Parameters
phone(string): The phone number to validate.
Returns
boolean:trueif the phone number is valid,falseotherwise.
Example
isValidPhone("+1 800-555-5555"); // true
isValidPhone("invalid-phone"); // falseFile Structure
jsvalidator-2025/
├── index.js # Main file with validation functions
├── package.json # Package configuration
├── README.md # Documentation
└── .npmignore # Files to ignore during publishingLicense
This project is licensed under the MIT License.
Contributing
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
Author
Developed by CodeWithReyaz.
Start validating email addresses and phone numbers with ease using this package. Happy coding!
