regex-validify
v1.1.0
Published
๐Your ultimate data validation tool! ๐ก๏ธ Validate emails, passwords, URLs, and more effortlessly! Ensure clean and secure inputs for your applications! ๐
Downloads
169
Maintainers
Readme
๐ ๏ธ Regex Validify - Simplify Your Input Validation! ๐ก๏ธ
๐ Table of Contents
๐ Description
Regex Validify is a versatile JavaScript library that simplifies input validation by providing a set of regular expressions. With Regex Validify ๐ก๏ธ, you can easily validate email addresses, phone numbers, URLs, and much more, making your data validation process seamless and efficient!
๐ฆ Installation
To install Regex Validify, run the following command in your terminal:
npm install regex-validify
๐ Usage
After installation, you can use Regex Validify in your JavaScript project as follows:
import Regex from 'regex-validify';
import { CheckPhoneNumber, CheckDate } from 'regex-validify'
// Example usage
const isValidEmail = Regex.CheckEmail("[email protected]");
const isValidName = Regex.CheckName("John Doe");
console.log(`Is valid email: ${isValidEmail}`); // Output: Is valid email: true
console.log(`Is valid name: ${isValidName}`); // Output: Is valid name: true
console.log(`Is valid phoneNumber: ${CheckPhoneNumber("12340123")}`) // Output: Is valid phoneNumber: false
console.log(`Is valid Date: ${CheckDate("12/10/2010")}`) // Output: Is valid Date: true
๐ ๏ธ Methods
1. CheckEmail(email: string): boolean
Validates an email address.
- Example:
Regex.CheckEmail("[email protected]");
2. CheckName(name: string): boolean
Validates a name consisting only of letters and spaces.
- Example:
Regex.CheckName("John Doe");
3. CheckPhoneNumber(phone: string): boolean
Validates a 10-digit phone number.
- Example:
Regex.CheckPhoneNumber("1234567890");
4. CheckURL(url: string): boolean
Validates a URL.
- Example:
Regex.CheckURL("https://www.example.com");
5. CheckDate(date: string): boolean
Validates a date in DD/MM/YYYY format.
- Example:
Regex.CheckDate("31/12/2024");
6. CheckOnlyLetters(input: string): boolean
Validates a string with only letters.
- Example:
Regex.CheckOnlyLetters("HelloWorld");
7. CheckSpaces(input: string): boolean
Validates a string without spaces.
- Example:
Regex.CheckSpaces("NoSpaces");
8. CheckPassword(password: string, complexity: boolean): boolean
Validates a password, enforcing complex rules if specified.
- Example:
- Complex validation:
Regex.CheckPassword("P@ssw0rd123!", true);
- Simple validation:
Regex.CheckPassword("Password123", false);
- Complex validation:
9. CheckFloat(number: string): boolean
Validates a float number (including decimals).
- Example:
Regex.CheckFloat("123.45");
10. CheckUsername(username: string): boolean
Validates a username (alphanumeric, underscores, periods, and hyphens, 3-16 characters).
- Example:
Regex.CheckUsername("user.name-123");
11. CheckIPv4(ip: string): boolean
Validates an IPv4 address.
- Example:
Regex.CheckIPv4("192.168.0.1");
12. CheckHexColor(hex: string): boolean
Validates a hexadecimal color code.
- Example:
Regex.CheckHexColor("#FF5733");
13. CheckCreditCard(cardNumber: string): boolean
Validates a credit card number using the Luhn Algorithm.
- Example:
Regex.CheckCreditCard("4111111111111111");
14. CheckMACAddress(mac: string): boolean
Validates a MAC address.
- Example:
Regex.CheckMACAddress("00:1B:44:11:3A:B7");
๐จ Features
Regex Validify offers a range of features to enhance your input validation experience:
- Email Validation: Validate email addresses with ease.
- Phone Number Validation: Check for valid 10-digit phone numbers.
- URL Validation: Ensure that URLs are formatted correctly.
- Date Validation: Validate dates in the DD/MM/YYYY format.
- Complex Password Validation: Enforce rules for secure passwords.
- Only Letters Validation: Validate strings containing only letters.
- Spaces Validation: Check for strings without spaces.
- Float Number Validation: Validate float numbers including decimals.
- Username Validation: Validate usernames with specific character rules.
- IPv4 Address Validation: Validate IPv4 addresses.
- Hexadecimal Color Validation: Validate hexadecimal color codes.
- Credit Card Validation: Validate credit card numbers using the Luhn algorithm.
- MAC Address Validation: Validate MAC addresses.
- Check Name Validation: Validate names consisting of letters and spaces.
With Regex Validify, you can streamline your data validation process and ensure the integrity of your input!
๐ License
This project is licensed under the ISC License.