regex-validify
v3.0.3
Published
Validation tool for validating user's input.
Downloads
329
Maintainers
Readme
🛠️ Regex Validify 🛡️
📚 Table of Contents
Installation
Install the Regex Validify package by running:
$ npm i regex-validify
This will install the latest version of the package and make it available for use in your project.
Description
Regex Validify is a powerful validation library packed with robust functions for checking various types of data. From emails and passwords to complex custom regex checks, this library simplifies input validation. 💥🔒
Features
- ✅ Email Validation ✉️: Ensures the string is a valid email address.
- ✅ Date Validation 📅: Verifies the date is in the format
DD/MM/YYYY
. - ✅ Password Strength Validation 🔑: Validates passwords with different strength levels: simple, medium, and complex.
- ✅ URL Validation 🌐: Checks if the URL follows the correct format.
- ✅ IPv4 & IPv6 Validation 🌍: Ensures IP addresses are in valid IPv4 or IPv6 format.
- ✅ Credit Card Validation 💳: Validates credit card numbers using the Luhn algorithm.
- ✅ MAC Address Validation 🖧: Verifies the MAC address format.
- ✅ Username Validation 👤: Checks if the username follows the correct format.
- ✅ Custom Regex Support 🔍: Allows you to validate any input using custom regex patterns.
And many more! 🚀
Usage
Import Functions
import Validators from 'regex-validify';
// Validate an email
const isValidEmail = Validators.checkEmail('[email protected]');
console.log(isValidEmail); // true ✅
// Validate a password for 'medium' strength
const isValidPassword = Validators.checkPassword('password123', 'medium');
console.log(isValidPassword); // true or false depending on validation 🔑
// Validate a date in DD/MM/YYYY format
const isValidDate = Validators.checkDate('12/05/2024');
console.log(isValidDate); // true ✅
// Validate a phone number
const isValidPhone = Validators.checkPhoneNumber('123-456-7890');
console.log(isValidPhone); // true 📞
// Validate a URL
const isValidURL = Validators.checkURL('https://www.example.com');
console.log(isValidURL); // true 🌐
- Import the whole
Validators
Container for big projects.
Functions
checkEmail
- Email Validator 📧
The checkEmail
function ensures that a given string is a valid email address (e.g., [email protected]
). This validation checks the presence of a valid domain and username format.
Example Usage:
const isValidEmail = checkEmail('[email protected]');
console.log(isValidEmail); // true ✅
checkPassword
- Password Strength Validator 🔑
Validates a password based on the provided strength level: simple, medium, or complex.
- Simple: Checks for basic characters.
- Medium: Requires numbers and special characters.
- Complex: Requires uppercase, lowercase, numbers, and special characters.
Example Usage:
const isValidPassword = checkPassword('password123', 'medium');
console.log(isValidPassword); // true ✅ or false ❌ depending on strength
checkDate
- Date Validator 📅
Validates if the input date is in the DD/MM/YYYY format.
Example Usage:
const isValidDate = checkDate('12/05/2024');
console.log(isValidDate); // true ✅
checkPhoneNumber
- Phone Number Validator 📞
Validates if the input is a valid phone number (e.g., 123-456-7890
).
Example Usage:
const isValidPhone = checkPhoneNumber('123-456-7890');
console.log(isValidPhone); // true 📞
checkURL
- URL Validator 🌐
Validates whether the input string is a valid URL (e.g., https://www.example.com
).
Example Usage:
const isValidURL = checkURL('https://www.example.com');
console.log(isValidURL); // true 🌐
checkIPv4
- IPv4 Address Validator 🌍
Validates whether the string represents a valid IPv4 address (e.g., 192.168.1.1
).
Example Usage:
const isValidIPv4 = checkIPv4('192.168.1.1');
console.log(isValidIPv4); // true 🌍
checkCreditCard
- Credit Card Validator 💳
Validates credit card numbers using the Luhn algorithm, ensuring they are correctly formatted.
Example Usage:
const isValidCard = checkCreditCard('4111111111111111');
console.log(isValidCard); // true 💳
checkUsername
- Username Validator 👤
Validates a username, ensuring it follows a valid pattern (e.g., only letters and numbers).
Example Usage:
const isValidUsername = checkUsername('user123');
console.log(isValidUsername); // true 👤
checkHexColor
- Hex Color Code Validator 🎨
Validates if the input string is a valid hexadecimal color code (e.g., #FF5733
).
Example Usage:
const isValidHexColor = checkHexColor('#FF5733');
console.log(isValidHexColor); // true 🎨
checkMACAddress
- MAC Address Validator 🖧
Validates if the string is a valid MAC address (e.g., 00:14:22:01:23:45
).
Example Usage:
const isValidMAC = checkMACAddress('00:14:22:01:23:45');
console.log(isValidMAC); // true 🖧
checkEmoji
- Emoji Validator 😊
Validates whether the string contains a valid emoji.
Example Usage:
const isValidEmoji = checkEmoji('😊');
console.log(isValidEmoji); // true 😊
checkAnsiArt
- ANSI Art Validator 🎨
Validates if the input string contains valid ANSI art.
Example Usage:
const isValidArt = checkAnsiArt('▒▒▒▒▒▒▒▒▒');
console.log(isValidArt); // true 🎨
customRegex
- Custom Regex Validator 🔍
Allows you to validate any string using custom regular expressions.
Example Usage:
const customPattern = (value) => /^[A-Za-z]+$/.test(value); // Only alphabets
const isValid = customRegex(customPattern, 'Hello');
console.log(isValid); // true ✅
License
This project is licensed under the ISC License.